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

Commit f36ee681 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove FLAG_SERVICE_BINDING_OOM_ADJ_POLICY" into main

parents fca42188 0d179e39
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -4509,8 +4509,8 @@ public final class ActiveServices {
                }

                serviceDoneExecutingLocked(r, mDestroyingServices.contains(r), false, false,
                        !Flags.serviceBindingOomAdjPolicy() || r.wasOomAdjUpdated()
                        ? OOM_ADJ_REASON_EXECUTING_SERVICE : OOM_ADJ_REASON_NONE);
                        r.wasOomAdjUpdated() ? OOM_ADJ_REASON_EXECUTING_SERVICE
                                : OOM_ADJ_REASON_NONE);
            }
        } finally {
            mAm.mInjector.restoreCallingIdentity(origId);
@@ -4656,8 +4656,7 @@ public final class ActiveServices {
                }

                serviceDoneExecutingLocked(r, inDestroying, false, false,
                        !Flags.serviceBindingOomAdjPolicy() || r.wasOomAdjUpdated()
                        ? OOM_ADJ_REASON_UNBIND_SERVICE : OOM_ADJ_REASON_NONE);
                        r.wasOomAdjUpdated() ? OOM_ADJ_REASON_UNBIND_SERVICE : OOM_ADJ_REASON_NONE);
            }
        } finally {
            mAm.mInjector.restoreCallingIdentity(origId);
@@ -5268,16 +5267,14 @@ public final class ActiveServices {
                if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Crashed while binding " + r, e);
                final boolean inDestroying = mDestroyingServices.contains(r);
                serviceDoneExecutingLocked(r, inDestroying, inDestroying, false,
                        !Flags.serviceBindingOomAdjPolicy() || r.wasOomAdjUpdated()
                        ? OOM_ADJ_REASON_UNBIND_SERVICE : OOM_ADJ_REASON_NONE);
                        r.wasOomAdjUpdated() ? OOM_ADJ_REASON_UNBIND_SERVICE : OOM_ADJ_REASON_NONE);
                throw e;
            } catch (RemoteException e) {
                if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Crashed while binding " + r);
                // Keep the executeNesting count accurate.
                final boolean inDestroying = mDestroyingServices.contains(r);
                serviceDoneExecutingLocked(r, inDestroying, inDestroying, false,
                        !Flags.serviceBindingOomAdjPolicy() || r.wasOomAdjUpdated()
                        ? OOM_ADJ_REASON_UNBIND_SERVICE : OOM_ADJ_REASON_NONE);
                        r.wasOomAdjUpdated() ? OOM_ADJ_REASON_UNBIND_SERVICE : OOM_ADJ_REASON_NONE);
                return false;
            }
        }
@@ -6007,7 +6004,7 @@ public final class ActiveServices {
    private int getServiceBindingOomAdjPolicyForAddLocked(ProcessRecord clientApp,
            ProcessRecord hostApp, ConnectionRecord cr) {
        @ServiceBindingOomAdjPolicy int policy = SERVICE_BIND_OOMADJ_POLICY_LEGACY;
        if (Flags.serviceBindingOomAdjPolicy() && clientApp != null && hostApp != null) {
        if (clientApp != null && hostApp != null) {
            if (clientApp == hostApp) {
                policy = DEFAULT_SERVICE_NO_BUMP_BIND_POLICY_FLAG;
            } else if (clientApp.isCached()) {
@@ -6041,7 +6038,7 @@ public final class ActiveServices {
    private int getServiceBindingOomAdjPolicyForRemovalLocked(ProcessRecord clientApp,
            ProcessRecord hostApp, ConnectionRecord cr) {
        @ServiceBindingOomAdjPolicy int policy = SERVICE_BIND_OOMADJ_POLICY_LEGACY;
        if (Flags.serviceBindingOomAdjPolicy() && clientApp != null && hostApp != null
        if (clientApp != null && hostApp != null
                && cr != null) {
            if (clientApp == hostApp) {
                policy = DEFAULT_SERVICE_NO_BUMP_BIND_POLICY_FLAG;
@@ -6131,8 +6128,7 @@ public final class ActiveServices {
                // Keep the executeNesting count accurate.
                final boolean inDestroying = mDestroyingServices.contains(r);
                serviceDoneExecutingLocked(r, inDestroying, inDestroying, false,
                        !Flags.serviceBindingOomAdjPolicy() || r.wasOomAdjUpdated()
                        ? OOM_ADJ_REASON_STOP_SERVICE : OOM_ADJ_REASON_NONE);
                        r.wasOomAdjUpdated() ? OOM_ADJ_REASON_STOP_SERVICE : OOM_ADJ_REASON_NONE);

                // Cleanup.
                if (newService) {
@@ -6353,7 +6349,7 @@ public final class ActiveServices {
            }
        }

        boolean oomAdjusted = Flags.serviceBindingOomAdjPolicy() && r.wasOomAdjUpdated();
        boolean oomAdjusted = r.wasOomAdjUpdated();

        // Tell the service that it has been unbound.
        if (r.app != null && r.app.isThreadReady()) {
@@ -6813,8 +6809,8 @@ public final class ActiveServices {
            }
            final long origId = mAm.mInjector.clearCallingIdentity();
            serviceDoneExecutingLocked(r, inDestroying, inDestroying, enqueueOomAdj,
                    !Flags.serviceBindingOomAdjPolicy() || r.wasOomAdjUpdated() || needOomAdj
                    ? OOM_ADJ_REASON_EXECUTING_SERVICE : OOM_ADJ_REASON_NONE);
                    r.wasOomAdjUpdated() || needOomAdj ? OOM_ADJ_REASON_EXECUTING_SERVICE
                            : OOM_ADJ_REASON_NONE);
            mAm.mInjector.restoreCallingIdentity(origId);
        } else {
            Slog.w(TAG, "Done executing unknown service from pid "
+5 −9
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import static com.android.internal.util.FrameworkStatsLog.PROVIDER_ACQUISITION_E
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_MU;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PROCESSES;
import static com.android.server.am.ActivityManagerService.TAG_MU;
import static com.android.server.am.Flags.serviceBindingOomAdjPolicy;

import android.annotation.Nullable;
import android.annotation.UserIdInt;
@@ -323,11 +322,9 @@ public class ContentProviderHelper {

                    checkTime(startTime, "getContentProviderImpl: before updateOomAdj");
                    final int verifiedAdj = cpr.proc.mState.getVerifiedAdj();
                    boolean success = !serviceBindingOomAdjPolicy()
                            || mService.mOomAdjuster.evaluateProviderConnectionAdd(r, cpr.proc)
                            ? mService.mProcessStateController.runUpdate(cpr.proc,
                            OOM_ADJ_REASON_GET_PROVIDER)
                            : true;
                    boolean success = mService.mOomAdjuster.evaluateProviderConnectionAdd(r,
                            cpr.proc) ? mService.mProcessStateController.runUpdate(cpr.proc,
                            OOM_ADJ_REASON_GET_PROVIDER) : true;
                    // XXX things have changed so updateOomAdjLocked doesn't actually tell us
                    // if the process has been successfully adjusted.  So to reduce races with
                    // it, we will check whether the process still exists.  Note that this doesn't
@@ -1557,9 +1554,8 @@ public class ContentProviderHelper {
            }
            mService.stopAssociationLocked(conn.client.uid, conn.client.processName, cpr.uid,
                    cpr.appInfo.longVersionCode, cpr.name, cpr.info.processName);
            if (updateOomAdj && (!serviceBindingOomAdjPolicy()
                    || mService.mOomAdjuster.evaluateProviderConnectionRemoval(conn.client,
                            cpr.proc))) {
            if (updateOomAdj && mService.mOomAdjuster.evaluateProviderConnectionRemoval(conn.client,
                    cpr.proc)) {
                mService.updateOomAdjLocked(conn.provider.proc, OOM_ADJ_REASON_REMOVE_PROVIDER);
            }
        }
+3 −10
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.server.am;
import static android.app.ProcessMemoryState.HOSTING_COMPONENT_TYPE_BOUND_SERVICE;
import static android.app.ProcessMemoryState.HOSTING_COMPONENT_TYPE_FOREGROUND_SERVICE;

import static com.android.server.am.Flags.serviceBindingOomAdjPolicy;

import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.Context;
@@ -696,9 +694,6 @@ final class ProcessServiceRecord {

    @GuardedBy("mService")
    private void scheduleServiceTimeoutIfNeededLocked() {
        if (!serviceBindingOomAdjPolicy()) {
            return;
        }
        if (mScheduleServiceTimeoutPending && mExecutingServices.size() > 0) {
            mService.mServices.scheduleServiceTimeoutLocked(mApp);
            // We'll need to reset the executingStart since the app was frozen.
@@ -753,10 +748,8 @@ final class ProcessServiceRecord {
                pw.print(prefix); pw.print("  - "); pw.println(mConnections.valueAt(i));
            }
        }
        if (serviceBindingOomAdjPolicy()) {
        pw.print(prefix);
        pw.print("scheduleServiceTimeoutPending=");
        pw.println(mScheduleServiceTimeoutPending);
    }
}
}
+0 −7
Original line number Diff line number Diff line
@@ -15,13 +15,6 @@ flag {
    bug: "304347838"
}

flag {
    name: "service_binding_oom_adj_policy"
    namespace: "backstage_power"
    description: "Optimize the service bindings by different policies like skipping oom adjuster"
    bug: "318717054"
}

flag {
    namespace: "backstage_power"
    name: "defer_outgoing_broadcasts"
+2 −258

File changed.

Preview size limit exceeded, changes collapsed.