Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f109076 authored by Michael Wachenschwanz's avatar Michael Wachenschwanz Committed by Android (Google) Code Review
Browse files

Merge "Fix sandboxed process traversal in new OomAdjuster" into main

parents 147602c4 570de8d5
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -722,14 +722,8 @@ public class OomAdjusterModernImpl extends OomAdjuster {
        performNewUpdateOomAdjLSP(oomAdjReason, topApp, targetProcesses, activeUids,
                fullUpdate, now, UNKNOWN_ADJ);

        if (fullUpdate) {
        // TODO: b/319163103 - optimize cache adj assignment to not require the whole lru list.
        assignCachedAdjIfNecessary(mProcessList.getLruProcessesLOSP());
        } else {
            activeProcesses.clear();
            activeProcesses.addAll(targetProcesses);
            assignCachedAdjIfNecessary(activeProcesses);
            activeProcesses.clear();
        }
        postUpdateOomAdjInnerLSP(oomAdjReason, activeUids, now, nowElapsed, oldTime);
        targetProcesses.clear();

@@ -996,11 +990,11 @@ public class OomAdjusterModernImpl extends OomAdjuster {
                            && service.mState.getMaxAdj() < FOREGROUND_APP_ADJ)
                    || (service.mState.getCurAdj() <= FOREGROUND_APP_ADJ
                            && service.mState.getCurrentSchedulingGroup() > SCHED_GROUP_BACKGROUND
                            && service.mState.getCurProcState() <= PROCESS_STATE_TOP)) {
                            && service.mState.getCurProcState() <= PROCESS_STATE_TOP)
                    || (service.isSdkSandbox && cr.binding.attributedClient != null)) {
                continue;
            }


            computeServiceHostOomAdjLSP(cr, service, app, now, topApp, fullUpdate, false, false,
                    oomAdjReason, cachedAdj, false, false);
        }
+5 −21
Original line number Diff line number Diff line
@@ -1678,10 +1678,14 @@ class ProcessRecord implements WindowProcessListener {
                final ArrayList<ConnectionRecord> clist = serviceConnections.valueAt(j);
                for (int k = clist.size() - 1; k >= 0; k--) {
                    final ConnectionRecord cr = clist.get(k);
                    if (isSdkSandbox && cr.binding.attributedClient != null) {
                        consumer.accept(cr.binding.attributedClient);
                    } else {
                        consumer.accept(cr.binding.client);
                    }
                }
            }
        }
        for (int i = mProviders.numberOfProviders() - 1; i >= 0; i--) {
            final ContentProviderRecord cpr = mProviders.getProviderAt(i);
            for (int j = cpr.connections.size() - 1; j >= 0; j--) {
@@ -1689,25 +1693,5 @@ class ProcessRecord implements WindowProcessListener {
                consumer.accept(conn.client);
            }
        }
        // If this process is a sandbox itself, also add the app on whose behalf
        // its running
        if (isSdkSandbox) {
            for (int is = mServices.numberOfRunningServices() - 1; is >= 0; is--) {
                ServiceRecord s = mServices.getRunningServiceAt(is);
                ArrayMap<IBinder, ArrayList<ConnectionRecord>> serviceConnections =
                        s.getConnections();
                for (int conni = serviceConnections.size() - 1; conni >= 0; conni--) {
                    ArrayList<ConnectionRecord> clist = serviceConnections.valueAt(conni);
                    for (int i = clist.size() - 1; i >= 0; i--) {
                        ConnectionRecord cr = clist.get(i);
                        ProcessRecord attributedApp = cr.binding.attributedClient;
                        if (attributedApp == null || attributedApp == this) {
                            continue;
                        }
                        consumer.accept(attributedApp);
                    }
                }
            }
        }
    }
}
+307 −212

File changed.

Preview size limit exceeded, changes collapsed.