Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server; |
| 18 | |
| 19 | import android.app.Activity; |
| 20 | import android.app.ActivityManagerNative; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 21 | import android.app.IUiModeManager; |
| 22 | import android.app.Notification; |
| 23 | import android.app.NotificationManager; |
| 24 | import android.app.PendingIntent; |
| 25 | import android.app.StatusBarManager; |
| 26 | import android.app.UiModeManager; |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 27 | import android.content.ActivityNotFoundException; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 28 | import android.content.BroadcastReceiver; |
| 29 | import android.content.Context; |
| 30 | import android.content.Intent; |
| 31 | import android.content.IntentFilter; |
| 32 | import android.content.pm.PackageManager; |
| 33 | import android.content.res.Configuration; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 34 | import android.os.BatteryManager; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 35 | import android.os.Binder; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 36 | import android.os.Handler; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 37 | import android.os.PowerManager; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 38 | import android.os.RemoteException; |
| 39 | import android.os.ServiceManager; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 40 | import android.provider.Settings; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 41 | import android.util.Slog; |
| 42 | |
| 43 | import java.io.FileDescriptor; |
| 44 | import java.io.PrintWriter; |
| 45 | |
| 46 | import com.android.internal.R; |
| 47 | import com.android.internal.app.DisableCarModeActivity; |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 48 | import com.android.server.TwilightService.TwilightState; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 49 | |
| 50 | class UiModeManagerService extends IUiModeManager.Stub { |
| 51 | private static final String TAG = UiModeManager.class.getSimpleName(); |
| 52 | private static final boolean LOG = false; |
| 53 | |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 54 | // Enable launching of applications when entering the dock. |
| 55 | private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true; |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 56 | private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = true; |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 57 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 58 | private final Context mContext; |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 59 | private final TwilightService mTwilightService; |
| 60 | private final Handler mHandler = new Handler(); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 61 | |
| 62 | final Object mLock = new Object(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 63 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 64 | private int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 65 | private int mLastBroadcastState = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 66 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 67 | private int mNightMode = UiModeManager.MODE_NIGHT_NO; |
| 68 | private boolean mCarModeEnabled = false; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 69 | private boolean mCharging = false; |
Joe Onorato | 44fcb83 | 2011-12-14 20:59:30 -0800 | [diff] [blame] | 70 | private final int mDefaultUiModeType; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 71 | private final boolean mCarModeKeepsScreenOn; |
| 72 | private final boolean mDeskModeKeepsScreenOn; |
Dianne Hackborn | 0cf2c8a | 2012-05-17 17:29:49 -0700 | [diff] [blame] | 73 | private final boolean mTelevision; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 74 | |
| 75 | private boolean mComputedNightMode; |
| 76 | private int mCurUiMode = 0; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 77 | private int mSetUiMode = 0; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 78 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 79 | private boolean mHoldingConfiguration = false; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 80 | private Configuration mConfiguration = new Configuration(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 81 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 82 | private boolean mSystemReady; |
| 83 | |
| 84 | private NotificationManager mNotificationManager; |
| 85 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 86 | private StatusBarManager mStatusBarManager; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 87 | private final PowerManager.WakeLock mWakeLock; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 88 | |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 89 | static Intent buildHomeIntent(String category) { |
| 90 | Intent intent = new Intent(Intent.ACTION_MAIN); |
| 91 | intent.addCategory(category); |
| 92 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 93 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 94 | return intent; |
| 95 | } |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 96 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 97 | // The broadcast receiver which receives the result of the ordered broadcast sent when |
| 98 | // the dock state changes. The original ordered broadcast is sent with an initial result |
| 99 | // code of RESULT_OK. If any of the registered broadcast receivers changes this value, e.g., |
| 100 | // to RESULT_CANCELED, then the intent to start a dock app will not be sent. |
| 101 | private final BroadcastReceiver mResultReceiver = new BroadcastReceiver() { |
| 102 | @Override |
| 103 | public void onReceive(Context context, Intent intent) { |
| 104 | if (getResultCode() != Activity.RESULT_OK) { |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 105 | if (LOG) { |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 106 | Slog.v(TAG, "Handling broadcast result for action " + intent.getAction() |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 107 | + ": canceled: " + getResultCode()); |
| 108 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 109 | return; |
| 110 | } |
| 111 | |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 112 | final int enableFlags = intent.getIntExtra("enableFlags", 0); |
| 113 | final int disableFlags = intent.getIntExtra("disableFlags", 0); |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 114 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 115 | synchronized (mLock) { |
| 116 | // Launch a dock activity |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 117 | String category = null; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 118 | if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 119 | // Only launch car home when car mode is enabled and the caller |
| 120 | // has asked us to switch to it. |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 121 | if (ENABLE_LAUNCH_CAR_DOCK_APP |
| 122 | && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 123 | category = Intent.CATEGORY_CAR_DOCK; |
| 124 | } |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 125 | } else if (UiModeManager.ACTION_ENTER_DESK_MODE.equals(intent.getAction())) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 126 | // Only launch car home when desk mode is enabled and the caller |
| 127 | // has asked us to switch to it. Currently re-using the car |
| 128 | // mode flag since we don't have a formal API for "desk mode". |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 129 | if (ENABLE_LAUNCH_DESK_DOCK_APP |
| 130 | && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 131 | category = Intent.CATEGORY_DESK_DOCK; |
| 132 | } |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 133 | } else { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 134 | // Launch the standard home app if requested. |
| 135 | if ((disableFlags&UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { |
| 136 | category = Intent.CATEGORY_HOME; |
| 137 | } |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 138 | } |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 139 | |
| 140 | if (LOG) { |
| 141 | Slog.v(TAG, String.format( |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 142 | "Handling broadcast result for action %s: enable=0x%08x disable=0x%08x category=%s", |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 143 | intent.getAction(), enableFlags, disableFlags, category)); |
| 144 | } |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 145 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 146 | if (category != null) { |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 147 | // This is the new activity that will serve as home while |
| 148 | // we are in care mode. |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 149 | Intent homeIntent = buildHomeIntent(category); |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 150 | |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 151 | // Now we are going to be careful about switching the |
| 152 | // configuration and starting the activity -- we need to |
| 153 | // do this in a specific order under control of the |
| 154 | // activity manager, to do it cleanly. So compute the |
| 155 | // new config, but don't set it yet, and let the |
| 156 | // activity manager take care of both the start and config |
| 157 | // change. |
| 158 | Configuration newConfig = null; |
| 159 | if (mHoldingConfiguration) { |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 160 | mHoldingConfiguration = false; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 161 | updateConfigurationLocked(false); |
| 162 | newConfig = mConfiguration; |
| 163 | } |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 164 | try { |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 165 | ActivityManagerNative.getDefault().startActivityWithConfig( |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 166 | null, homeIntent, null, null, null, 0, 0, |
| 167 | newConfig, null); |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 168 | mHoldingConfiguration = false; |
| 169 | } catch (RemoteException e) { |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 170 | Slog.w(TAG, e.getCause()); |
| 171 | } |
| 172 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 173 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 174 | if (mHoldingConfiguration) { |
| 175 | mHoldingConfiguration = false; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 176 | updateConfigurationLocked(true); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | } |
| 180 | }; |
| 181 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 182 | private final BroadcastReceiver mDockModeReceiver = new BroadcastReceiver() { |
| 183 | @Override |
| 184 | public void onReceive(Context context, Intent intent) { |
| 185 | int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 186 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 187 | updateDockState(state); |
| 188 | } |
| 189 | }; |
| 190 | |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 191 | private final BroadcastReceiver mBatteryReceiver = new BroadcastReceiver() { |
| 192 | @Override |
| 193 | public void onReceive(Context context, Intent intent) { |
| 194 | mCharging = (intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0); |
| 195 | synchronized (mLock) { |
| 196 | if (mSystemReady) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 197 | updateLocked(0, 0); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 198 | } |
| 199 | } |
| 200 | } |
| 201 | }; |
| 202 | |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 203 | private final TwilightService.TwilightListener mTwilightListener = |
| 204 | new TwilightService.TwilightListener() { |
Dianne Hackborn | 57f4503 | 2010-06-17 15:49:33 -0700 | [diff] [blame] | 205 | @Override |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 206 | public void onTwilightStateChanged() { |
| 207 | updateTwilight(); |
Dianne Hackborn | 57f4503 | 2010-06-17 15:49:33 -0700 | [diff] [blame] | 208 | } |
| 209 | }; |
| 210 | |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 211 | public UiModeManagerService(Context context, TwilightService twilight) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 212 | mContext = context; |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 213 | mTwilightService = twilight; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 214 | |
| 215 | ServiceManager.addService(Context.UI_MODE_SERVICE, this); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 216 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 217 | mContext.registerReceiver(mDockModeReceiver, |
| 218 | new IntentFilter(Intent.ACTION_DOCK_EVENT)); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 219 | mContext.registerReceiver(mBatteryReceiver, |
| 220 | new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); |
| 221 | |
| 222 | PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 223 | mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 224 | |
| 225 | mConfiguration.setToDefaults(); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 226 | |
Joe Onorato | 44fcb83 | 2011-12-14 20:59:30 -0800 | [diff] [blame] | 227 | mDefaultUiModeType = context.getResources().getInteger( |
| 228 | com.android.internal.R.integer.config_defaultUiModeType); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 229 | mCarModeKeepsScreenOn = (context.getResources().getInteger( |
| 230 | com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1); |
| 231 | mDeskModeKeepsScreenOn = (context.getResources().getInteger( |
| 232 | com.android.internal.R.integer.config_deskDockKeepsScreenOn) == 1); |
Dianne Hackborn | 0cf2c8a | 2012-05-17 17:29:49 -0700 | [diff] [blame] | 233 | mTelevision = context.getPackageManager().hasSystemFeature( |
| 234 | PackageManager.FEATURE_TELEVISION); |
| 235 | |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 236 | mNightMode = Settings.Secure.getInt(mContext.getContentResolver(), |
| 237 | Settings.Secure.UI_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO); |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 238 | |
| 239 | mTwilightService.registerListener(mTwilightListener, mHandler); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 240 | } |
| 241 | |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 242 | public void disableCarMode(int flags) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 243 | synchronized (mLock) { |
| 244 | setCarModeLocked(false); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 245 | if (mSystemReady) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 246 | updateLocked(0, flags); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 247 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 251 | public void enableCarMode(int flags) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 252 | synchronized (mLock) { |
| 253 | setCarModeLocked(true); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 254 | if (mSystemReady) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 255 | updateLocked(flags, 0); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 256 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 257 | } |
| 258 | } |
| 259 | |
| 260 | public int getCurrentModeType() { |
| 261 | synchronized (mLock) { |
| 262 | return mCurUiMode & Configuration.UI_MODE_TYPE_MASK; |
| 263 | } |
| 264 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 265 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 266 | public void setNightMode(int mode) throws RemoteException { |
| 267 | synchronized (mLock) { |
| 268 | switch (mode) { |
| 269 | case UiModeManager.MODE_NIGHT_NO: |
| 270 | case UiModeManager.MODE_NIGHT_YES: |
| 271 | case UiModeManager.MODE_NIGHT_AUTO: |
| 272 | break; |
| 273 | default: |
| 274 | throw new IllegalArgumentException("Unknown mode: " + mode); |
| 275 | } |
| 276 | if (!isDoingNightMode()) { |
| 277 | return; |
| 278 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 279 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 280 | if (mNightMode != mode) { |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 281 | long ident = Binder.clearCallingIdentity(); |
| 282 | Settings.Secure.putInt(mContext.getContentResolver(), |
| 283 | Settings.Secure.UI_NIGHT_MODE, mode); |
| 284 | Binder.restoreCallingIdentity(ident); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 285 | mNightMode = mode; |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 286 | updateLocked(0, 0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 287 | } |
| 288 | } |
| 289 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 290 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 291 | public int getNightMode() throws RemoteException { |
| 292 | return mNightMode; |
| 293 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 294 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 295 | void systemReady() { |
| 296 | synchronized (mLock) { |
| 297 | mSystemReady = true; |
| 298 | mCarModeEnabled = mDockState == Intent.EXTRA_DOCK_STATE_CAR; |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 299 | updateComputedNightModeLocked(); |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 300 | updateLocked(0, 0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 301 | } |
| 302 | } |
| 303 | |
| 304 | boolean isDoingNightMode() { |
| 305 | return mCarModeEnabled || mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 306 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 307 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 308 | void setCarModeLocked(boolean enabled) { |
| 309 | if (mCarModeEnabled != enabled) { |
| 310 | mCarModeEnabled = enabled; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
| 314 | void updateDockState(int newState) { |
| 315 | synchronized (mLock) { |
| 316 | if (newState != mDockState) { |
| 317 | mDockState = newState; |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 318 | setCarModeLocked(mDockState == Intent.EXTRA_DOCK_STATE_CAR); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 319 | if (mSystemReady) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 320 | updateLocked(UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME, 0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | } |
| 324 | } |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 325 | |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 326 | final static boolean isDeskDockState(int state) { |
| 327 | switch (state) { |
| 328 | case Intent.EXTRA_DOCK_STATE_DESK: |
| 329 | case Intent.EXTRA_DOCK_STATE_LE_DESK: |
| 330 | case Intent.EXTRA_DOCK_STATE_HE_DESK: |
| 331 | return true; |
| 332 | default: |
| 333 | return false; |
| 334 | } |
| 335 | } |
| 336 | |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 337 | final void updateConfigurationLocked(boolean sendIt) { |
Dianne Hackborn | 0cf2c8a | 2012-05-17 17:29:49 -0700 | [diff] [blame] | 338 | int uiMode = mTelevision ? Configuration.UI_MODE_TYPE_TELEVISION |
| 339 | : mDefaultUiModeType; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 340 | if (mCarModeEnabled) { |
| 341 | uiMode = Configuration.UI_MODE_TYPE_CAR; |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 342 | } else if (isDeskDockState(mDockState)) { |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 343 | uiMode = Configuration.UI_MODE_TYPE_DESK; |
| 344 | } |
Dianne Hackborn | 9c9c532 | 2010-03-30 23:12:22 -0700 | [diff] [blame] | 345 | if (mCarModeEnabled) { |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 346 | if (mNightMode == UiModeManager.MODE_NIGHT_AUTO) { |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 347 | updateComputedNightModeLocked(); |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 348 | uiMode |= mComputedNightMode ? Configuration.UI_MODE_NIGHT_YES |
| 349 | : Configuration.UI_MODE_NIGHT_NO; |
| 350 | } else { |
| 351 | uiMode |= mNightMode << 4; |
| 352 | } |
| 353 | } else { |
| 354 | // Disabling the car mode clears the night mode. |
Daniel Sandler | 8daf2a4 | 2010-04-02 10:15:09 -0400 | [diff] [blame] | 355 | uiMode = (uiMode & ~Configuration.UI_MODE_NIGHT_MASK) | Configuration.UI_MODE_NIGHT_NO; |
| 356 | } |
| 357 | |
| 358 | if (LOG) { |
John Spurlock | 960779d | 2012-05-29 14:37:05 -0400 | [diff] [blame] | 359 | Slog.d(TAG, |
| 360 | "updateConfigurationLocked: mDockState=" + mDockState |
Daniel Sandler | 8daf2a4 | 2010-04-02 10:15:09 -0400 | [diff] [blame] | 361 | + "; mCarMode=" + mCarModeEnabled |
| 362 | + "; mNightMode=" + mNightMode |
| 363 | + "; uiMode=" + uiMode); |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 364 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 365 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 366 | mCurUiMode = uiMode; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 367 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 368 | if (!mHoldingConfiguration && uiMode != mSetUiMode) { |
| 369 | mSetUiMode = uiMode; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 370 | mConfiguration.uiMode = uiMode; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 371 | |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 372 | if (sendIt) { |
| 373 | try { |
| 374 | ActivityManagerNative.getDefault().updateConfiguration(mConfiguration); |
| 375 | } catch (RemoteException e) { |
| 376 | Slog.w(TAG, "Failure communicating with activity manager", e); |
| 377 | } |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 378 | } |
| 379 | } |
| 380 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 381 | |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 382 | final void updateLocked(int enableFlags, int disableFlags) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 383 | long ident = Binder.clearCallingIdentity(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 384 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 385 | try { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 386 | String action = null; |
| 387 | String oldAction = null; |
| 388 | if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_CAR) { |
Tobias Haamel | 780b260 | 2010-03-15 12:54:45 +0100 | [diff] [blame] | 389 | adjustStatusBarCarModeLocked(); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 390 | oldAction = UiModeManager.ACTION_EXIT_CAR_MODE; |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 391 | } else if (isDeskDockState(mLastBroadcastState)) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 392 | oldAction = UiModeManager.ACTION_EXIT_DESK_MODE; |
| 393 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 394 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 395 | if (mCarModeEnabled) { |
| 396 | if (mLastBroadcastState != Intent.EXTRA_DOCK_STATE_CAR) { |
| 397 | adjustStatusBarCarModeLocked(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 398 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 399 | if (oldAction != null) { |
| 400 | mContext.sendBroadcast(new Intent(oldAction)); |
| 401 | } |
| 402 | mLastBroadcastState = Intent.EXTRA_DOCK_STATE_CAR; |
| 403 | action = UiModeManager.ACTION_ENTER_CAR_MODE; |
| 404 | } |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 405 | } else if (isDeskDockState(mDockState)) { |
| 406 | if (!isDeskDockState(mLastBroadcastState)) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 407 | if (oldAction != null) { |
| 408 | mContext.sendBroadcast(new Intent(oldAction)); |
| 409 | } |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 410 | mLastBroadcastState = mDockState; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 411 | action = UiModeManager.ACTION_ENTER_DESK_MODE; |
| 412 | } |
| 413 | } else { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 414 | mLastBroadcastState = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 415 | action = oldAction; |
| 416 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 417 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 418 | if (action != null) { |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 419 | if (LOG) { |
| 420 | Slog.v(TAG, String.format( |
| 421 | "updateLocked: preparing broadcast: action=%s enable=0x%08x disable=0x%08x", |
| 422 | action, enableFlags, disableFlags)); |
| 423 | } |
| 424 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 425 | // Send the ordered broadcast; the result receiver will receive after all |
| 426 | // broadcasts have been sent. If any broadcast receiver changes the result |
| 427 | // code from the initial value of RESULT_OK, then the result receiver will |
| 428 | // not launch the corresponding dock application. This gives apps a chance |
| 429 | // to override the behavior and stay in their app even when the device is |
| 430 | // placed into a dock. |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 431 | Intent intent = new Intent(action); |
| 432 | intent.putExtra("enableFlags", enableFlags); |
| 433 | intent.putExtra("disableFlags", disableFlags); |
| 434 | mContext.sendOrderedBroadcast(intent, null, |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 435 | mResultReceiver, null, Activity.RESULT_OK, null, null); |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 436 | // Attempting to make this transition a little more clean, we are going |
| 437 | // to hold off on doing a configuration change until we have finished |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 438 | // the broadcast and started the home activity. |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 439 | mHoldingConfiguration = true; |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 440 | } else { |
| 441 | Intent homeIntent = null; |
| 442 | if (mCarModeEnabled) { |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 443 | if (ENABLE_LAUNCH_CAR_DOCK_APP |
| 444 | && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 445 | homeIntent = buildHomeIntent(Intent.CATEGORY_CAR_DOCK); |
| 446 | } |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 447 | } else if (isDeskDockState(mDockState)) { |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 448 | if (ENABLE_LAUNCH_DESK_DOCK_APP |
| 449 | && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 450 | homeIntent = buildHomeIntent(Intent.CATEGORY_DESK_DOCK); |
| 451 | } |
| 452 | } else { |
| 453 | if ((disableFlags&UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { |
| 454 | homeIntent = buildHomeIntent(Intent.CATEGORY_HOME); |
| 455 | } |
| 456 | } |
Daniel Sandler | 69a1da4 | 2011-11-04 15:08:30 -0400 | [diff] [blame] | 457 | |
| 458 | if (LOG) { |
| 459 | Slog.v(TAG, "updateLocked: null action, mDockState=" |
| 460 | + mDockState +", firing homeIntent: " + homeIntent); |
| 461 | } |
| 462 | |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 463 | if (homeIntent != null) { |
| 464 | try { |
| 465 | mContext.startActivity(homeIntent); |
| 466 | } catch (ActivityNotFoundException e) { |
| 467 | } |
| 468 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 469 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 470 | |
Dianne Hackborn | f5c5d22 | 2010-04-09 13:14:48 -0700 | [diff] [blame] | 471 | updateConfigurationLocked(true); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 472 | |
| 473 | // keep screen on when charging and in car mode |
| 474 | boolean keepScreenOn = mCharging && |
| 475 | ((mCarModeEnabled && mCarModeKeepsScreenOn) || |
| 476 | (mCurUiMode == Configuration.UI_MODE_TYPE_DESK && mDeskModeKeepsScreenOn)); |
| 477 | if (keepScreenOn != mWakeLock.isHeld()) { |
| 478 | if (keepScreenOn) { |
| 479 | mWakeLock.acquire(); |
| 480 | } else { |
| 481 | mWakeLock.release(); |
| 482 | } |
| 483 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 484 | } finally { |
| 485 | Binder.restoreCallingIdentity(ident); |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | private void adjustStatusBarCarModeLocked() { |
| 490 | if (mStatusBarManager == null) { |
| 491 | mStatusBarManager = (StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE); |
| 492 | } |
| 493 | |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 494 | // Fear not: StatusBarManagerService manages a list of requests to disable |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 495 | // features of the status bar; these are ORed together to form the |
| 496 | // active disabled list. So if (for example) the device is locked and |
| 497 | // the status bar should be totally disabled, the calls below will |
| 498 | // have no effect until the device is unlocked. |
| 499 | if (mStatusBarManager != null) { |
| 500 | mStatusBarManager.disable(mCarModeEnabled |
| 501 | ? StatusBarManager.DISABLE_NOTIFICATION_TICKER |
| 502 | : StatusBarManager.DISABLE_NONE); |
| 503 | } |
| 504 | |
| 505 | if (mNotificationManager == null) { |
| 506 | mNotificationManager = (NotificationManager) |
| 507 | mContext.getSystemService(Context.NOTIFICATION_SERVICE); |
| 508 | } |
| 509 | |
| 510 | if (mNotificationManager != null) { |
| 511 | if (mCarModeEnabled) { |
| 512 | Intent carModeOffIntent = new Intent(mContext, DisableCarModeActivity.class); |
| 513 | |
| 514 | Notification n = new Notification(); |
| 515 | n.icon = R.drawable.stat_notify_car_mode; |
| 516 | n.defaults = Notification.DEFAULT_LIGHTS; |
| 517 | n.flags = Notification.FLAG_ONGOING_EVENT; |
| 518 | n.when = 0; |
| 519 | n.setLatestEventInfo( |
| 520 | mContext, |
| 521 | mContext.getString(R.string.car_mode_disable_notification_title), |
| 522 | mContext.getString(R.string.car_mode_disable_notification_message), |
| 523 | PendingIntent.getActivity(mContext, 0, carModeOffIntent, 0)); |
| 524 | mNotificationManager.notify(0, n); |
| 525 | } else { |
| 526 | mNotificationManager.cancel(0); |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 531 | private void updateTwilight() { |
| 532 | synchronized (mLock) { |
| 533 | if (isDoingNightMode() && mNightMode == UiModeManager.MODE_NIGHT_AUTO) { |
| 534 | updateComputedNightModeLocked(); |
| 535 | updateLocked(0, 0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 536 | } |
| 537 | } |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 538 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 539 | |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 540 | private void updateComputedNightModeLocked() { |
| 541 | TwilightState state = mTwilightService.getCurrentState(); |
| 542 | if (state != null) { |
| 543 | mComputedNightMode = state.isNight(); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 544 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 545 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 546 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 547 | @Override |
| 548 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 549 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 550 | != PackageManager.PERMISSION_GRANTED) { |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 551 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 552 | pw.println("Permission Denial: can't dump uimode service from from pid=" |
| 553 | + Binder.getCallingPid() |
| 554 | + ", uid=" + Binder.getCallingUid()); |
| 555 | return; |
| 556 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 557 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 558 | synchronized (mLock) { |
| 559 | pw.println("Current UI Mode Service state:"); |
| 560 | pw.print(" mDockState="); pw.print(mDockState); |
| 561 | pw.print(" mLastBroadcastState="); pw.println(mLastBroadcastState); |
| 562 | pw.print(" mNightMode="); pw.print(mNightMode); |
| 563 | pw.print(" mCarModeEnabled="); pw.print(mCarModeEnabled); |
| 564 | pw.print(" mComputedNightMode="); pw.println(mComputedNightMode); |
| 565 | pw.print(" mCurUiMode=0x"); pw.print(Integer.toHexString(mCurUiMode)); |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 566 | pw.print(" mSetUiMode=0x"); pw.println(Integer.toHexString(mSetUiMode)); |
| 567 | pw.print(" mHoldingConfiguration="); pw.print(mHoldingConfiguration); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 568 | pw.print(" mSystemReady="); pw.println(mSystemReady); |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 569 | pw.print(" mTwilightService.getCurrentState()="); |
| 570 | pw.println(mTwilightService.getCurrentState()); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 571 | } |
| 572 | } |
| 573 | } |