Loading services/core/java/com/android/server/appop/AppOpsService.java +22 −15 Original line number Original line Diff line number Diff line Loading @@ -1029,7 +1029,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (isStarted && mInProgressEvents == null) { if (isStarted && mInProgressEvents == null) { mInProgressEvents = new ArrayMap<>(1); mInProgressEvents = new ArrayMap<>(1); } else if (mPausedInProgressEvents == null) { } else if (!isStarted && mPausedInProgressEvents == null) { mPausedInProgressEvents = new ArrayMap<>(1); mPausedInProgressEvents = new ArrayMap<>(1); } } ArrayMap<IBinder, InProgressStartOpEvent> events = isStarted ArrayMap<IBinder, InProgressStartOpEvent> events = isStarted Loading Loading @@ -1231,11 +1231,13 @@ public class AppOpsService extends IAppOpsService.Stub { */ */ void onClientDeath(@NonNull IBinder clientId) { void onClientDeath(@NonNull IBinder clientId) { synchronized (AppOpsService.this) { synchronized (AppOpsService.this) { if (mInProgressEvents == null) { if (mInProgressEvents == null && mPausedInProgressEvents == null) { return; return; } } InProgressStartOpEvent deadEvent = mInProgressEvents.get(clientId); ArrayMap<IBinder, InProgressStartOpEvent> events = isPaused() ? mPausedInProgressEvents : mInProgressEvents; InProgressStartOpEvent deadEvent = events.get(clientId); if (deadEvent != null) { if (deadEvent != null) { deadEvent.numUnfinishedStarts = 1; deadEvent.numUnfinishedStarts = 1; } } Loading @@ -1250,14 +1252,18 @@ public class AppOpsService extends IAppOpsService.Stub { * @param newState The new state * @param newState The new state */ */ public void onUidStateChanged(@AppOpsManager.UidState int newState) { public void onUidStateChanged(@AppOpsManager.UidState int newState) { if (mInProgressEvents == null) { if (mInProgressEvents == null && mPausedInProgressEvents == null) { return; return; } } int numInProgressEvents = mInProgressEvents.size(); boolean isRunning = isRunning(); List<IBinder> binders = new ArrayList<>(mInProgressEvents.keySet()); ArrayMap<IBinder, AppOpsService.InProgressStartOpEvent> events = isRunning ? mInProgressEvents : mPausedInProgressEvents; int numInProgressEvents = events.size(); List<IBinder> binders = new ArrayList<>(events.keySet()); for (int i = 0; i < numInProgressEvents; i++) { for (int i = 0; i < numInProgressEvents; i++) { InProgressStartOpEvent event = mInProgressEvents.get(binders.get(i)); InProgressStartOpEvent event = events.get(binders.get(i)); if (event != null && event.getUidState() != newState) { if (event != null && event.getUidState() != newState) { try { try { Loading @@ -1272,16 +1278,17 @@ public class AppOpsService extends IAppOpsService.Stub { // Call started() to add a new start event object and then add the // Call started() to add a new start event object and then add the // previously removed unfinished start counts back // previously removed unfinished start counts back if (proxy != null) { if (proxy != null) { started(event.getClientId(), proxy.getUid(), proxy.getPackageName(), startedOrPaused(event.getClientId(), proxy.getUid(), proxy.getAttributionTag(), newState, event.getFlags(), false, proxy.getPackageName(), proxy.getAttributionTag(), newState, event.getFlags(), false, isRunning, event.getAttributionFlags(), event.getAttributionChainId()); event.getAttributionFlags(), event.getAttributionChainId()); } else { } else { started(event.getClientId(), Process.INVALID_UID, null, null, newState, startedOrPaused(event.getClientId(), Process.INVALID_UID, null, null, OP_FLAG_SELF, false, event.getAttributionFlags(), newState, event.getFlags(), false, isRunning, event.getAttributionChainId()); event.getAttributionFlags(), event.getAttributionChainId()); } } InProgressStartOpEvent newEvent = mInProgressEvents.get(binders.get(i)); InProgressStartOpEvent newEvent = events.get(binders.get(i)); if (newEvent != null) { if (newEvent != null) { newEvent.numUnfinishedStarts += numPreviousUnfinishedStarts - 1; newEvent.numUnfinishedStarts += numPreviousUnfinishedStarts - 1; } } Loading Loading @@ -6494,9 +6501,9 @@ public class AppOpsService extends IAppOpsService.Stub { int numAttrTags = op.mAttributions.size(); int numAttrTags = op.mAttributions.size(); for (int attrNum = 0; attrNum < numAttrTags; attrNum++) { for (int attrNum = 0; attrNum < numAttrTags; attrNum++) { AttributedOp attrOp = op.mAttributions.valueAt(attrNum); AttributedOp attrOp = op.mAttributions.valueAt(attrNum); if (restricted) { if (restricted && attrOp.isRunning()) { attrOp.pause(); attrOp.pause(); } else { } else if (attrOp.isPaused()) { attrOp.resume(); attrOp.resume(); } } } } Loading Loading
services/core/java/com/android/server/appop/AppOpsService.java +22 −15 Original line number Original line Diff line number Diff line Loading @@ -1029,7 +1029,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (isStarted && mInProgressEvents == null) { if (isStarted && mInProgressEvents == null) { mInProgressEvents = new ArrayMap<>(1); mInProgressEvents = new ArrayMap<>(1); } else if (mPausedInProgressEvents == null) { } else if (!isStarted && mPausedInProgressEvents == null) { mPausedInProgressEvents = new ArrayMap<>(1); mPausedInProgressEvents = new ArrayMap<>(1); } } ArrayMap<IBinder, InProgressStartOpEvent> events = isStarted ArrayMap<IBinder, InProgressStartOpEvent> events = isStarted Loading Loading @@ -1231,11 +1231,13 @@ public class AppOpsService extends IAppOpsService.Stub { */ */ void onClientDeath(@NonNull IBinder clientId) { void onClientDeath(@NonNull IBinder clientId) { synchronized (AppOpsService.this) { synchronized (AppOpsService.this) { if (mInProgressEvents == null) { if (mInProgressEvents == null && mPausedInProgressEvents == null) { return; return; } } InProgressStartOpEvent deadEvent = mInProgressEvents.get(clientId); ArrayMap<IBinder, InProgressStartOpEvent> events = isPaused() ? mPausedInProgressEvents : mInProgressEvents; InProgressStartOpEvent deadEvent = events.get(clientId); if (deadEvent != null) { if (deadEvent != null) { deadEvent.numUnfinishedStarts = 1; deadEvent.numUnfinishedStarts = 1; } } Loading @@ -1250,14 +1252,18 @@ public class AppOpsService extends IAppOpsService.Stub { * @param newState The new state * @param newState The new state */ */ public void onUidStateChanged(@AppOpsManager.UidState int newState) { public void onUidStateChanged(@AppOpsManager.UidState int newState) { if (mInProgressEvents == null) { if (mInProgressEvents == null && mPausedInProgressEvents == null) { return; return; } } int numInProgressEvents = mInProgressEvents.size(); boolean isRunning = isRunning(); List<IBinder> binders = new ArrayList<>(mInProgressEvents.keySet()); ArrayMap<IBinder, AppOpsService.InProgressStartOpEvent> events = isRunning ? mInProgressEvents : mPausedInProgressEvents; int numInProgressEvents = events.size(); List<IBinder> binders = new ArrayList<>(events.keySet()); for (int i = 0; i < numInProgressEvents; i++) { for (int i = 0; i < numInProgressEvents; i++) { InProgressStartOpEvent event = mInProgressEvents.get(binders.get(i)); InProgressStartOpEvent event = events.get(binders.get(i)); if (event != null && event.getUidState() != newState) { if (event != null && event.getUidState() != newState) { try { try { Loading @@ -1272,16 +1278,17 @@ public class AppOpsService extends IAppOpsService.Stub { // Call started() to add a new start event object and then add the // Call started() to add a new start event object and then add the // previously removed unfinished start counts back // previously removed unfinished start counts back if (proxy != null) { if (proxy != null) { started(event.getClientId(), proxy.getUid(), proxy.getPackageName(), startedOrPaused(event.getClientId(), proxy.getUid(), proxy.getAttributionTag(), newState, event.getFlags(), false, proxy.getPackageName(), proxy.getAttributionTag(), newState, event.getFlags(), false, isRunning, event.getAttributionFlags(), event.getAttributionChainId()); event.getAttributionFlags(), event.getAttributionChainId()); } else { } else { started(event.getClientId(), Process.INVALID_UID, null, null, newState, startedOrPaused(event.getClientId(), Process.INVALID_UID, null, null, OP_FLAG_SELF, false, event.getAttributionFlags(), newState, event.getFlags(), false, isRunning, event.getAttributionChainId()); event.getAttributionFlags(), event.getAttributionChainId()); } } InProgressStartOpEvent newEvent = mInProgressEvents.get(binders.get(i)); InProgressStartOpEvent newEvent = events.get(binders.get(i)); if (newEvent != null) { if (newEvent != null) { newEvent.numUnfinishedStarts += numPreviousUnfinishedStarts - 1; newEvent.numUnfinishedStarts += numPreviousUnfinishedStarts - 1; } } Loading Loading @@ -6494,9 +6501,9 @@ public class AppOpsService extends IAppOpsService.Stub { int numAttrTags = op.mAttributions.size(); int numAttrTags = op.mAttributions.size(); for (int attrNum = 0; attrNum < numAttrTags; attrNum++) { for (int attrNum = 0; attrNum < numAttrTags; attrNum++) { AttributedOp attrOp = op.mAttributions.valueAt(attrNum); AttributedOp attrOp = op.mAttributions.valueAt(attrNum); if (restricted) { if (restricted && attrOp.isRunning()) { attrOp.pause(); attrOp.pause(); } else { } else if (attrOp.isPaused()) { attrOp.resume(); attrOp.resume(); } } } } Loading