Summary
If a theme exists at sites/*/mytheme/, install_default_theme('mytheme') and install_admin_theme('mytheme') work.
If a theme exists at profiles/myprofile/mytheme/, install_default_theme('mytheme') and install_admin_theme('mytheme') do not work.
As I'm sure you know, Drupal now automatically packages modules and themes that are required by installation profiles.
Drupal places required themes in profile/profilename/themes. The problem is that for some reason, the themes in this directory cannot be enabled with install_default_theme() and install_admin_theme(). When an install profile tries to do this, the user receives error messages from system.inc (which from my experience seems to indicate that the theme cannot be found). The user will then have a broken theme, but as soon as he visits admin/build/themes, the theme originally set with install_default_theme() and install_admin_theme() will become active.
On the other hand, if the theme exists in sites/*/themes before install_default_theme() and install_admin_theme() are called, the theme becomes active as expected.
Comments
Comment #1
john.karahalis commentedCorrection: The errors relate to system.module, not system.inc.
Below is the actual error message that a user receives when a profile tries to use install_default_theme() and install_admin_theme() to enable a packaged theme. The actual messages are less-than-helpful, but as I said, I have seen them appear in the past when a profile was trying to enable a theme that Drupal couldn't find.
Comment #2
dww#330297: Themes in profiles directory not discovered during install