@Override public void onStart() { final Context context = getContext(); mTwilightManager = getLocalService(TwilightManager.class); final PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); context.registerReceiver(mDockModeReceiver, new IntentFilter(Intent.ACTION_DOCK_EVENT)); context.registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); mConfiguration.setToDefaults(); mDefaultUiModeType = context.getResources().getInteger( com.android.internal.R.integer.config_defaultUiModeType); mCarModeKeepsScreenOn = (context.getResources().getInteger( com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1); mDeskModeKeepsScreenOn = (context.getResources().getInteger( com.android.internal.R.integer.config_deskDockKeepsScreenOn) == 1); mTelevision = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TELEVISION) || context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK); mWatch = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); mNightMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.UI_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO); mTwilightManager.registerListener(mTwilightListener, mHandler); publishBinderService(Context.UI_MODE_SERVICE, mService); }
void dumpImpl(PrintWriter pw) { synchronized (mLock) { pw.println("Current UI Mode Service state:"); pw.print(" mDockState="); pw.print(mDockState); pw.print(" mLastBroadcastState="); pw.println(mLastBroadcastState); pw.print(" mNightMode="); pw.print(mNightMode); pw.print(" mCarModeEnabled="); pw.print(mCarModeEnabled); pw.print(" mComputedNightMode="); pw.print(mComputedNightMode); pw.print(" mCarModeEnableFlags="); pw.println(mCarModeEnableFlags); pw.print(" mCurUiMode=0x"); pw.print(Integer.toHexString(mCurUiMode)); 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()); } }