Loading services/core/java/com/android/server/attention/AttentionManagerService.java +17 −10 Original line number Diff line number Diff line Loading @@ -73,7 +73,6 @@ public class AttentionManagerService extends SystemService { private final Context mContext; private final PowerManager mPowerManager; private final ActivityManager mActivityManager; private final Object mLock; @GuardedBy("mLock") private final SparseArray<UserState> mUserStates = new SparseArray<>(); Loading @@ -85,7 +84,6 @@ public class AttentionManagerService extends SystemService { super(context); mContext = Preconditions.checkNotNull(context); mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); mLock = new Object(); mAttentionHandler = new AttentionHandler(); } Loading @@ -96,7 +94,7 @@ public class AttentionManagerService extends SystemService { } @Override public void onStopUser(int userId) { public void onSwitchUser(int userId) { cancelAndUnbindLocked(peekUserStateLocked(userId), AttentionService.ATTENTION_FAILURE_UNKNOWN); } Loading Loading @@ -201,13 +199,22 @@ public class AttentionManagerService extends SystemService { /** Cancels the specified attention check. */ public void cancelAttentionCheck(int requestCode) { synchronized (mLock) { final UserState userState = getOrCreateCurrentUserStateLocked(); if (userState.mService == null) { if (userState.mPendingAttentionCheck != null && userState.mPendingAttentionCheck.mRequestCode == requestCode) { userState.mPendingAttentionCheck = null; } return; } try { userState.mService.cancelAttentionCheck(requestCode); } catch (RemoteException e) { Slog.e(LOG_TAG, "Cannot call into the AttentionService"); } } } @GuardedBy("mLock") private void unbindAfterTimeoutLocked() { Loading @@ -224,7 +231,7 @@ public class AttentionManagerService extends SystemService { @GuardedBy("mLock") private UserState getOrCreateCurrentUserStateLocked() { return getOrCreateUserStateLocked(mActivityManager.getCurrentUser()); return getOrCreateUserStateLocked(ActivityManager.getCurrentUser()); } @GuardedBy("mLock") Loading @@ -239,7 +246,7 @@ public class AttentionManagerService extends SystemService { @GuardedBy("mLock") UserState peekCurrentUserStateLocked() { return peekUserStateLocked(mActivityManager.getCurrentUser()); return peekUserStateLocked(ActivityManager.getCurrentUser()); } @GuardedBy("mLock") Loading Loading
services/core/java/com/android/server/attention/AttentionManagerService.java +17 −10 Original line number Diff line number Diff line Loading @@ -73,7 +73,6 @@ public class AttentionManagerService extends SystemService { private final Context mContext; private final PowerManager mPowerManager; private final ActivityManager mActivityManager; private final Object mLock; @GuardedBy("mLock") private final SparseArray<UserState> mUserStates = new SparseArray<>(); Loading @@ -85,7 +84,6 @@ public class AttentionManagerService extends SystemService { super(context); mContext = Preconditions.checkNotNull(context); mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); mLock = new Object(); mAttentionHandler = new AttentionHandler(); } Loading @@ -96,7 +94,7 @@ public class AttentionManagerService extends SystemService { } @Override public void onStopUser(int userId) { public void onSwitchUser(int userId) { cancelAndUnbindLocked(peekUserStateLocked(userId), AttentionService.ATTENTION_FAILURE_UNKNOWN); } Loading Loading @@ -201,13 +199,22 @@ public class AttentionManagerService extends SystemService { /** Cancels the specified attention check. */ public void cancelAttentionCheck(int requestCode) { synchronized (mLock) { final UserState userState = getOrCreateCurrentUserStateLocked(); if (userState.mService == null) { if (userState.mPendingAttentionCheck != null && userState.mPendingAttentionCheck.mRequestCode == requestCode) { userState.mPendingAttentionCheck = null; } return; } try { userState.mService.cancelAttentionCheck(requestCode); } catch (RemoteException e) { Slog.e(LOG_TAG, "Cannot call into the AttentionService"); } } } @GuardedBy("mLock") private void unbindAfterTimeoutLocked() { Loading @@ -224,7 +231,7 @@ public class AttentionManagerService extends SystemService { @GuardedBy("mLock") private UserState getOrCreateCurrentUserStateLocked() { return getOrCreateUserStateLocked(mActivityManager.getCurrentUser()); return getOrCreateUserStateLocked(ActivityManager.getCurrentUser()); } @GuardedBy("mLock") Loading @@ -239,7 +246,7 @@ public class AttentionManagerService extends SystemService { @GuardedBy("mLock") UserState peekCurrentUserStateLocked() { return peekUserStateLocked(mActivityManager.getCurrentUser()); return peekUserStateLocked(ActivityManager.getCurrentUser()); } @GuardedBy("mLock") Loading