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; |
| 21 | import android.app.AlarmManager; |
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; |
| 34 | import android.location.Criteria; |
| 35 | import android.location.Location; |
| 36 | import android.location.LocationListener; |
| 37 | import android.location.LocationManager; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 38 | import android.os.BatteryManager; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 39 | import android.os.Binder; |
| 40 | import android.os.Bundle; |
| 41 | import android.os.Handler; |
| 42 | import android.os.Message; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 43 | import android.os.PowerManager; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 44 | import android.os.RemoteException; |
| 45 | import android.os.ServiceManager; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 46 | import android.provider.Settings; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 47 | import android.text.format.DateUtils; |
| 48 | import android.text.format.Time; |
| 49 | import android.util.Slog; |
| 50 | |
| 51 | import java.io.FileDescriptor; |
| 52 | import java.io.PrintWriter; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 53 | import java.util.Iterator; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 54 | |
| 55 | import com.android.internal.R; |
| 56 | import com.android.internal.app.DisableCarModeActivity; |
| 57 | |
| 58 | class UiModeManagerService extends IUiModeManager.Stub { |
| 59 | private static final String TAG = UiModeManager.class.getSimpleName(); |
| 60 | private static final boolean LOG = false; |
| 61 | |
| 62 | private static final String KEY_LAST_UPDATE_INTERVAL = "LAST_UPDATE_INTERVAL"; |
| 63 | |
| 64 | private static final int MSG_UPDATE_TWILIGHT = 0; |
| 65 | private static final int MSG_ENABLE_LOCATION_UPDATES = 1; |
| 66 | |
| 67 | private static final long LOCATION_UPDATE_MS = 30 * DateUtils.MINUTE_IN_MILLIS; |
| 68 | private static final float LOCATION_UPDATE_DISTANCE_METER = 1000 * 20; |
| 69 | private static final long LOCATION_UPDATE_ENABLE_INTERVAL_MIN = 5000; |
| 70 | private static final long LOCATION_UPDATE_ENABLE_INTERVAL_MAX = 5 * DateUtils.MINUTE_IN_MILLIS; |
| 71 | private static final double FACTOR_GMT_OFFSET_LONGITUDE = 1000.0 * 360.0 / DateUtils.DAY_IN_MILLIS; |
| 72 | |
| 73 | private static final String ACTION_UPDATE_NIGHT_MODE = "com.android.server.action.UPDATE_NIGHT_MODE"; |
| 74 | |
| 75 | private final Context mContext; |
| 76 | |
| 77 | final Object mLock = new Object(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 78 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 79 | private int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 80 | private int mLastBroadcastState = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
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 int mNightMode = UiModeManager.MODE_NIGHT_NO; |
| 83 | private boolean mCarModeEnabled = false; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 84 | private boolean mCharging = false; |
| 85 | private final boolean mCarModeKeepsScreenOn; |
| 86 | private final boolean mDeskModeKeepsScreenOn; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 87 | |
| 88 | private boolean mComputedNightMode; |
| 89 | private int mCurUiMode = 0; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 90 | private int mSetUiMode = 0; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 91 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 92 | private boolean mHoldingConfiguration = false; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 93 | private Configuration mConfiguration = new Configuration(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 94 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 95 | private boolean mSystemReady; |
| 96 | |
| 97 | private NotificationManager mNotificationManager; |
| 98 | |
| 99 | private AlarmManager mAlarmManager; |
| 100 | |
| 101 | private LocationManager mLocationManager; |
| 102 | private Location mLocation; |
| 103 | private StatusBarManager mStatusBarManager; |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 104 | private final PowerManager.WakeLock mWakeLock; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 105 | |
| 106 | // The broadcast receiver which receives the result of the ordered broadcast sent when |
| 107 | // the dock state changes. The original ordered broadcast is sent with an initial result |
| 108 | // code of RESULT_OK. If any of the registered broadcast receivers changes this value, e.g., |
| 109 | // to RESULT_CANCELED, then the intent to start a dock app will not be sent. |
| 110 | private final BroadcastReceiver mResultReceiver = new BroadcastReceiver() { |
| 111 | @Override |
| 112 | public void onReceive(Context context, Intent intent) { |
| 113 | if (getResultCode() != Activity.RESULT_OK) { |
| 114 | return; |
| 115 | } |
| 116 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 117 | synchronized (mLock) { |
| 118 | // Launch a dock activity |
| 119 | String category; |
| 120 | if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { |
| 121 | // Only launch car home when car mode is enabled. |
| 122 | category = Intent.CATEGORY_CAR_DOCK; |
| 123 | } else if (UiModeManager.ACTION_ENTER_DESK_MODE.equals(intent.getAction())) { |
| 124 | category = Intent.CATEGORY_DESK_DOCK; |
| 125 | } else { |
| 126 | category = null; |
| 127 | } |
| 128 | if (category != null) { |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 129 | // This is the new activity that will serve as home while |
| 130 | // we are in care mode. |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 131 | intent = new Intent(Intent.ACTION_MAIN); |
| 132 | intent.addCategory(category); |
| 133 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 134 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 135 | |
| 136 | // Now we are going to be careful about switching the |
| 137 | // configuration and starting the activity -- we need to |
| 138 | // do this in a specific order under control of the |
| 139 | // activity manager, to do it cleanly. So compute the |
| 140 | // new config, but don't set it yet, and let the |
| 141 | // activity manager take care of both the start and config |
| 142 | // change. |
| 143 | Configuration newConfig = null; |
| 144 | if (mHoldingConfiguration) { |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 145 | mHoldingConfiguration = false; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 146 | updateConfigurationLocked(false); |
| 147 | newConfig = mConfiguration; |
| 148 | } |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 149 | try { |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 150 | ActivityManagerNative.getDefault().startActivityWithConfig( |
| 151 | null, intent, null, null, 0, null, null, 0, false, false, |
| 152 | newConfig); |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 153 | mHoldingConfiguration = false; |
| 154 | } catch (RemoteException e) { |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 155 | Slog.w(TAG, e.getCause()); |
| 156 | } |
| 157 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 158 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 159 | if (mHoldingConfiguration) { |
| 160 | mHoldingConfiguration = false; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 161 | updateConfigurationLocked(true); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | } |
| 165 | }; |
| 166 | |
| 167 | private final BroadcastReceiver mTwilightUpdateReceiver = new BroadcastReceiver() { |
| 168 | @Override |
| 169 | public void onReceive(Context context, Intent intent) { |
| 170 | if (isDoingNightMode() && mNightMode == UiModeManager.MODE_NIGHT_AUTO) { |
| 171 | mHandler.sendEmptyMessage(MSG_UPDATE_TWILIGHT); |
| 172 | } |
| 173 | } |
| 174 | }; |
| 175 | |
| 176 | private final BroadcastReceiver mDockModeReceiver = new BroadcastReceiver() { |
| 177 | @Override |
| 178 | public void onReceive(Context context, Intent intent) { |
| 179 | int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 180 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 181 | updateDockState(state); |
| 182 | } |
| 183 | }; |
| 184 | |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 185 | private final BroadcastReceiver mBatteryReceiver = new BroadcastReceiver() { |
| 186 | @Override |
| 187 | public void onReceive(Context context, Intent intent) { |
| 188 | mCharging = (intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0); |
| 189 | synchronized (mLock) { |
| 190 | if (mSystemReady) { |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 191 | updateLocked(0); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 192 | } |
| 193 | } |
| 194 | } |
| 195 | }; |
| 196 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 197 | // A LocationListener to initialize the network location provider. The location updates |
| 198 | // are handled through the passive location provider. |
| 199 | private final LocationListener mEmptyLocationListener = new LocationListener() { |
| 200 | public void onLocationChanged(Location location) { |
| 201 | } |
| 202 | |
| 203 | public void onProviderDisabled(String provider) { |
| 204 | } |
| 205 | |
| 206 | public void onProviderEnabled(String provider) { |
| 207 | } |
| 208 | |
| 209 | public void onStatusChanged(String provider, int status, Bundle extras) { |
| 210 | } |
| 211 | }; |
| 212 | |
| 213 | private final LocationListener mLocationListener = new LocationListener() { |
| 214 | |
| 215 | public void onLocationChanged(Location location) { |
| 216 | final boolean hasMoved = hasMoved(location); |
| 217 | final boolean hasBetterAccuracy = mLocation == null |
| 218 | || location.getAccuracy() < mLocation.getAccuracy(); |
| 219 | if (hasMoved || hasBetterAccuracy) { |
| 220 | synchronized (mLock) { |
| 221 | mLocation = location; |
| 222 | if (hasMoved && isDoingNightMode() |
| 223 | && mNightMode == UiModeManager.MODE_NIGHT_AUTO) { |
| 224 | mHandler.sendEmptyMessage(MSG_UPDATE_TWILIGHT); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | public void onProviderDisabled(String provider) { |
| 231 | } |
| 232 | |
| 233 | public void onProviderEnabled(String provider) { |
| 234 | } |
| 235 | |
| 236 | public void onStatusChanged(String provider, int status, Bundle extras) { |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | * The user has moved if the accuracy circles of the two locations |
| 241 | * don't overlap. |
| 242 | */ |
| 243 | private boolean hasMoved(Location location) { |
| 244 | if (location == null) { |
| 245 | return false; |
| 246 | } |
| 247 | if (mLocation == null) { |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | /* if new location is older than the current one, the devices hasn't |
| 252 | * moved. |
| 253 | */ |
| 254 | if (location.getTime() < mLocation.getTime()) { |
| 255 | return false; |
| 256 | } |
| 257 | |
| 258 | /* Get the distance between the two points */ |
| 259 | float distance = mLocation.distanceTo(location); |
| 260 | |
| 261 | /* Get the total accuracy radius for both locations */ |
| 262 | float totalAccuracy = mLocation.getAccuracy() + location.getAccuracy(); |
| 263 | |
| 264 | /* If the distance is greater than the combined accuracy of the two |
| 265 | * points then they can't overlap and hence the user has moved. |
| 266 | */ |
| 267 | return distance >= totalAccuracy; |
| 268 | } |
| 269 | }; |
| 270 | |
| 271 | public UiModeManagerService(Context context) { |
| 272 | mContext = context; |
| 273 | |
| 274 | ServiceManager.addService(Context.UI_MODE_SERVICE, this); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 275 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 276 | mAlarmManager = |
| 277 | (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE); |
| 278 | mLocationManager = |
| 279 | (LocationManager)mContext.getSystemService(Context.LOCATION_SERVICE); |
| 280 | mContext.registerReceiver(mTwilightUpdateReceiver, |
| 281 | new IntentFilter(ACTION_UPDATE_NIGHT_MODE)); |
| 282 | mContext.registerReceiver(mDockModeReceiver, |
| 283 | new IntentFilter(Intent.ACTION_DOCK_EVENT)); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 284 | mContext.registerReceiver(mBatteryReceiver, |
| 285 | new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); |
| 286 | |
| 287 | PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 288 | mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 289 | |
| 290 | mConfiguration.setToDefaults(); |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 291 | |
| 292 | mCarModeKeepsScreenOn = (context.getResources().getInteger( |
| 293 | com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1); |
| 294 | mDeskModeKeepsScreenOn = (context.getResources().getInteger( |
| 295 | com.android.internal.R.integer.config_deskDockKeepsScreenOn) == 1); |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 296 | |
| 297 | mNightMode = Settings.Secure.getInt(mContext.getContentResolver(), |
| 298 | Settings.Secure.UI_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 299 | } |
| 300 | |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 301 | public void disableCarMode(int flags) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 302 | synchronized (mLock) { |
| 303 | setCarModeLocked(false); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 304 | if (mSystemReady) { |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 305 | updateLocked(flags); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 306 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 307 | } |
| 308 | } |
| 309 | |
| 310 | public void enableCarMode() { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 311 | synchronized (mLock) { |
| 312 | setCarModeLocked(true); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 313 | if (mSystemReady) { |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 314 | updateLocked(0); |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 315 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 316 | } |
| 317 | } |
| 318 | |
| 319 | public int getCurrentModeType() { |
| 320 | synchronized (mLock) { |
| 321 | return mCurUiMode & Configuration.UI_MODE_TYPE_MASK; |
| 322 | } |
| 323 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 324 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 325 | public void setNightMode(int mode) throws RemoteException { |
| 326 | synchronized (mLock) { |
| 327 | switch (mode) { |
| 328 | case UiModeManager.MODE_NIGHT_NO: |
| 329 | case UiModeManager.MODE_NIGHT_YES: |
| 330 | case UiModeManager.MODE_NIGHT_AUTO: |
| 331 | break; |
| 332 | default: |
| 333 | throw new IllegalArgumentException("Unknown mode: " + mode); |
| 334 | } |
| 335 | if (!isDoingNightMode()) { |
| 336 | return; |
| 337 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 338 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 339 | if (mNightMode != mode) { |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 340 | long ident = Binder.clearCallingIdentity(); |
| 341 | Settings.Secure.putInt(mContext.getContentResolver(), |
| 342 | Settings.Secure.UI_NIGHT_MODE, mode); |
| 343 | Binder.restoreCallingIdentity(ident); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 344 | mNightMode = mode; |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 345 | updateLocked(0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 349 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 350 | public int getNightMode() throws RemoteException { |
| 351 | return mNightMode; |
| 352 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 353 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 354 | void systemReady() { |
| 355 | synchronized (mLock) { |
| 356 | mSystemReady = true; |
| 357 | mCarModeEnabled = mDockState == Intent.EXTRA_DOCK_STATE_CAR; |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 358 | updateLocked(0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 359 | mHandler.sendEmptyMessage(MSG_ENABLE_LOCATION_UPDATES); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | boolean isDoingNightMode() { |
| 364 | return mCarModeEnabled || mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 365 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 366 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 367 | void setCarModeLocked(boolean enabled) { |
| 368 | if (mCarModeEnabled != enabled) { |
| 369 | mCarModeEnabled = enabled; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | |
| 373 | void updateDockState(int newState) { |
| 374 | synchronized (mLock) { |
| 375 | if (newState != mDockState) { |
| 376 | mDockState = newState; |
Mike Lockwood | 924e164 | 2010-03-05 11:56:53 -0500 | [diff] [blame] | 377 | setCarModeLocked(mDockState == Intent.EXTRA_DOCK_STATE_CAR); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 378 | if (mSystemReady) { |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 379 | updateLocked(0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 380 | } |
| 381 | } |
| 382 | } |
| 383 | } |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 384 | |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 385 | final void updateConfigurationLocked(boolean sendIt) { |
Daniel Sandler | 8daf2a4 | 2010-04-02 10:15:09 -0400 | [diff] [blame^] | 386 | int uiMode = Configuration.UI_MODE_TYPE_NORMAL; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 387 | if (mCarModeEnabled) { |
| 388 | uiMode = Configuration.UI_MODE_TYPE_CAR; |
| 389 | } else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) { |
| 390 | uiMode = Configuration.UI_MODE_TYPE_DESK; |
| 391 | } |
Dianne Hackborn | 9c9c532 | 2010-03-30 23:12:22 -0700 | [diff] [blame] | 392 | if (mCarModeEnabled) { |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 393 | if (mNightMode == UiModeManager.MODE_NIGHT_AUTO) { |
| 394 | updateTwilightLocked(); |
| 395 | uiMode |= mComputedNightMode ? Configuration.UI_MODE_NIGHT_YES |
| 396 | : Configuration.UI_MODE_NIGHT_NO; |
| 397 | } else { |
| 398 | uiMode |= mNightMode << 4; |
| 399 | } |
| 400 | } else { |
| 401 | // Disabling the car mode clears the night mode. |
Daniel Sandler | 8daf2a4 | 2010-04-02 10:15:09 -0400 | [diff] [blame^] | 402 | uiMode = (uiMode & ~Configuration.UI_MODE_NIGHT_MASK) | Configuration.UI_MODE_NIGHT_NO; |
| 403 | } |
| 404 | |
| 405 | if (LOG) { |
| 406 | Slog.d(TAG, |
| 407 | "updateConfigurationLocked: mDockState=" + mDockState |
| 408 | + "; mCarMode=" + mCarModeEnabled |
| 409 | + "; mNightMode=" + mNightMode |
| 410 | + "; uiMode=" + uiMode); |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 411 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 412 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 413 | mCurUiMode = uiMode; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 414 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 415 | if (!mHoldingConfiguration && uiMode != mSetUiMode) { |
| 416 | mSetUiMode = uiMode; |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 417 | mConfiguration.uiMode = uiMode; |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 418 | |
Dianne Hackborn | 2ccda4d | 2010-03-22 21:49:15 -0700 | [diff] [blame] | 419 | if (sendIt) { |
| 420 | try { |
| 421 | ActivityManagerNative.getDefault().updateConfiguration(mConfiguration); |
| 422 | } catch (RemoteException e) { |
| 423 | Slog.w(TAG, "Failure communicating with activity manager", e); |
| 424 | } |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 428 | |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 429 | final void updateLocked(int flags) { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 430 | long ident = Binder.clearCallingIdentity(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 431 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 432 | try { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 433 | String action = null; |
| 434 | String oldAction = null; |
| 435 | if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_CAR) { |
Tobias Haamel | 780b260 | 2010-03-15 12:54:45 +0100 | [diff] [blame] | 436 | adjustStatusBarCarModeLocked(); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 437 | oldAction = UiModeManager.ACTION_EXIT_CAR_MODE; |
| 438 | } else if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_DESK) { |
| 439 | oldAction = UiModeManager.ACTION_EXIT_DESK_MODE; |
| 440 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 441 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 442 | if (mCarModeEnabled) { |
| 443 | if (mLastBroadcastState != Intent.EXTRA_DOCK_STATE_CAR) { |
| 444 | adjustStatusBarCarModeLocked(); |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 445 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 446 | if (oldAction != null) { |
| 447 | mContext.sendBroadcast(new Intent(oldAction)); |
| 448 | } |
| 449 | mLastBroadcastState = Intent.EXTRA_DOCK_STATE_CAR; |
| 450 | action = UiModeManager.ACTION_ENTER_CAR_MODE; |
| 451 | } |
| 452 | } else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) { |
| 453 | if (mLastBroadcastState != Intent.EXTRA_DOCK_STATE_DESK) { |
| 454 | if (oldAction != null) { |
| 455 | mContext.sendBroadcast(new Intent(oldAction)); |
| 456 | } |
| 457 | mLastBroadcastState = Intent.EXTRA_DOCK_STATE_DESK; |
| 458 | action = UiModeManager.ACTION_ENTER_DESK_MODE; |
| 459 | } |
| 460 | } else { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 461 | mLastBroadcastState = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 462 | action = oldAction; |
| 463 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 464 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 465 | if (action != null) { |
| 466 | // Send the ordered broadcast; the result receiver will receive after all |
| 467 | // broadcasts have been sent. If any broadcast receiver changes the result |
| 468 | // code from the initial value of RESULT_OK, then the result receiver will |
| 469 | // not launch the corresponding dock application. This gives apps a chance |
| 470 | // to override the behavior and stay in their app even when the device is |
| 471 | // placed into a dock. |
| 472 | mContext.sendOrderedBroadcast(new Intent(action), null, |
| 473 | mResultReceiver, null, Activity.RESULT_OK, null, null); |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 474 | // Attempting to make this transition a little more clean, we are going |
| 475 | // to hold off on doing a configuration change until we have finished |
| 476 | // the broacast and started the home activity. |
| 477 | mHoldingConfiguration = true; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 478 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 479 | |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 480 | if (oldAction != null && (flags&UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { |
| 481 | // We are exiting the special mode, and have been asked to return |
| 482 | // to the main home screen while doing so. To keep this clean, we |
| 483 | // have the activity manager switch the configuration for us at the |
| 484 | // same time as the switch. |
| 485 | try { |
| 486 | Intent intent = new Intent(Intent.ACTION_MAIN); |
| 487 | intent.addCategory(Intent.CATEGORY_HOME); |
| 488 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Dianne Hackborn | e252246 | 2010-03-29 18:41:30 -0700 | [diff] [blame] | 489 | mHoldingConfiguration = false; |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 490 | updateConfigurationLocked(false); |
| 491 | ActivityManagerNative.getDefault().startActivityWithConfig( |
| 492 | null, intent, null, null, 0, null, null, 0, false, false, |
| 493 | mConfiguration); |
| 494 | } catch (RemoteException e) { |
| 495 | Slog.w(TAG, e.getCause()); |
| 496 | } |
| 497 | } else { |
| 498 | updateConfigurationLocked(true); |
| 499 | } |
Mike Lockwood | e29db6a | 2010-03-05 13:45:51 -0500 | [diff] [blame] | 500 | |
| 501 | // keep screen on when charging and in car mode |
| 502 | boolean keepScreenOn = mCharging && |
| 503 | ((mCarModeEnabled && mCarModeKeepsScreenOn) || |
| 504 | (mCurUiMode == Configuration.UI_MODE_TYPE_DESK && mDeskModeKeepsScreenOn)); |
| 505 | if (keepScreenOn != mWakeLock.isHeld()) { |
| 506 | if (keepScreenOn) { |
| 507 | mWakeLock.acquire(); |
| 508 | } else { |
| 509 | mWakeLock.release(); |
| 510 | } |
| 511 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 512 | } finally { |
| 513 | Binder.restoreCallingIdentity(ident); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | private void adjustStatusBarCarModeLocked() { |
| 518 | if (mStatusBarManager == null) { |
| 519 | mStatusBarManager = (StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE); |
| 520 | } |
| 521 | |
| 522 | // Fear not: StatusBarService manages a list of requests to disable |
| 523 | // features of the status bar; these are ORed together to form the |
| 524 | // active disabled list. So if (for example) the device is locked and |
| 525 | // the status bar should be totally disabled, the calls below will |
| 526 | // have no effect until the device is unlocked. |
| 527 | if (mStatusBarManager != null) { |
| 528 | mStatusBarManager.disable(mCarModeEnabled |
| 529 | ? StatusBarManager.DISABLE_NOTIFICATION_TICKER |
| 530 | : StatusBarManager.DISABLE_NONE); |
| 531 | } |
| 532 | |
| 533 | if (mNotificationManager == null) { |
| 534 | mNotificationManager = (NotificationManager) |
| 535 | mContext.getSystemService(Context.NOTIFICATION_SERVICE); |
| 536 | } |
| 537 | |
| 538 | if (mNotificationManager != null) { |
| 539 | if (mCarModeEnabled) { |
| 540 | Intent carModeOffIntent = new Intent(mContext, DisableCarModeActivity.class); |
| 541 | |
| 542 | Notification n = new Notification(); |
| 543 | n.icon = R.drawable.stat_notify_car_mode; |
| 544 | n.defaults = Notification.DEFAULT_LIGHTS; |
| 545 | n.flags = Notification.FLAG_ONGOING_EVENT; |
| 546 | n.when = 0; |
| 547 | n.setLatestEventInfo( |
| 548 | mContext, |
| 549 | mContext.getString(R.string.car_mode_disable_notification_title), |
| 550 | mContext.getString(R.string.car_mode_disable_notification_message), |
| 551 | PendingIntent.getActivity(mContext, 0, carModeOffIntent, 0)); |
| 552 | mNotificationManager.notify(0, n); |
| 553 | } else { |
| 554 | mNotificationManager.cancel(0); |
| 555 | } |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | private final Handler mHandler = new Handler() { |
| 560 | |
| 561 | boolean mPassiveListenerEnabled; |
| 562 | boolean mNetworkListenerEnabled; |
| 563 | |
| 564 | @Override |
| 565 | public void handleMessage(Message msg) { |
| 566 | switch (msg.what) { |
| 567 | case MSG_UPDATE_TWILIGHT: |
| 568 | synchronized (mLock) { |
| 569 | if (isDoingNightMode() && mLocation != null |
| 570 | && mNightMode == UiModeManager.MODE_NIGHT_AUTO) { |
| 571 | updateTwilightLocked(); |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 572 | updateLocked(0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 573 | } |
| 574 | } |
| 575 | break; |
| 576 | case MSG_ENABLE_LOCATION_UPDATES: |
| 577 | // enable network provider to receive at least location updates for a given |
| 578 | // distance. |
| 579 | boolean networkLocationEnabled; |
| 580 | try { |
| 581 | networkLocationEnabled = |
| 582 | mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); |
| 583 | } catch (Exception e) { |
| 584 | // we may get IllegalArgumentException if network location provider |
| 585 | // does not exist or is not yet installed. |
| 586 | networkLocationEnabled = false; |
| 587 | } |
| 588 | if (!mNetworkListenerEnabled && networkLocationEnabled) { |
| 589 | mNetworkListenerEnabled = true; |
| 590 | mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, |
| 591 | LOCATION_UPDATE_MS, 0, mEmptyLocationListener); |
| 592 | |
| 593 | if (mLocation == null) { |
| 594 | retrieveLocation(); |
| 595 | } |
| 596 | synchronized (mLock) { |
| 597 | if (isDoingNightMode() && mLocation != null |
| 598 | && mNightMode == UiModeManager.MODE_NIGHT_AUTO) { |
| 599 | updateTwilightLocked(); |
Dianne Hackborn | d49258f | 2010-03-26 00:44:29 -0700 | [diff] [blame] | 600 | updateLocked(0); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 601 | } |
| 602 | } |
| 603 | } |
| 604 | // enable passive provider to receive updates from location fixes (gps |
| 605 | // and network). |
| 606 | boolean passiveLocationEnabled; |
| 607 | try { |
| 608 | passiveLocationEnabled = |
| 609 | mLocationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER); |
| 610 | } catch (Exception e) { |
| 611 | // we may get IllegalArgumentException if passive location provider |
| 612 | // does not exist or is not yet installed. |
| 613 | passiveLocationEnabled = false; |
| 614 | } |
| 615 | if (!mPassiveListenerEnabled && passiveLocationEnabled) { |
| 616 | mPassiveListenerEnabled = true; |
| 617 | mLocationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, |
| 618 | 0, LOCATION_UPDATE_DISTANCE_METER , mLocationListener); |
| 619 | } |
| 620 | if (!(mNetworkListenerEnabled && mPassiveListenerEnabled)) { |
| 621 | long interval = msg.getData().getLong(KEY_LAST_UPDATE_INTERVAL); |
| 622 | interval *= 1.5; |
| 623 | if (interval == 0) { |
| 624 | interval = LOCATION_UPDATE_ENABLE_INTERVAL_MIN; |
| 625 | } else if (interval > LOCATION_UPDATE_ENABLE_INTERVAL_MAX) { |
| 626 | interval = LOCATION_UPDATE_ENABLE_INTERVAL_MAX; |
| 627 | } |
| 628 | Bundle bundle = new Bundle(); |
| 629 | bundle.putLong(KEY_LAST_UPDATE_INTERVAL, interval); |
| 630 | Message newMsg = mHandler.obtainMessage(MSG_ENABLE_LOCATION_UPDATES); |
| 631 | newMsg.setData(bundle); |
| 632 | mHandler.sendMessageDelayed(newMsg, interval); |
| 633 | } |
| 634 | break; |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | private void retrieveLocation() { |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 639 | Location location = null; |
| 640 | final Iterator<String> providers = |
| 641 | mLocationManager.getProviders(new Criteria(), true).iterator(); |
| 642 | while (providers.hasNext()) { |
| 643 | final Location lastKnownLocation = |
| 644 | mLocationManager.getLastKnownLocation(providers.next()); |
| 645 | // pick the most recent location |
| 646 | if (location == null || (lastKnownLocation != null && |
| 647 | location.getTime() < lastKnownLocation.getTime())) { |
| 648 | location = lastKnownLocation; |
| 649 | } |
| 650 | } |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 651 | // In the case there is no location available (e.g. GPS fix or network location |
| 652 | // is not available yet), the longitude of the location is estimated using the timezone, |
| 653 | // latitude and accuracy are set to get a good average. |
| 654 | if (location == null) { |
| 655 | Time currentTime = new Time(); |
| 656 | currentTime.set(System.currentTimeMillis()); |
| 657 | double lngOffset = FACTOR_GMT_OFFSET_LONGITUDE * |
| 658 | (currentTime.gmtoff - (currentTime.isDst > 0 ? 3600 : 0)); |
| 659 | location = new Location("fake"); |
| 660 | location.setLongitude(lngOffset); |
| 661 | location.setLatitude(0); |
| 662 | location.setAccuracy(417000.0f); |
| 663 | location.setTime(System.currentTimeMillis()); |
| 664 | } |
| 665 | synchronized (mLock) { |
| 666 | mLocation = location; |
| 667 | } |
| 668 | } |
| 669 | }; |
| 670 | |
| 671 | void updateTwilightLocked() { |
| 672 | if (mLocation == null) { |
| 673 | return; |
| 674 | } |
| 675 | final long currentTime = System.currentTimeMillis(); |
| 676 | boolean nightMode; |
| 677 | // calculate current twilight |
| 678 | TwilightCalculator tw = new TwilightCalculator(); |
| 679 | tw.calculateTwilight(currentTime, |
| 680 | mLocation.getLatitude(), mLocation.getLongitude()); |
| 681 | if (tw.mState == TwilightCalculator.DAY) { |
| 682 | nightMode = false; |
| 683 | } else { |
| 684 | nightMode = true; |
| 685 | } |
| 686 | |
| 687 | // schedule next update |
| 688 | long nextUpdate = 0; |
| 689 | if (tw.mSunrise == -1 || tw.mSunset == -1) { |
| 690 | // In the case the day or night never ends the update is scheduled 12 hours later. |
| 691 | nextUpdate = currentTime + 12 * DateUtils.HOUR_IN_MILLIS; |
| 692 | } else { |
| 693 | final int mLastTwilightState = tw.mState; |
| 694 | // add some extra time to be on the save side. |
| 695 | nextUpdate += DateUtils.MINUTE_IN_MILLIS; |
| 696 | if (currentTime > tw.mSunset) { |
| 697 | // next update should be on the following day |
| 698 | tw.calculateTwilight(currentTime |
| 699 | + DateUtils.DAY_IN_MILLIS, mLocation.getLatitude(), |
| 700 | mLocation.getLongitude()); |
| 701 | } |
| 702 | |
| 703 | if (mLastTwilightState == TwilightCalculator.NIGHT) { |
| 704 | nextUpdate += tw.mSunrise; |
| 705 | } else { |
| 706 | nextUpdate += tw.mSunset; |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | Intent updateIntent = new Intent(ACTION_UPDATE_NIGHT_MODE); |
| 711 | PendingIntent pendingIntent = |
| 712 | PendingIntent.getBroadcast(mContext, 0, updateIntent, 0); |
| 713 | mAlarmManager.cancel(pendingIntent); |
| 714 | mAlarmManager.set(AlarmManager.RTC_WAKEUP, nextUpdate, pendingIntent); |
| 715 | |
| 716 | mComputedNightMode = nightMode; |
| 717 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 718 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 719 | @Override |
| 720 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 721 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 722 | != PackageManager.PERMISSION_GRANTED) { |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 723 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 724 | pw.println("Permission Denial: can't dump uimode service from from pid=" |
| 725 | + Binder.getCallingPid() |
| 726 | + ", uid=" + Binder.getCallingUid()); |
| 727 | return; |
| 728 | } |
Bernd Holzhey | ba9ab18 | 2010-03-12 09:30:29 +0100 | [diff] [blame] | 729 | |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 730 | synchronized (mLock) { |
| 731 | pw.println("Current UI Mode Service state:"); |
| 732 | pw.print(" mDockState="); pw.print(mDockState); |
| 733 | pw.print(" mLastBroadcastState="); pw.println(mLastBroadcastState); |
| 734 | pw.print(" mNightMode="); pw.print(mNightMode); |
| 735 | pw.print(" mCarModeEnabled="); pw.print(mCarModeEnabled); |
| 736 | pw.print(" mComputedNightMode="); pw.println(mComputedNightMode); |
| 737 | pw.print(" mCurUiMode=0x"); pw.print(Integer.toHexString(mCurUiMode)); |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 738 | pw.print(" mSetUiMode=0x"); pw.println(Integer.toHexString(mSetUiMode)); |
| 739 | pw.print(" mHoldingConfiguration="); pw.print(mHoldingConfiguration); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 740 | pw.print(" mSystemReady="); pw.println(mSystemReady); |
| 741 | if (mLocation != null) { |
| 742 | pw.print(" mLocation="); pw.println(mLocation); |
| 743 | } |
| 744 | } |
| 745 | } |
| 746 | } |