diff options
| author | 2020-02-04 18:36:41 +0000 | |
|---|---|---|
| committer | 2020-02-04 18:36:41 +0000 | |
| commit | 1374932dcf46c1b17787cb9e7ce42e9c4e46d449 (patch) | |
| tree | 5c23ff33a7f8ca5ca60b4403a375b9a4ba9e7642 | |
| parent | 177caa7a2b5661d75a8b59a218a6b6808335abee (diff) | |
| parent | 494b4ab56ffc60bb75ea3966bd3bf6e633a5cf7c (diff) | |
Merge "Correctly update in-progress events when switching uidStates"
| -rw-r--r-- | services/core/java/com/android/server/appop/AppOpsService.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 83f46f423c55..ee2d7fcd5d62 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -846,7 +846,12 @@ public class AppOpsService extends IAppOpsService.Stub { */ public void started(@NonNull IBinder clientId, @AppOpsManager.UidState int uidState) throws RemoteException { - if (!parent.isRunning()) { + started(clientId, uidState, true); + } + + private void started(@NonNull IBinder clientId, @AppOpsManager.UidState int uidState, + boolean triggerCallbackIfNeeded) throws RemoteException { + if (triggerCallbackIfNeeded && !parent.isRunning()) { scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid, parent.packageName, true); } @@ -965,8 +970,16 @@ public class AppOpsService extends IAppOpsService.Stub { if (event.getUidState() != newState) { try { + // Remove all but one unfinished start count and then call finished() to + // remove start event object + int numPreviousUnfinishedStarts = event.numUnfinishedStarts; + event.numUnfinishedStarts = 1; finished(event.getClientId(), false); - started(event.getClientId(), newState); + + // Call started() to add a new start event object and then add the + // previously removed unfinished start counts back + started(event.getClientId(), newState, false); + event.numUnfinishedStarts += numPreviousUnfinishedStarts - 1; } catch (RemoteException e) { if (DEBUG) Slog.e(TAG, "Cannot switch to new uidState " + newState); } |