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

Commit 3ff30271 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

Merge "Skip OomAdjuster update in bindService for self-bindings" into main

parents 437d1045 f8041cb4
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -319,6 +319,10 @@ public final class ActivityThread extends ClientTransactionHandler
    public static final int SERVICE_DONE_EXECUTING_START = 1;
    /** Type for IActivityManager.serviceDoneExecuting: done stopping (destroying) service */
    public static final int SERVICE_DONE_EXECUTING_STOP = 2;
    /** Type for IActivityManager.serviceDoneExecuting: done with an onRebind call */
    public static final int SERVICE_DONE_EXECUTING_REBIND = 3;
    /** Type for IActivityManager.serviceDoneExecuting: done with an onUnbind call */
    public static final int SERVICE_DONE_EXECUTING_UNBIND = 4;

    /** Use foreground GC policy (less pause time) and higher JIT weight. */
    private static final int VM_PROCESS_STATE_JANK_PERCEPTIBLE = 0;
@@ -4882,7 +4886,7 @@ public final class ActivityThread extends ClientTransactionHandler
            mServices.put(data.token, service);
            try {
                ActivityManager.getService().serviceDoneExecuting(
                        data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0);
                        data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0, null);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
@@ -4913,7 +4917,7 @@ public final class ActivityThread extends ClientTransactionHandler
                    } else {
                        s.onRebind(data.intent);
                        ActivityManager.getService().serviceDoneExecuting(
                                data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0);
                                data.token, SERVICE_DONE_EXECUTING_REBIND, 0, 0, data.intent);
                    }
                } catch (RemoteException ex) {
                    throw ex.rethrowFromSystemServer();
@@ -4943,7 +4947,7 @@ public final class ActivityThread extends ClientTransactionHandler
                                data.token, data.intent, doRebind);
                    } else {
                        ActivityManager.getService().serviceDoneExecuting(
                                data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0);
                                data.token, SERVICE_DONE_EXECUTING_UNBIND, 0, 0, data.intent);
                    }
                } catch (RemoteException ex) {
                    throw ex.rethrowFromSystemServer();
@@ -5057,7 +5061,7 @@ public final class ActivityThread extends ClientTransactionHandler

                try {
                    ActivityManager.getService().serviceDoneExecuting(
                            data.token, SERVICE_DONE_EXECUTING_START, data.startId, res);
                            data.token, SERVICE_DONE_EXECUTING_START, data.startId, res, null);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                }
@@ -5089,7 +5093,7 @@ public final class ActivityThread extends ClientTransactionHandler

                try {
                    ActivityManager.getService().serviceDoneExecuting(
                            token, SERVICE_DONE_EXECUTING_STOP, 0, 0);
                            token, SERVICE_DONE_EXECUTING_STOP, 0, 0, null);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                }
+2 −1
Original line number Diff line number Diff line
@@ -294,7 +294,8 @@ interface IActivityManager {
    @UnsupportedAppUsage
    ParceledListSlice getRecentTasks(int maxNum, int flags, int userId);
    @UnsupportedAppUsage
    oneway void serviceDoneExecuting(in IBinder token, int type, int startId, int res);
    oneway void serviceDoneExecuting(in IBinder token, int type, int startId, int res,
            in Intent intent);
    /** @deprecated  Use {@link #getIntentSenderWithFeature} instead */
    @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link PendingIntent#getIntentSender()} instead")
    IIntentSender getIntentSender(int type, in String packageName, in IBinder token,
+287 −88

File changed.

Preview size limit exceeded, changes collapsed.

+37 −5
Original line number Diff line number Diff line
@@ -1751,7 +1751,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    @GuardedBy("mProcLock")
    private long mLastBinderHeavyHitterAutoSamplerStart = 0L;
    final AppProfiler mAppProfiler;
    AppProfiler mAppProfiler;
    private static final int INDEX_NATIVE_PSS = 0;
    private static final int INDEX_NATIVE_SWAP_PSS = 1;
@@ -2496,7 +2496,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        mInjector = injector;
        mContext = mInjector.getContext();
        mUiContext = null;
        mAppErrors = null;
        mAppErrors = injector.getAppErrors();
        mPackageWatchdog = null;
        mAppOpsService = mInjector.getAppOpsService(null /* recentAccessesFile */,
            null /* storageFile */, null /* handler */);
@@ -2514,7 +2514,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                ? new OomAdjusterModernImpl(this, mProcessList, activeUids, handlerThread)
                : new OomAdjuster(this, mProcessList, activeUids, handlerThread);
        mIntentFirewall = null;
        mIntentFirewall = injector.getIntentFirewall();
        mProcessStats = new ProcessStatsService(this, mContext.getCacheDir());
        mCpHelper = new ContentProviderHelper(this, false);
        mServices = mInjector.getActiveServices(this);
@@ -13889,13 +13889,15 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    public void serviceDoneExecuting(IBinder token, int type, int startId, int res) {
    @Override
    public void serviceDoneExecuting(IBinder token, int type, int startId, int res, Intent intent) {
        synchronized(this) {
            if (!(token instanceof ServiceRecord)) {
                Slog.e(TAG, "serviceDoneExecuting: Invalid service token=" + token);
                throw new IllegalArgumentException("Invalid service token");
            }
            mServices.serviceDoneExecutingLocked((ServiceRecord) token, type, startId, res, false);
            mServices.serviceDoneExecutingLocked((ServiceRecord) token, type, startId, res, false,
                    intent);
        }
    }
@@ -20236,6 +20238,36 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            return broadcastQueues;
        }
        /** @see Binder#getCallingUid */
        public int getCallingUid() {
            return Binder.getCallingUid();
        }
        /** @see Binder#getCallingPid */
        public int getCallingPid() {
            return Binder.getCallingUid();
        }
        /** @see Binder#clearCallingIdentity */
        public long clearCallingIdentity() {
            return Binder.clearCallingIdentity();
        }
        /** @see Binder#clearCallingIdentity */
        public void restoreCallingIdentity(long ident) {
            Binder.restoreCallingIdentity(ident);
        }
        /** @return the default instance of AppErrors */
        public AppErrors getAppErrors() {
            return null;
        }
        /** @return the default instance of intent firewall */
        public IntentFirewall getIntentFirewall() {
            return null;
        }
    }
    @Override
+16 −1
Original line number Diff line number Diff line
@@ -1418,6 +1418,11 @@ public final class CachedAppOptimizer {
        freezeAppAsyncInternalLSP(app, delayMillis, false);
    }

    @GuardedBy({"mAm", "mProcLock"})
    void freezeAppAsyncAtEarliestLSP(ProcessRecord app) {
        freezeAppAsyncLSP(app, updateEarliestFreezableTime(app, 0));
    }

    @GuardedBy({"mAm", "mProcLock"})
    void freezeAppAsyncInternalLSP(ProcessRecord app, @UptimeMillisLong long delayMillis,
            boolean force) {
@@ -1714,6 +1719,14 @@ public final class CachedAppOptimizer {
                compactApp(frozenProc, CompactProfile.FULL, CompactSource.APP, false);
            }
        }
        frozenProc.onProcessFrozen();
    }

    /**
     * Callback received when an attempt to freeze a process is cancelled (failed).
     */
    void onProcessFrozenCancelled(ProcessRecord app) {
        app.onProcessFrozenCancelled();
    }

    /**
@@ -2203,6 +2216,8 @@ public final class CachedAppOptimizer {
                        onProcessFrozen(proc);
                        removeMessages(DEADLOCK_WATCHDOG_MSG);
                        sendEmptyMessageDelayed(DEADLOCK_WATCHDOG_MSG, FREEZE_DEADLOCK_TIMEOUT_MS);
                    } else {
                        onProcessFrozenCancelled(proc);
                    }
                } break;
                case REPORT_UNFREEZE_MSG: {
@@ -2460,7 +2475,7 @@ public final class CachedAppOptimizer {
                                pr = mAm.mPidsSelfLocked.get(blocked);
                            }
                            if (pr != null
                                    && pr.mState.getCurAdj() < ProcessList.CACHED_APP_MIN_ADJ) {
                                    && pr.mState.getCurAdj() < ProcessList.FREEZER_CUTOFF_ADJ) {
                                Slog.d(TAG_AM, app.processName + " (" + pid + ") blocks "
                                        + pr.processName + " (" + blocked + ")");
                                // Found at least one blocked non-cached process
Loading