diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-03-23 18:33:08 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-23 18:33:10 +0000 |
commit | 356176177633a619f4a916248536e4e7a5fb9b2e (patch) | |
tree | 32893c6fc11bae091e7ad4daa0e53c9e9757f726 | |
parent | 2a16460c7c914729e9c256ce39d681524d53b7dc (diff) | |
parent | 05199e83a460683e2af06212b0dc7310647e8502 (diff) | |
download | frameworks_base-356176177633a619f4a916248536e4e7a5fb9b2e.zip frameworks_base-356176177633a619f4a916248536e4e7a5fb9b2e.tar.gz frameworks_base-356176177633a619f4a916248536e4e7a5fb9b2e.tar.bz2 |
Merge "Set the appliance (tv/watch) in the configuration earlier"
-rw-r--r-- | services/core/java/com/android/server/UiModeManagerService.java | 26 | ||||
-rw-r--r-- | services/java/com/android/server/SystemServer.java | 6 |
2 files changed, 23 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index 87dc420..64f3070 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -157,7 +157,6 @@ final class UiModeManagerService extends SystemService { @Override public void onStart() { final Context context = getContext(); - mTwilightManager = getLocalService(TwilightManager.class); final PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); @@ -188,7 +187,11 @@ final class UiModeManagerService extends SystemService { mNightMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.UI_NIGHT_MODE, defaultNightMode); - mTwilightManager.registerListener(mTwilightListener, mHandler); + // Update the initial, static configurations. + synchronized (this) { + updateConfigurationLocked(); + sendConfigurationLocked(); + } publishBinderService(Context.UI_MODE_SERVICE, mService); } @@ -297,8 +300,11 @@ final class UiModeManagerService extends SystemService { pw.print(" mSetUiMode=0x"); pw.println(Integer.toHexString(mSetUiMode)); pw.print(" mHoldingConfiguration="); pw.print(mHoldingConfiguration); pw.print(" mSystemReady="); pw.println(mSystemReady); - pw.print(" mTwilightService.getCurrentState()="); - pw.println(mTwilightManager.getCurrentState()); + if (mTwilightManager != null) { + // We may not have a TwilightManager. + pw.print(" mTwilightService.getCurrentState()="); + pw.println(mTwilightManager.getCurrentState()); + } } } @@ -306,6 +312,10 @@ final class UiModeManagerService extends SystemService { public void onBootPhase(int phase) { if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) { synchronized (mLock) { + mTwilightManager = getLocalService(TwilightManager.class); + if (mTwilightManager != null) { + mTwilightManager.registerListener(mTwilightListener, mHandler); + } mSystemReady = true; mCarModeEnabled = mDockState == Intent.EXTRA_DOCK_STATE_CAR; updateComputedNightModeLocked(); @@ -623,9 +633,11 @@ final class UiModeManagerService extends SystemService { } private void updateComputedNightModeLocked() { - TwilightState state = mTwilightManager.getCurrentState(); - if (state != null) { - mComputedNightMode = state.isNight(); + if (mTwilightManager != null) { + TwilightState state = mTwilightManager.getCurrentState(); + if (state != null) { + mComputedNightMode = state.isNight(); + } } } diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index bcd8d42..ae2c54b 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -564,6 +564,10 @@ public final class SystemServer { } } + // We start this here so that we update our configuration to set watch or television + // as appropriate. + mSystemServiceManager.startService(UiModeManagerService.class); + try { mPackageManagerService.performBootDexOpt(); } catch (Throwable e) { @@ -843,8 +847,6 @@ public final class SystemServer { mSystemServiceManager.startService(TwilightService.class); - mSystemServiceManager.startService(UiModeManagerService.class); - mSystemServiceManager.startService(JobSchedulerService.class); if (!disableNonCoreServices) { |