Fix weak global reference overflow

When the last item of sRunningAttributionSources is removed, the
current check condition will cause the process of removing
sRunningAttributionSources stopped and return directly, bring in weak
global reference table overflow.

Change the order for smooth removal.

Bug: 218794347
Test: run audio stress test pass
Change-Id: I39072f3b72f0be6d6debbcbc948d7a940ad92785
This commit is contained in:
ot903277
2022-06-29 16:15:19 +08:00
committed by Chuanghua Zhao
parent 4b7206b8d8
commit 11a19e4c71

View File

@@ -5689,16 +5689,21 @@ public class PermissionManagerService extends IPermissionManager.Stub {
appOpsManager.finishProxyOp(AppOpsManager.opToPublicName(op),
resolvedAttributionSource, skipCurrentFinish);
}
if (next == null || next.getNext() == null) {
return;
}
RegisteredAttribution registered =
sRunningAttributionSources.remove(current.getToken());
if (registered != null) {
registered.unregister();
}
if (next == null || next.getNext() == null) {
if (next != null) {
registered = sRunningAttributionSources.remove(next.getToken());
if (registered != null) {
registered.unregister();
}
}
return;
}
current = next;
}
}