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