PageRenderTime 60ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/services/java/jd-gui/com/android/server/UiModeManagerService.java

https://bitbucket.org/chaos_rom/miui_frameworks
Java | 1036 lines | 582 code | 29 blank | 425 comment | 112 complexity | 92b060c25ca06d8bf507681897aae325 MD5 | raw file
  1. package com.android.server;
  2. import android.annotation.MiuiHook;
  3. import android.annotation.MiuiHook.MiuiHookType;
  4. import android.app.ActivityManagerNative;
  5. import android.app.AlarmManager;
  6. import android.app.IActivityManager;
  7. import android.app.IUiModeManager.Stub;
  8. import android.app.Notification;
  9. import android.app.NotificationManager;
  10. import android.app.PendingIntent;
  11. import android.app.StatusBarManager;
  12. import android.app.UiModeManager;
  13. import android.content.ActivityNotFoundException;
  14. import android.content.BroadcastReceiver;
  15. import android.content.ContentResolver;
  16. import android.content.Context;
  17. import android.content.Intent;
  18. import android.content.IntentFilter;
  19. import android.content.pm.PackageManager;
  20. import android.content.res.Configuration;
  21. import android.content.res.Resources;
  22. import android.database.ContentObserver;
  23. import android.location.Criteria;
  24. import android.location.Location;
  25. import android.location.LocationListener;
  26. import android.location.LocationManager;
  27. import android.os.Binder;
  28. import android.os.Bundle;
  29. import android.os.Handler;
  30. import android.os.PowerManager;
  31. import android.os.PowerManager.WakeLock;
  32. import android.os.RemoteException;
  33. import android.os.ServiceManager;
  34. import android.provider.Settings.Secure;
  35. import android.provider.Settings.System;
  36. import android.text.format.Time;
  37. import android.util.Slog;
  38. import com.android.internal.app.DisableCarModeActivity;
  39. import java.io.FileDescriptor;
  40. import java.io.PrintWriter;
  41. import java.util.Iterator;
  42. import java.util.List;
  43. class UiModeManagerService extends IUiModeManager.Stub
  44. {
  45. private static final String ACTION_UPDATE_NIGHT_MODE = "com.android.server.action.UPDATE_NIGHT_MODE";
  46. private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true;
  47. private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = true;
  48. private static final double FACTOR_GMT_OFFSET_LONGITUDE = 0.004166666666666667D;
  49. private static final String KEY_LAST_UPDATE_INTERVAL = "LAST_UPDATE_INTERVAL";
  50. private static final float LOCATION_UPDATE_DISTANCE_METER = 20000.0F;
  51. private static final long LOCATION_UPDATE_ENABLE_INTERVAL_MAX = 900000L;
  52. private static final long LOCATION_UPDATE_ENABLE_INTERVAL_MIN = 5000L;
  53. private static final long LOCATION_UPDATE_MS = 86400000L;
  54. private static final boolean LOG = false;
  55. private static final long MIN_LOCATION_UPDATE_MS = 1800000L;
  56. private static final int MSG_ENABLE_LOCATION_UPDATES = 1;
  57. private static final int MSG_GET_NEW_LOCATION_UPDATE = 2;
  58. private static final int MSG_UPDATE_TWILIGHT;
  59. private static final String TAG = UiModeManager.class.getSimpleName();
  60. private AlarmManager mAlarmManager;
  61. private final BroadcastReceiver mBatteryReceiver;
  62. private boolean mCarModeEnabled;
  63. private final boolean mCarModeKeepsScreenOn;
  64. private boolean mCharging;
  65. private boolean mComputedNightMode;
  66. private Configuration mConfiguration;
  67. private final Context mContext;
  68. private int mCurUiMode;
  69. private final int mDefaultUiModeType;
  70. private final boolean mDeskModeKeepsScreenOn;
  71. private final BroadcastReceiver mDockModeReceiver;
  72. private int mDockState;
  73. private final LocationListener mEmptyLocationListener;
  74. private final Handler mHandler;
  75. private boolean mHoldingConfiguration;
  76. private int mLastBroadcastState;
  77. private Location mLocation;
  78. private final LocationListener mLocationListener;
  79. private LocationManager mLocationManager;
  80. final Object mLock;
  81. private int mNightMode;
  82. @MiuiHook(MiuiHook.MiuiHookType.NEW_FIELD)
  83. int mNormalType;
  84. private NotificationManager mNotificationManager;
  85. private final BroadcastReceiver mResultReceiver;
  86. private int mSetUiMode;
  87. private StatusBarManager mStatusBarManager;
  88. private boolean mSystemReady;
  89. private final boolean mTelevision;
  90. private final BroadcastReceiver mTwilightUpdateReceiver;
  91. private final BroadcastReceiver mUpdateLocationReceiver;
  92. private final PowerManager.WakeLock mWakeLock;
  93. @MiuiHook(MiuiHook.MiuiHookType.CHANGE_CODE)
  94. public UiModeManagerService(Context paramContext)
  95. {
  96. this.mNormalType = i;
  97. this.mLock = new Object();
  98. this.mDockState = 0;
  99. this.mLastBroadcastState = 0;
  100. this.mNightMode = i;
  101. this.mCarModeEnabled = false;
  102. this.mCharging = false;
  103. this.mCurUiMode = 0;
  104. this.mSetUiMode = 0;
  105. this.mHoldingConfiguration = false;
  106. this.mConfiguration = new Configuration();
  107. this.mResultReceiver = new BroadcastReceiver()
  108. {
  109. // ERROR //
  110. public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
  111. {
  112. // Byte code:
  113. // 0: aload_0
  114. // 1: invokevirtual 23 com/android/server/UiModeManagerService$1:getResultCode ()I
  115. // 4: bipush 255
  116. // 6: if_icmpeq +4 -> 10
  117. // 9: return
  118. // 10: aload_2
  119. // 11: ldc 25
  120. // 13: iconst_0
  121. // 14: invokevirtual 31 android/content/Intent:getIntExtra (Ljava/lang/String;I)I
  122. // 17: istore_3
  123. // 18: aload_2
  124. // 19: ldc 33
  125. // 21: iconst_0
  126. // 22: invokevirtual 31 android/content/Intent:getIntExtra (Ljava/lang/String;I)I
  127. // 25: istore 4
  128. // 27: aload_0
  129. // 28: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  130. // 31: getfield 37 com/android/server/UiModeManagerService:mLock Ljava/lang/Object;
  131. // 34: astore 5
  132. // 36: aload 5
  133. // 38: monitorenter
  134. // 39: aconst_null
  135. // 40: astore 6
  136. // 42: getstatic 43 android/app/UiModeManager:ACTION_ENTER_CAR_MODE Ljava/lang/String;
  137. // 45: aload_2
  138. // 46: invokevirtual 47 android/content/Intent:getAction ()Ljava/lang/String;
  139. // 49: invokevirtual 53 java/lang/String:equals (Ljava/lang/Object;)Z
  140. // 52: ifeq +138 -> 190
  141. // 55: iload_3
  142. // 56: iconst_1
  143. // 57: iand
  144. // 58: ifeq +7 -> 65
  145. // 61: ldc 55
  146. // 63: astore 6
  147. // 65: aload 6
  148. // 67: ifnull +82 -> 149
  149. // 70: aload 6
  150. // 72: invokestatic 59 com/android/server/UiModeManagerService:buildHomeIntent (Ljava/lang/String;)Landroid/content/Intent;
  151. // 75: astore 9
  152. // 77: aconst_null
  153. // 78: astore 10
  154. // 80: aload_0
  155. // 81: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  156. // 84: invokestatic 63 com/android/server/UiModeManagerService:access$000 (Lcom/android/server/UiModeManagerService;)Z
  157. // 87: ifeq +33 -> 120
  158. // 90: aload_0
  159. // 91: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  160. // 94: iconst_0
  161. // 95: invokestatic 67 com/android/server/UiModeManagerService:access$002 (Lcom/android/server/UiModeManagerService;Z)Z
  162. // 98: pop
  163. // 99: aload_0
  164. // 100: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  165. // 103: iconst_0
  166. // 104: invokevirtual 71 com/android/server/UiModeManagerService:updateConfigurationLocked (Z)V
  167. // 107: aload_0
  168. // 108: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  169. // 111: invokestatic 75 com/android/server/UiModeManagerService:access$100 (Lcom/android/server/UiModeManagerService;)Landroid/content/res/Configuration;
  170. // 114: astore 16
  171. // 116: aload 16
  172. // 118: astore 10
  173. // 120: invokestatic 81 android/app/ActivityManagerNative:getDefault ()Landroid/app/IActivityManager;
  174. // 123: aconst_null
  175. // 124: aload 9
  176. // 126: aconst_null
  177. // 127: aconst_null
  178. // 128: aconst_null
  179. // 129: iconst_0
  180. // 130: iconst_0
  181. // 131: aload 10
  182. // 133: aconst_null
  183. // 134: invokeinterface 87 10 0
  184. // 139: pop
  185. // 140: aload_0
  186. // 141: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  187. // 144: iconst_0
  188. // 145: invokestatic 67 com/android/server/UiModeManagerService:access$002 (Lcom/android/server/UiModeManagerService;Z)Z
  189. // 148: pop
  190. // 149: aload_0
  191. // 150: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  192. // 153: invokestatic 63 com/android/server/UiModeManagerService:access$000 (Lcom/android/server/UiModeManagerService;)Z
  193. // 156: ifeq +20 -> 176
  194. // 159: aload_0
  195. // 160: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  196. // 163: iconst_0
  197. // 164: invokestatic 67 com/android/server/UiModeManagerService:access$002 (Lcom/android/server/UiModeManagerService;Z)Z
  198. // 167: pop
  199. // 168: aload_0
  200. // 169: getfield 12 com/android/server/UiModeManagerService$1:this$0 Lcom/android/server/UiModeManagerService;
  201. // 172: iconst_1
  202. // 173: invokevirtual 71 com/android/server/UiModeManagerService:updateConfigurationLocked (Z)V
  203. // 176: aload 5
  204. // 178: monitorexit
  205. // 179: goto -170 -> 9
  206. // 182: astore 7
  207. // 184: aload 5
  208. // 186: monitorexit
  209. // 187: aload 7
  210. // 189: athrow
  211. // 190: getstatic 90 android/app/UiModeManager:ACTION_ENTER_DESK_MODE Ljava/lang/String;
  212. // 193: aload_2
  213. // 194: invokevirtual 47 android/content/Intent:getAction ()Ljava/lang/String;
  214. // 197: invokevirtual 53 java/lang/String:equals (Ljava/lang/Object;)Z
  215. // 200: ifeq +33 -> 233
  216. // 203: iload_3
  217. // 204: iconst_1
  218. // 205: iand
  219. // 206: ifeq -141 -> 65
  220. // 209: ldc 92
  221. // 211: astore 6
  222. // 213: goto -148 -> 65
  223. // 216: astore 11
  224. // 218: invokestatic 95 com/android/server/UiModeManagerService:access$200 ()Ljava/lang/String;
  225. // 221: aload 11
  226. // 223: invokevirtual 99 android/os/RemoteException:getCause ()Ljava/lang/Throwable;
  227. // 226: invokestatic 105 android/util/Slog:w (Ljava/lang/String;Ljava/lang/Throwable;)I
  228. // 229: pop
  229. // 230: goto -81 -> 149
  230. // 233: iload 4
  231. // 235: iconst_1
  232. // 236: iand
  233. // 237: ifeq -172 -> 65
  234. // 240: ldc 107
  235. // 242: astore 6
  236. // 244: goto -179 -> 65
  237. //
  238. // Exception table:
  239. // from to target type
  240. // 42 116 182 finally
  241. // 120 149 182 finally
  242. // 149 187 182 finally
  243. // 190 230 182 finally
  244. // 120 149 216 android/os/RemoteException
  245. }
  246. };
  247. this.mTwilightUpdateReceiver = new BroadcastReceiver()
  248. {
  249. public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
  250. {
  251. if ((UiModeManagerService.this.isDoingNightMode()) && (UiModeManagerService.this.mNightMode == 0))
  252. UiModeManagerService.this.mHandler.sendEmptyMessage(0);
  253. }
  254. };
  255. this.mDockModeReceiver = new BroadcastReceiver()
  256. {
  257. public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
  258. {
  259. int i = paramAnonymousIntent.getIntExtra("android.intent.extra.DOCK_STATE", 0);
  260. UiModeManagerService.this.updateDockState(i);
  261. }
  262. };
  263. this.mBatteryReceiver = new BroadcastReceiver()
  264. {
  265. public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
  266. {
  267. boolean bool = false;
  268. UiModeManagerService localUiModeManagerService = UiModeManagerService.this;
  269. if (paramAnonymousIntent.getIntExtra("plugged", 0) != 0)
  270. bool = true;
  271. UiModeManagerService.access$502(localUiModeManagerService, bool);
  272. synchronized (UiModeManagerService.this.mLock)
  273. {
  274. if (UiModeManagerService.this.mSystemReady)
  275. UiModeManagerService.this.updateLocked(0, 0);
  276. return;
  277. }
  278. }
  279. };
  280. this.mUpdateLocationReceiver = new BroadcastReceiver()
  281. {
  282. public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
  283. {
  284. if ("android.intent.action.AIRPLANE_MODE".equals(paramAnonymousIntent.getAction()))
  285. if (!paramAnonymousIntent.getBooleanExtra("state", false))
  286. UiModeManagerService.this.mHandler.sendEmptyMessage(2);
  287. while (true)
  288. {
  289. return;
  290. UiModeManagerService.this.mHandler.sendEmptyMessage(2);
  291. }
  292. }
  293. };
  294. this.mEmptyLocationListener = new LocationListener()
  295. {
  296. public void onLocationChanged(Location paramAnonymousLocation)
  297. {
  298. }
  299. public void onProviderDisabled(String paramAnonymousString)
  300. {
  301. }
  302. public void onProviderEnabled(String paramAnonymousString)
  303. {
  304. }
  305. public void onStatusChanged(String paramAnonymousString, int paramAnonymousInt, Bundle paramAnonymousBundle)
  306. {
  307. }
  308. };
  309. this.mLocationListener = new LocationListener()
  310. {
  311. private boolean hasMoved(Location paramAnonymousLocation)
  312. {
  313. boolean bool1 = true;
  314. boolean bool2 = false;
  315. if (paramAnonymousLocation == null);
  316. do
  317. while (true)
  318. {
  319. return bool2;
  320. if (UiModeManagerService.this.mLocation != null)
  321. break;
  322. bool2 = bool1;
  323. }
  324. while (paramAnonymousLocation.getTime() < UiModeManagerService.this.mLocation.getTime());
  325. if (UiModeManagerService.this.mLocation.distanceTo(paramAnonymousLocation) >= UiModeManagerService.this.mLocation.getAccuracy() + paramAnonymousLocation.getAccuracy());
  326. while (true)
  327. {
  328. bool2 = bool1;
  329. break;
  330. bool1 = false;
  331. }
  332. }
  333. public void onLocationChanged(Location paramAnonymousLocation)
  334. {
  335. int i = 0;
  336. boolean bool = hasMoved(paramAnonymousLocation);
  337. if ((UiModeManagerService.this.mLocation == null) || (paramAnonymousLocation.getAccuracy() < UiModeManagerService.this.mLocation.getAccuracy()))
  338. i = 1;
  339. if ((bool) || (i != 0))
  340. synchronized (UiModeManagerService.this.mLock)
  341. {
  342. UiModeManagerService.access$702(UiModeManagerService.this, paramAnonymousLocation);
  343. if ((bool) && (UiModeManagerService.this.isDoingNightMode()) && (UiModeManagerService.this.mNightMode == 0))
  344. UiModeManagerService.this.mHandler.sendEmptyMessage(0);
  345. }
  346. }
  347. public void onProviderDisabled(String paramAnonymousString)
  348. {
  349. }
  350. public void onProviderEnabled(String paramAnonymousString)
  351. {
  352. }
  353. public void onStatusChanged(String paramAnonymousString, int paramAnonymousInt, Bundle paramAnonymousBundle)
  354. {
  355. }
  356. };
  357. this.mHandler = new Handler()
  358. {
  359. boolean mDidFirstInit;
  360. long mLastNetworkRegisterTime = -1800000L;
  361. boolean mNetworkListenerEnabled;
  362. boolean mPassiveListenerEnabled;
  363. private void retrieveLocation()
  364. {
  365. Object localObject1 = null;
  366. Iterator localIterator = UiModeManagerService.this.mLocationManager.getProviders(new Criteria(), true).iterator();
  367. while (localIterator.hasNext())
  368. {
  369. Location localLocation = UiModeManagerService.this.mLocationManager.getLastKnownLocation((String)localIterator.next());
  370. if ((localObject1 == null) || ((localLocation != null) && (((Location)localObject1).getTime() < localLocation.getTime())))
  371. localObject1 = localLocation;
  372. }
  373. long l;
  374. if (localObject1 == null)
  375. {
  376. Time localTime = new Time();
  377. localTime.set(System.currentTimeMillis());
  378. l = localTime.gmtoff;
  379. if (localTime.isDst <= 0)
  380. break label201;
  381. }
  382. label201: for (int i = 3600; ; i = 0)
  383. {
  384. double d = 0.004166666666666667D * (l - i);
  385. localObject1 = new Location("fake");
  386. ((Location)localObject1).setLongitude(d);
  387. ((Location)localObject1).setLatitude(0.0D);
  388. ((Location)localObject1).setAccuracy(417000.0F);
  389. ((Location)localObject1).setTime(System.currentTimeMillis());
  390. synchronized (UiModeManagerService.this.mLock)
  391. {
  392. UiModeManagerService.access$702(UiModeManagerService.this, (Location)localObject1);
  393. return;
  394. }
  395. }
  396. }
  397. // ERROR //
  398. public void handleMessage(android.os.Message paramAnonymousMessage)
  399. {
  400. // Byte code:
  401. // 0: aload_1
  402. // 1: getfield 125 android/os/Message:what I
  403. // 4: tableswitch default:+28 -> 32, 0:+29->33, 1:+145->149, 2:+101->105
  404. // 33: aload_0
  405. // 34: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  406. // 37: getfield 112 com/android/server/UiModeManagerService:mLock Ljava/lang/Object;
  407. // 40: astore 15
  408. // 42: aload 15
  409. // 44: monitorenter
  410. // 45: aload_0
  411. // 46: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  412. // 49: invokevirtual 128 com/android/server/UiModeManagerService:isDoingNightMode ()Z
  413. // 52: ifeq +39 -> 91
  414. // 55: aload_0
  415. // 56: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  416. // 59: invokestatic 132 com/android/server/UiModeManagerService:access$700 (Lcom/android/server/UiModeManagerService;)Landroid/location/Location;
  417. // 62: ifnull +29 -> 91
  418. // 65: aload_0
  419. // 66: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  420. // 69: invokestatic 136 com/android/server/UiModeManagerService:access$300 (Lcom/android/server/UiModeManagerService;)I
  421. // 72: ifne +19 -> 91
  422. // 75: aload_0
  423. // 76: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  424. // 79: invokevirtual 139 com/android/server/UiModeManagerService:updateTwilightLocked ()V
  425. // 82: aload_0
  426. // 83: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  427. // 86: iconst_0
  428. // 87: iconst_0
  429. // 88: invokevirtual 143 com/android/server/UiModeManagerService:updateLocked (II)V
  430. // 91: aload 15
  431. // 93: monitorexit
  432. // 94: goto -62 -> 32
  433. // 97: astore 16
  434. // 99: aload 15
  435. // 101: monitorexit
  436. // 102: aload 16
  437. // 104: athrow
  438. // 105: aload_0
  439. // 106: getfield 145 com/android/server/UiModeManagerService$8:mNetworkListenerEnabled Z
  440. // 109: ifeq -77 -> 32
  441. // 112: ldc2_w 146
  442. // 115: aload_0
  443. // 116: getfield 25 com/android/server/UiModeManagerService$8:mLastNetworkRegisterTime J
  444. // 119: ladd
  445. // 120: invokestatic 152 android/os/SystemClock:elapsedRealtime ()J
  446. // 123: lcmp
  447. // 124: ifge -92 -> 32
  448. // 127: aload_0
  449. // 128: iconst_0
  450. // 129: putfield 145 com/android/server/UiModeManagerService$8:mNetworkListenerEnabled Z
  451. // 132: aload_0
  452. // 133: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  453. // 136: invokestatic 30 com/android/server/UiModeManagerService:access$900 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationManager;
  454. // 139: aload_0
  455. // 140: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  456. // 143: invokestatic 156 com/android/server/UiModeManagerService:access$800 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationListener;
  457. // 146: invokevirtual 160 android/location/LocationManager:removeUpdates (Landroid/location/LocationListener;)V
  458. // 149: aload_0
  459. // 150: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  460. // 153: invokestatic 30 com/android/server/UiModeManagerService:access$900 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationManager;
  461. // 156: ldc 162
  462. // 158: invokevirtual 166 android/location/LocationManager:isProviderEnabled (Ljava/lang/String;)Z
  463. // 161: istore 14
  464. // 163: iload 14
  465. // 165: istore_3
  466. // 166: aload_0
  467. // 167: getfield 145 com/android/server/UiModeManagerService$8:mNetworkListenerEnabled Z
  468. // 170: ifne +129 -> 299
  469. // 173: iload_3
  470. // 174: ifeq +125 -> 299
  471. // 177: aload_0
  472. // 178: iconst_1
  473. // 179: putfield 145 com/android/server/UiModeManagerService$8:mNetworkListenerEnabled Z
  474. // 182: aload_0
  475. // 183: invokestatic 152 android/os/SystemClock:elapsedRealtime ()J
  476. // 186: putfield 25 com/android/server/UiModeManagerService$8:mLastNetworkRegisterTime J
  477. // 189: aload_0
  478. // 190: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  479. // 193: invokestatic 30 com/android/server/UiModeManagerService:access$900 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationManager;
  480. // 196: ldc 162
  481. // 198: ldc2_w 167
  482. // 201: fconst_0
  483. // 202: aload_0
  484. // 203: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  485. // 206: invokestatic 156 com/android/server/UiModeManagerService:access$800 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationListener;
  486. // 209: invokevirtual 172 android/location/LocationManager:requestLocationUpdates (Ljava/lang/String;JFLandroid/location/LocationListener;)V
  487. // 212: aload_0
  488. // 213: getfield 174 com/android/server/UiModeManagerService$8:mDidFirstInit Z
  489. // 216: ifne +83 -> 299
  490. // 219: aload_0
  491. // 220: iconst_1
  492. // 221: putfield 174 com/android/server/UiModeManagerService$8:mDidFirstInit Z
  493. // 224: aload_0
  494. // 225: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  495. // 228: invokestatic 132 com/android/server/UiModeManagerService:access$700 (Lcom/android/server/UiModeManagerService;)Landroid/location/Location;
  496. // 231: ifnonnull +7 -> 238
  497. // 234: aload_0
  498. // 235: invokespecial 176 com/android/server/UiModeManagerService$8:retrieveLocation ()V
  499. // 238: aload_0
  500. // 239: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  501. // 242: getfield 112 com/android/server/UiModeManagerService:mLock Ljava/lang/Object;
  502. // 245: astore 12
  503. // 247: aload 12
  504. // 249: monitorenter
  505. // 250: aload_0
  506. // 251: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  507. // 254: invokevirtual 128 com/android/server/UiModeManagerService:isDoingNightMode ()Z
  508. // 257: ifeq +39 -> 296
  509. // 260: aload_0
  510. // 261: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  511. // 264: invokestatic 132 com/android/server/UiModeManagerService:access$700 (Lcom/android/server/UiModeManagerService;)Landroid/location/Location;
  512. // 267: ifnull +29 -> 296
  513. // 270: aload_0
  514. // 271: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  515. // 274: invokestatic 136 com/android/server/UiModeManagerService:access$300 (Lcom/android/server/UiModeManagerService;)I
  516. // 277: ifne +19 -> 296
  517. // 280: aload_0
  518. // 281: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  519. // 284: invokevirtual 139 com/android/server/UiModeManagerService:updateTwilightLocked ()V
  520. // 287: aload_0
  521. // 288: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  522. // 291: iconst_0
  523. // 292: iconst_0
  524. // 293: invokevirtual 143 com/android/server/UiModeManagerService:updateLocked (II)V
  525. // 296: aload 12
  526. // 298: monitorexit
  527. // 299: aload_0
  528. // 300: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  529. // 303: invokestatic 30 com/android/server/UiModeManagerService:access$900 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationManager;
  530. // 306: ldc 178
  531. // 308: invokevirtual 166 android/location/LocationManager:isProviderEnabled (Ljava/lang/String;)Z
  532. // 311: istore 11
  533. // 313: iload 11
  534. // 315: istore 5
  535. // 317: aload_0
  536. // 318: getfield 180 com/android/server/UiModeManagerService$8:mPassiveListenerEnabled Z
  537. // 321: ifne +35 -> 356
  538. // 324: iload 5
  539. // 326: ifeq +30 -> 356
  540. // 329: aload_0
  541. // 330: iconst_1
  542. // 331: putfield 180 com/android/server/UiModeManagerService$8:mPassiveListenerEnabled Z
  543. // 334: aload_0
  544. // 335: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  545. // 338: invokestatic 30 com/android/server/UiModeManagerService:access$900 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationManager;
  546. // 341: ldc 178
  547. // 343: lconst_0
  548. // 344: ldc 181
  549. // 346: aload_0
  550. // 347: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  551. // 350: invokestatic 184 com/android/server/UiModeManagerService:access$1000 (Lcom/android/server/UiModeManagerService;)Landroid/location/LocationListener;
  552. // 353: invokevirtual 172 android/location/LocationManager:requestLocationUpdates (Ljava/lang/String;JFLandroid/location/LocationListener;)V
  553. // 356: aload_0
  554. // 357: getfield 145 com/android/server/UiModeManagerService$8:mNetworkListenerEnabled Z
  555. // 360: ifeq +10 -> 370
  556. // 363: aload_0
  557. // 364: getfield 180 com/android/server/UiModeManagerService$8:mPassiveListenerEnabled Z
  558. // 367: ifne -335 -> 32
  559. // 370: ldc2_w 185
  560. // 373: aload_1
  561. // 374: invokevirtual 190 android/os/Message:getData ()Landroid/os/Bundle;
  562. // 377: ldc 192
  563. // 379: invokevirtual 198 android/os/Bundle:getLong (Ljava/lang/String;)J
  564. // 382: l2d
  565. // 383: dmul
  566. // 384: d2l
  567. // 385: lstore 6
  568. // 387: lload 6
  569. // 389: lconst_0
  570. // 390: lcmp
  571. // 391: ifne +86 -> 477
  572. // 394: ldc2_w 199
  573. // 397: lstore 6
  574. // 399: new 194 android/os/Bundle
  575. // 402: dup
  576. // 403: invokespecial 201 android/os/Bundle:<init> ()V
  577. // 406: astore 8
  578. // 408: aload 8
  579. // 410: ldc 192
  580. // 412: lload 6
  581. // 414: invokevirtual 205 android/os/Bundle:putLong (Ljava/lang/String;J)V
  582. // 417: aload_0
  583. // 418: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  584. // 421: invokestatic 209 com/android/server/UiModeManagerService:access$400 (Lcom/android/server/UiModeManagerService;)Landroid/os/Handler;
  585. // 424: iconst_1
  586. // 425: invokevirtual 213 android/os/Handler:obtainMessage (I)Landroid/os/Message;
  587. // 428: astore 9
  588. // 430: aload 9
  589. // 432: aload 8
  590. // 434: invokevirtual 217 android/os/Message:setData (Landroid/os/Bundle;)V
  591. // 437: aload_0
  592. // 438: getfield 18 com/android/server/UiModeManagerService$8:this$0 Lcom/android/server/UiModeManagerService;
  593. // 441: invokestatic 209 com/android/server/UiModeManagerService:access$400 (Lcom/android/server/UiModeManagerService;)Landroid/os/Handler;
  594. // 444: aload 9
  595. // 446: lload 6
  596. // 448: invokevirtual 221 android/os/Handler:sendMessageDelayed (Landroid/os/Message;J)Z
  597. // 451: pop
  598. // 452: goto -420 -> 32
  599. // 455: astore_2
  600. // 456: iconst_0
  601. // 457: istore_3
  602. // 458: goto -292 -> 166
  603. // 461: astore 13
  604. // 463: aload 12
  605. // 465: monitorexit
  606. // 466: aload 13
  607. // 468: athrow
  608. // 469: astore 4
  609. // 471: iconst_0
  610. // 472: istore 5
  611. // 474: goto -157 -> 317
  612. // 477: lload 6
  613. // 479: ldc2_w 222
  614. // 482: lcmp
  615. // 483: ifle -84 -> 399
  616. // 486: ldc2_w 222
  617. // 489: lstore 6
  618. // 491: goto -92 -> 399
  619. //
  620. // Exception table:
  621. // from to target type
  622. // 45 102 97 finally
  623. // 149 163 455 java/lang/Exception
  624. // 250 299 461 finally
  625. // 463 466 461 finally
  626. // 299 313 469 java/lang/Exception
  627. }
  628. };
  629. this.mContext = paramContext;
  630. ServiceManager.addService("uimode", this);
  631. this.mAlarmManager = ((AlarmManager)this.mContext.getSystemService("alarm"));
  632. this.mLocationManager = ((LocationManager)this.mContext.getSystemService("location"));
  633. this.mContext.registerReceiver(this.mTwilightUpdateReceiver, new IntentFilter("com.android.server.action.UPDATE_NIGHT_MODE"));
  634. this.mContext.registerReceiver(this.mDockModeReceiver, new IntentFilter("android.intent.action.DOCK_EVENT"));
  635. this.mContext.registerReceiver(this.mBatteryReceiver, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
  636. IntentFilter localIntentFilter = new IntentFilter("android.intent.action.AIRPLANE_MODE");
  637. localIntentFilter.addAction("android.intent.action.TIMEZONE_CHANGED");
  638. this.mContext.registerReceiver(this.mUpdateLocationReceiver, localIntentFilter);
  639. Injector.registerUIModeScaleChangedOjbserver(this, this.mContext);
  640. this.mWakeLock = ((PowerManager)paramContext.getSystemService("power")).newWakeLock(26, TAG);
  641. this.mConfiguration.setToDefaults();
  642. this.mDefaultUiModeType = paramContext.getResources().getInteger(17694737);
  643. int j;
  644. if (paramContext.getResources().getInteger(17694739) == i)
  645. {
  646. j = i;
  647. this.mCarModeKeepsScreenOn = j;
  648. if (paramContext.getResources().getInteger(17694738) != i)
  649. break label437;
  650. }
  651. while (true)
  652. {
  653. this.mDeskModeKeepsScreenOn = i;
  654. this.mTelevision = paramContext.getPackageManager().hasSystemFeature("android.hardware.type.television");
  655. this.mNightMode = Settings.Secure.getInt(this.mContext.getContentResolver(), "ui_night_mode", 0);
  656. return;
  657. j = 0;
  658. break;
  659. label437: i = 0;
  660. }
  661. }
  662. private void adjustStatusBarCarModeLocked()
  663. {
  664. if (this.mStatusBarManager == null)
  665. this.mStatusBarManager = ((StatusBarManager)this.mContext.getSystemService("statusbar"));
  666. int i;
  667. if (this.mStatusBarManager != null)
  668. {
  669. StatusBarManager localStatusBarManager = this.mStatusBarManager;
  670. if (this.mCarModeEnabled)
  671. {
  672. i = 524288;
  673. localStatusBarManager.disable(i);
  674. }
  675. }
  676. else
  677. {
  678. if (this.mNotificationManager == null)
  679. this.mNotificationManager = ((NotificationManager)this.mContext.getSystemService("notification"));
  680. if (this.mNotificationManager != null)
  681. {
  682. if (!this.mCarModeEnabled)
  683. break label191;
  684. Intent localIntent = new Intent(this.mContext, DisableCarModeActivity.class);
  685. Notification localNotification = new Notification();
  686. localNotification.icon = 17302799;
  687. localNotification.defaults = 4;
  688. localNotification.flags = 2;
  689. localNotification.when = 0L;
  690. localNotification.setLatestEventInfo(this.mContext, this.mContext.getString(17040515), this.mContext.getString(17040516), PendingIntent.getActivity(this.mContext, 0, localIntent, 0));
  691. this.mNotificationManager.notify(0, localNotification);
  692. }
  693. }
  694. while (true)
  695. {
  696. return;
  697. i = 0;
  698. break;
  699. label191: this.mNotificationManager.cancel(0);
  700. }
  701. }
  702. static Intent buildHomeIntent(String paramString)
  703. {
  704. Intent localIntent = new Intent("android.intent.action.MAIN");
  705. localIntent.addCategory(paramString);
  706. localIntent.setFlags(270532608);
  707. return localIntent;
  708. }
  709. static final boolean isDeskDockState(int paramInt)
  710. {
  711. switch (paramInt)
  712. {
  713. case 2:
  714. default:
  715. case 1:
  716. case 3:
  717. case 4:
  718. }
  719. for (boolean bool = false; ; bool = true)
  720. return bool;
  721. }
  722. public void disableCarMode(int paramInt)
  723. {
  724. synchronized (this.mLock)
  725. {
  726. setCarModeLocked(false);
  727. if (this.mSystemReady)
  728. updateLocked(0, paramInt);
  729. return;
  730. }
  731. }
  732. protected void dump(FileDescriptor paramFileDescriptor, PrintWriter paramPrintWriter, String[] paramArrayOfString)
  733. {
  734. if (this.mContext.checkCallingOrSelfPermission("android.permission.DUMP") != 0)
  735. paramPrintWriter.println("Permission Denial: can't dump uimode service from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
  736. while (true)
  737. {
  738. return;
  739. synchronized (this.mLock)
  740. {
  741. paramPrintWriter.println("Current UI Mode Service state:");
  742. paramPrintWriter.print(" mDockState=");
  743. paramPrintWriter.print(this.mDockState);
  744. paramPrintWriter.print(" mLastBroadcastState=");
  745. paramPrintWriter.println(this.mLastBroadcastState);
  746. paramPrintWriter.print(" mNightMode=");
  747. paramPrintWriter.print(this.mNightMode);
  748. paramPrintWriter.print(" mCarModeEnabled=");
  749. paramPrintWriter.print(this.mCarModeEnabled);
  750. paramPrintWriter.print(" mComputedNightMode=");
  751. paramPrintWriter.println(this.mComputedNightMode);
  752. paramPrintWriter.print(" mCurUiMode=0x");
  753. paramPrintWriter.print(Integer.toHexString(this.mCurUiMode));
  754. paramPrintWriter.print(" mSetUiMode=0x");
  755. paramPrintWriter.println(Integer.toHexString(this.mSetUiMode));
  756. paramPrintWriter.print(" mHoldingConfiguration=");
  757. paramPrintWriter.print(this.mHoldingConfiguration);
  758. paramPrintWriter.print(" mSystemReady=");
  759. paramPrintWriter.println(this.mSystemReady);
  760. if (this.mLocation != null)
  761. {
  762. paramPrintWriter.print(" mLocation=");
  763. paramPrintWriter.println(this.mLocation);
  764. }
  765. }
  766. }
  767. }
  768. public void enableCarMode(int paramInt)
  769. {
  770. synchronized (this.mLock)
  771. {
  772. setCarModeLocked(true);
  773. if (this.mSystemReady)
  774. updateLocked(paramInt, 0);
  775. return;
  776. }
  777. }
  778. public int getCurrentModeType()
  779. {
  780. synchronized (this.mLock)
  781. {
  782. int i = 0xF & this.mCurUiMode;
  783. return i;
  784. }
  785. }
  786. public int getNightMode()
  787. throws RemoteException
  788. {
  789. return this.mNightMode;
  790. }
  791. boolean isDoingNightMode()
  792. {
  793. if ((this.mCarModeEnabled) || (this.mDockState != 0));
  794. for (boolean bool = true; ; bool = false)
  795. return bool;
  796. }
  797. void setCarModeLocked(boolean paramBoolean)
  798. {
  799. if (this.mCarModeEnabled != paramBoolean)
  800. this.mCarModeEnabled = paramBoolean;
  801. }
  802. // ERROR //
  803. public void setNightMode(int paramInt)
  804. throws RemoteException
  805. {
  806. // Byte code:
  807. // 0: aload_0
  808. // 1: getfield 134 com/android/server/UiModeManagerService:mLock Ljava/lang/Object;
  809. // 4: astore_2
  810. // 5: aload_2
  811. // 6: monitorenter
  812. // 7: iload_1
  813. // 8: tableswitch default:+28 -> 36, 0:+61->69, 1:+61->69, 2:+61->69
  814. // 37: aconst_null
  815. // 38: <illegal opcode>
  816. // 39: dup
  817. // 40: new 415 java/lang/StringBuilder
  818. // 43: dup
  819. // 44: invokespecial 416 java/lang/StringBuilder:<init> ()V
  820. // 47: ldc_w 499
  821. // 50: invokevirtual 422 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
  822. // 53: iload_1
  823. // 54: invokevirtual 431 java/lang/StringBuilder:append (I)Ljava/lang/StringBuilder;
  824. // 57: invokevirtual 439 java/lang/StringBuilder:toString ()Ljava/lang/String;
  825. // 60: invokespecial 500 java/lang/IllegalArgumentException:<init> (Ljava/lang/String;)V
  826. // 63: athrow
  827. // 64: astore_3
  828. // 65: aload_2
  829. // 66: monitorexit
  830. // 67: aload_3
  831. // 68: athrow
  832. // 69: aload_0
  833. // 70: invokevirtual 502 com/android/server/UiModeManagerService:isDoingNightMode ()Z
  834. // 73: ifne +8 -> 81
  835. // 76: aload_2
  836. // 77: monitorexit
  837. // 78: goto +49 -> 127
  838. // 81: aload_0
  839. // 82: getfield 140 com/android/server/UiModeManagerService:mNightMode I
  840. // 85: iload_1
  841. // 86: if_icmpeq +39 -> 125
  842. // 89: invokestatic 506 android/os/Binder:clearCallingIdentity ()J
  843. // 92: lstore 4
  844. // 94: aload_0
  845. // 95: getfield 183 com/android/server/UiModeManagerService:mContext Landroid/content/Context;
  846. // 98: invokevirtual 283 android/content/Context:getContentResolver ()Landroid/content/ContentResolver;
  847. // 101: ldc_w 285
  848. // 104: iload_1
  849. // 105: invokestatic 510 android/provider/Settings$Secure:putInt (Landroid/content/ContentResolver;Ljava/lang/String;I)Z
  850. // 108: pop
  851. // 109: lload 4
  852. // 111: invokestatic 514 android/os/Binder:restoreCallingIdentity (J)V
  853. // 114: aload_0
  854. // 115: iload_1
  855. // 116: putfield 140 com/android/server/UiModeManagerService:mNightMode I
  856. // 119: aload_0
  857. // 120: iconst_0
  858. // 121: iconst_0
  859. // 122: invokevirtual 405 com/android/server/UiModeManagerService:updateLocked (II)V
  860. // 125: aload_2
  861. // 126: monitorexit
  862. // 127: return
  863. //
  864. // Exception table:
  865. // from to target type
  866. // 36 67 64 finally
  867. // 69 127 64 finally
  868. }
  869. void systemReady()
  870. {
  871. for (boolean bool = true; ; bool = false)
  872. synchronized (this.mLock)
  873. {
  874. this.mSystemReady = true;
  875. if (this.mDockState == 2)
  876. {
  877. this.mCarModeEnabled = bool;
  878. updateLocked(0, 0);
  879. this.mHandler.sendEmptyMessage(1);
  880. return;
  881. }
  882. }
  883. }
  884. @MiuiHook(MiuiHook.MiuiHookType.CHANGE_CODE)
  885. final void updateConfigurationLocked(boolean paramBoolean)
  886. {
  887. int i;
  888. if (this.mTelevision)
  889. i = 4;
  890. while (true)
  891. {
  892. label18: int k;
  893. label47: int j;
  894. if (this.mCarModeEnabled)
  895. {
  896. i = 3;
  897. if (!this.mCarModeEnabled)
  898. break label144;
  899. if (this.mNightMode != 0)
  900. break label132;
  901. updateTwilightLocked();
  902. if (!this.mComputedNightMode)
  903. break label125;
  904. k = 32;
  905. j = i | k;
  906. label52: this.mCurUiMode = j;
  907. if ((!this.mHoldingConfiguration) && (j != this.mSetUiMode))
  908. {
  909. this.mSetUiMode = j;
  910. this.mConfiguration.uiMode = j;
  911. if (!paramBoolean);
  912. }
  913. }
  914. try
  915. {
  916. ActivityManagerNative.getDefault().updateConfiguration(this.mConfiguration);
  917. return;
  918. i = this.mNormalType;
  919. continue;
  920. if (!isDeskDockState(this.mDockState))
  921. break label18;
  922. i = 2;
  923. break label18;
  924. label125: k = 16;
  925. break label47;
  926. label132: j = i | this.mNightMode << 4;
  927. break label52;
  928. label144: j = 0x10 | i & 0xFFFFFFCF;
  929. }
  930. catch (RemoteException localRemoteException)
  931. {
  932. while (true)
  933. Slog.w(TAG, "Failure communicating with activity manager", localRemoteException);
  934. }
  935. }
  936. }
  937. void updateDockState(int paramInt)
  938. {
  939. for (boolean bool = true; ; bool = false)
  940. synchronized (this.mLock)
  941. {
  942. if (paramInt != this.mDockState)
  943. {
  944. this.mDockState = paramInt;
  945. if (this.mDockState != 2)
  946. continue;
  947. setCarModeLocked(bool);
  948. if (this.mSystemReady)
  949. updateLocked(1, 0);
  950. }
  951. return;
  952. }
  953. }
  954. final void updateLocked(int paramInt1, int paramInt2)
  955. {
  956. long l = Binder.clearCallingIdentity();
  957. Object localObject1 = null;
  958. String str = null;
  959. while (true)
  960. {
  961. try
  962. {
  963. if (this.mLastBroadcastState == 2)
  964. {
  965. adjustStatusBarCarModeLocked();
  966. str = UiModeManager.ACTION_EXIT_CAR_MODE;
  967. if (this.mCarModeEnabled)
  968. {
  969. if (this.mLastBroadcastState != 2)
  970. {
  971. adjustStatusBarCarModeLocked();
  972. if (str != null)
  973. this.mContext.sendBroadcast(new Intent(str));
  974. this.mLastBroadcastState = 2;
  975. localObject1 = UiModeManager.ACTION_ENTER_CAR_MODE;
  976. }
  977. if (localObject1 == null)
  978. continue;
  979. Intent localIntent1 = new Intent((String)localObject1);
  980. localIntent1.putExtra("enableFlags", paramInt1);
  981. localIntent1.putExtra("disableFlags", paramInt2);
  982. this.mContext.sendOrderedBroadcast(localIntent1, null, this.mResultReceiver, null, -1, null, null);
  983. this.mHoldingConfiguration = true;
  984. updateConfigurationLocked(true);
  985. if (!this.mCharging)
  986. break label416;
  987. if ((this.mCarModeEnabled) && (this.mCarModeKeepsScreenOn))
  988. break label410;
  989. if ((this.mCurUiMode != 2) || (!this.mDeskModeKeepsScreenOn))
  990. break label416;
  991. break label410;
  992. if (i != this.mWakeLock.isHeld())
  993. {
  994. if (i == 0)
  995. continue;
  996. this.mWakeLock.acquire();
  997. }
  998. }
  999. }
  1000. else
  1001. {
  1002. if (!isDeskDockState(this.mLastBroadcastState))
  1003. continue;
  1004. str = UiModeManager.ACTION_EXIT_DESK_MODE;
  1005. continue;
  1006. }
  1007. if (isDeskDockState(this.mDockState))