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

Commit 38c004eb authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7325276 from 2fef6def to sc-release

Change-Id: I15050e1a15f18a931620e28707d81f93ddec999d
parents 0b863c75 2fef6def
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ java_defaults {
    visibility: ["//visibility:private"],
}

java_library_static {
java_library {
    name: "android-non-updatable.stubs",
    defaults: ["android-non-updatable_defaults_stubs_current"],
    srcs: [":api-stubs-docs-non-updatable"],
@@ -368,7 +368,7 @@ java_library_static {
    },
}

java_library_static {
java_library {
    name: "android-non-updatable.stubs.system",
    defaults: ["android-non-updatable_defaults_stubs_current"],
    srcs: [":system-api-stubs-docs-non-updatable"],
@@ -378,7 +378,7 @@ java_library_static {
    },
}

java_library_static {
java_library {
    name: "android-non-updatable.stubs.module_lib",
    defaults: ["android-non-updatable_defaults_stubs_current"],
    srcs: [":module-lib-api-stubs-docs-non-updatable"],
@@ -392,7 +392,7 @@ java_library_static {
    },
}

java_library_static {
java_library {
    name: "android-non-updatable.stubs.test",
    defaults: ["android-non-updatable_defaults_stubs_current"],
    srcs: [":test-api-stubs-docs-non-updatable"],
@@ -415,7 +415,7 @@ java_defaults {
    defaults_visibility: ["//frameworks/base/services"],
}

java_library_static {
java_library {
    name: "android_stubs_current",
    static_libs: modules_public_stubs + [
        "android-non-updatable.stubs",
@@ -424,7 +424,7 @@ java_library_static {
    defaults: ["android.jar_defaults"],
}

java_library_static {
java_library {
    name: "android_system_stubs_current",
    static_libs: modules_system_stubs + [
        "android-non-updatable.stubs.system",
@@ -450,7 +450,7 @@ java_library_static {
    ],
}

java_library_static {
java_library {
    name: "android_test_stubs_current",
    // Modules do not have test APIs, but we want to include their SystemApis, like we include
    // the SystemApi of framework-non-updatable-sources.
@@ -467,7 +467,7 @@ java_library_static {
    },
}

java_library_static {
java_library {
    name: "android_module_lib_stubs_current",
    defaults: [
        "android.jar_defaults",
@@ -531,7 +531,7 @@ droidstubs {
    visibility: ["//visibility:private"],
}

java_library_static {
java_library {
    name: "hwbinder.stubs",
    sdk_version: "core_current",
    libs: ["framework-annotations-lib"],
+9 −10
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.util.ArraySet;

import com.android.internal.infra.AndroidFuture;

import java.io.Closeable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -43,6 +41,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
@@ -95,7 +94,7 @@ public class AppSearchMigrationHelper implements Closeable {
        File queryFile = File.createTempFile(/*prefix=*/"appsearch", /*suffix=*/null);
        try (ParcelFileDescriptor fileDescriptor =
                     ParcelFileDescriptor.open(queryFile, MODE_WRITE_ONLY)) {
            AndroidFuture<AppSearchResult<Void>> androidFuture = new AndroidFuture<>();
            CompletableFuture<AppSearchResult<Void>> future = new CompletableFuture<>();
            mService.writeQueryResultsToFile(mPackageName, mDatabaseName,
                    fileDescriptor,
                    /*queryExpression=*/ "",
@@ -106,11 +105,11 @@ public class AppSearchMigrationHelper implements Closeable {
                    mUserId,
                    new IAppSearchResultCallback.Stub() {
                        @Override
                        public void onResult(AppSearchResult result) throws RemoteException {
                            androidFuture.complete(result);
                        public void onResult(AppSearchResult result) {
                            future.complete(result);
                        }
                    });
            AppSearchResult<Void> result = androidFuture.get();
            AppSearchResult<Void> result = future.get();
            if (!result.isSuccess()) {
                throw new AppSearchException(result.getResultCode(), result.getErrorMessage());
            }
@@ -142,15 +141,15 @@ public class AppSearchMigrationHelper implements Closeable {
        }
        try (ParcelFileDescriptor fileDescriptor =
                     ParcelFileDescriptor.open(mMigratedFile, MODE_READ_ONLY)) {
            AndroidFuture<AppSearchResult<List<Bundle>>> androidFuture = new AndroidFuture<>();
            CompletableFuture<AppSearchResult<List<Bundle>>> future = new CompletableFuture<>();
            mService.putDocumentsFromFile(mPackageName, mDatabaseName, fileDescriptor, mUserId,
                    new IAppSearchResultCallback.Stub() {
                        @Override
                        public void onResult(AppSearchResult result) throws RemoteException {
                            androidFuture.complete(result);
                        public void onResult(AppSearchResult result) {
                            future.complete(result);
                        }
                    });
            AppSearchResult<List<Bundle>> result = androidFuture.get();
            AppSearchResult<List<Bundle>> result = future.get();
            if (!result.isSuccess()) {
                return AppSearchResult.newFailedResult(result);
            }
+7 −6
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;

import com.android.internal.infra.AndroidFuture;
import com.android.internal.util.Preconditions;

import java.io.Closeable;
@@ -37,6 +36,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

@@ -708,8 +708,8 @@ public final class AppSearchSession implements Closeable {
            try {
                // Migration process
                // 1. Validate and retrieve all active migrators.
                AndroidFuture<AppSearchResult<GetSchemaResponse>> getSchemaFuture =
                        new AndroidFuture<>();
                CompletableFuture<AppSearchResult<GetSchemaResponse>> getSchemaFuture =
                        new CompletableFuture<>();
                getSchema(callbackExecutor, getSchemaFuture::complete);
                AppSearchResult<GetSchemaResponse> getSchemaResult = getSchemaFuture.get();
                if (!getSchemaResult.isSuccess()) {
@@ -733,7 +733,8 @@ public final class AppSearchSession implements Closeable {

                // 2. SetSchema with forceOverride=false, to retrieve the list of
                // incompatible/deleted types.
                AndroidFuture<AppSearchResult<Bundle>> setSchemaFuture = new AndroidFuture<>();
                CompletableFuture<AppSearchResult<Bundle>> setSchemaFuture =
                        new CompletableFuture<>();
                mService.setSchema(
                        mPackageName,
                        mDatabaseName,
@@ -781,8 +782,8 @@ public final class AppSearchSession implements Closeable {
                    // failed.
                    if (!setSchemaResponse.getIncompatibleTypes().isEmpty()
                            || !setSchemaResponse.getDeletedTypes().isEmpty()) {
                        AndroidFuture<AppSearchResult<Bundle>> setSchema2Future =
                                new AndroidFuture<>();
                        CompletableFuture<AppSearchResult<Bundle>> setSchema2Future =
                                new CompletableFuture<>();
                        // only trigger second setSchema() call if the first one is fail.
                        mService.setSchema(
                                mPackageName,
+0 −5
Original line number Diff line number Diff line
@@ -17,14 +17,9 @@ package android.app.appsearch;

import android.os.Bundle;

import android.app.appsearch.AppSearchBatchResult;
import android.app.appsearch.AppSearchResult;
import android.app.appsearch.IAppSearchBatchResultCallback;
import android.app.appsearch.IAppSearchResultCallback;
import android.os.ParcelFileDescriptor;
import com.android.internal.infra.AndroidFuture;

parcelable SearchResults;

/** {@hide} */
interface IAppSearchManager {
+150 −60
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@ import static com.android.server.alarm.Alarm.EXACT_ALLOW_REASON_COMPAT;
import static com.android.server.alarm.Alarm.EXACT_ALLOW_REASON_NOT_APPLICABLE;
import static com.android.server.alarm.Alarm.EXACT_ALLOW_REASON_PERMISSION;
import static com.android.server.alarm.Alarm.REQUESTER_POLICY_INDEX;
import static com.android.server.alarm.AlarmManagerService.RemovedAlarm.REMOVE_REASON_ALARM_CANCELLED;
import static com.android.server.alarm.AlarmManagerService.RemovedAlarm.REMOVE_REASON_DATA_CLEARED;
import static com.android.server.alarm.AlarmManagerService.RemovedAlarm.REMOVE_REASON_EXACT_PERMISSION_REVOKED;
import static com.android.server.alarm.AlarmManagerService.RemovedAlarm.REMOVE_REASON_PI_CANCELLED;
import static com.android.server.alarm.AlarmManagerService.RemovedAlarm.REMOVE_REASON_UNDEFINED;

import android.Manifest;
import android.annotation.NonNull;
@@ -116,6 +121,7 @@ import com.android.internal.app.IAppOpsService;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.LocalLog;
import com.android.internal.util.RingBuffer;
import com.android.internal.util.StatLogger;
import com.android.server.AlarmManagerInternal;
import com.android.server.AppStateTracker;
@@ -160,6 +166,7 @@ import java.util.function.Predicate;
public class AlarmManagerService extends SystemService {
    private static final int RTC_WAKEUP_MASK = 1 << RTC_WAKEUP;
    private static final int ELAPSED_REALTIME_WAKEUP_MASK = 1 << ELAPSED_REALTIME_WAKEUP;
    private static final int REMOVAL_HISTORY_SIZE_PER_UID = 10;
    static final int TIME_CHANGED_MASK = 1 << 16;
    static final int IS_WAKEUP_MASK = RTC_WAKEUP_MASK | ELAPSED_REALTIME_WAKEUP_MASK;

@@ -198,12 +205,11 @@ public class AlarmManagerService extends SystemService {
    final LocalLog mLog = new LocalLog(TAG);

    AppOpsManager mAppOps;
    IAppOpsService mAppOpsService;
    DeviceIdleInternal mLocalDeviceIdleController;
    private UsageStatsManagerInternal mUsageStatsManagerInternal;
    private ActivityManagerInternal mActivityManagerInternal;
    private PackageManagerInternal mPackageManagerInternal;
    private PermissionManagerServiceInternal mLocalPermissionManager;
    private volatile PermissionManagerServiceInternal mLocalPermissionManager;

    final Object mLock = new Object();

@@ -238,6 +244,7 @@ public class AlarmManagerService extends SystemService {
    AppWakeupHistory mAppWakeupHistory;
    AppWakeupHistory mAllowWhileIdleHistory;
    private final SparseLongArray mLastPriorityAlarmDispatch = new SparseLongArray();
    private final SparseArray<RingBuffer<RemovedAlarm>> mRemovalHistory = new SparseArray<>();
    ClockReceiver mClockReceiver;
    final DeliveryTracker mDeliveryTracker = new DeliveryTracker();
    IBinder.DeathRecipient mListenerDeathRecipient;
@@ -392,6 +399,57 @@ public class AlarmManagerService extends SystemService {
        }
    }

    static class RemovedAlarm {
        static final int REMOVE_REASON_UNDEFINED = 0;
        static final int REMOVE_REASON_ALARM_CANCELLED = 1;
        static final int REMOVE_REASON_EXACT_PERMISSION_REVOKED = 2;
        static final int REMOVE_REASON_DATA_CLEARED = 3;
        static final int REMOVE_REASON_PI_CANCELLED = 4;

        final String mTag;
        final long mWhenRemovedElapsed;
        final long mWhenRemovedRtc;
        final int mRemoveReason;

        RemovedAlarm(Alarm a, int removeReason, long nowRtc, long nowElapsed) {
            mTag = a.statsTag;
            mRemoveReason = removeReason;
            mWhenRemovedRtc = nowRtc;
            mWhenRemovedElapsed = nowElapsed;
        }

        static final boolean isLoggable(int reason) {
            // We don't want to log meaningless reasons. This also gives a way for callers to
            // opt out of logging, e.g. when replacing an alarm.
            return reason != REMOVE_REASON_UNDEFINED;
        }

        static final String removeReasonToString(int reason) {
            switch (reason) {
                case REMOVE_REASON_ALARM_CANCELLED:
                    return "alarm_cancelled";
                case REMOVE_REASON_EXACT_PERMISSION_REVOKED:
                    return "exact_alarm_permission_revoked";
                case REMOVE_REASON_DATA_CLEARED:
                    return "data_cleared";
                case REMOVE_REASON_PI_CANCELLED:
                    return "pi_cancelled";
                default:
                    return "unknown:" + reason;
            }
        }

        void dump(IndentingPrintWriter pw, long nowElapsed, SimpleDateFormat sdf) {
            pw.print("[tag", mTag);
            pw.print("reason", removeReasonToString(mRemoveReason));
            pw.print("elapsed=");
            TimeUtils.formatDuration(mWhenRemovedElapsed, nowElapsed, pw);
            pw.print(" rtc=");
            pw.print(sdf.format(new Date(mWhenRemovedRtc)));
            pw.println("]");
        }
    }

    /**
     * All times are in milliseconds. These constants are kept synchronized with the system
     * global Settings. Any access to this class or its fields should be done while
@@ -1447,7 +1505,7 @@ public class AlarmManagerService extends SystemService {
    @Override
    public void onStart() {
        mInjector.init();
        mMetricsHelper = new MetricsHelper(getContext());
        mMetricsHelper = new MetricsHelper(getContext(), mLock);

        mListenerDeathRecipient = new IBinder.DeathRecipient() {
            @Override
@@ -1571,10 +1629,24 @@ public class AlarmManagerService extends SystemService {
        if (phase == PHASE_SYSTEM_SERVICES_READY) {
            synchronized (mLock) {
                mConstants.start();

                mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
                mAppOpsService = mInjector.getAppOpsService();

                mLocalDeviceIdleController =
                        LocalServices.getService(DeviceIdleInternal.class);
                mUsageStatsManagerInternal =
                        LocalServices.getService(UsageStatsManagerInternal.class);

                mAppStateTracker =
                        (AppStateTrackerImpl) LocalServices.getService(AppStateTracker.class);
                mAppStateTracker.addListener(mForceAppStandbyListener);

                mClockReceiver.scheduleTimeTickEvent();
                mClockReceiver.scheduleDateChangedEvent();
            }
            IAppOpsService iAppOpsService = mInjector.getAppOpsService();
            try {
                    mAppOpsService.startWatchingMode(AppOpsManager.OP_SCHEDULE_EXACT_ALARM, null,
                iAppOpsService.startWatchingMode(AppOpsManager.OP_SCHEDULE_EXACT_ALARM, null,
                        new IAppOpsCallback.Stub() {
                            @Override
                            public void opChanged(int op, int uid, String packageName)
@@ -1590,12 +1662,6 @@ public class AlarmManagerService extends SystemService {
                        });
            } catch (RemoteException e) {
            }
                mMetricsHelper.registerPuller(mAlarmStore);

                mLocalDeviceIdleController =
                        LocalServices.getService(DeviceIdleInternal.class);
                mUsageStatsManagerInternal =
                        LocalServices.getService(UsageStatsManagerInternal.class);

            mLocalPermissionManager = LocalServices.getService(
                    PermissionManagerServiceInternal.class);
@@ -1605,13 +1671,7 @@ public class AlarmManagerService extends SystemService {
                    LocalServices.getService(AppStandbyInternal.class);
            appStandbyInternal.addListener(new AppStandbyTracker());

                mAppStateTracker =
                        (AppStateTrackerImpl) LocalServices.getService(AppStateTracker.class);
                mAppStateTracker.addListener(mForceAppStandbyListener);

                mClockReceiver.scheduleTimeTickEvent();
                mClockReceiver.scheduleDateChangedEvent();
            }
            mMetricsHelper.registerPuller(() -> mAlarmStore);
        }
    }

@@ -1691,7 +1751,7 @@ public class AlarmManagerService extends SystemService {

    void removeImpl(PendingIntent operation, IAlarmListener listener) {
        synchronized (mLock) {
            removeLocked(operation, listener);
            removeLocked(operation, listener, REMOVE_REASON_UNDEFINED);
        }
    }

@@ -1812,7 +1872,7 @@ public class AlarmManagerService extends SystemService {
                    + " -- package not allowed to start");
            return;
        }
        removeLocked(operation, directReceiver);
        removeLocked(operation, directReceiver, REMOVE_REASON_UNDEFINED);
        incrementAlarmCount(a.uid);
        setImplLocked(a);
        MetricsHelper.pushAlarmScheduled(a);
@@ -2106,7 +2166,7 @@ public class AlarmManagerService extends SystemService {
        @Override
        public void removeAlarmsForUid(int uid) {
            synchronized (mLock) {
                removeLocked(uid);
                removeLocked(uid, REMOVE_REASON_DATA_CLEARED);
            }
        }

@@ -2342,7 +2402,7 @@ public class AlarmManagerService extends SystemService {
                return;
            }
            synchronized (mLock) {
                removeLocked(operation, listener);
                removeLocked(operation, listener, REMOVE_REASON_ALARM_CANCELLED);
            }
        }

@@ -2688,6 +2748,7 @@ public class AlarmManagerService extends SystemService {

            pw.println("Allow while idle history:");
            mAllowWhileIdleHistory.dump(pw, nowELAPSED);
            pw.println();

            if (mLastPriorityAlarmDispatch.size() > 0) {
                pw.println("Last priority alarm dispatches:");
@@ -2702,6 +2763,23 @@ public class AlarmManagerService extends SystemService {
                pw.decreaseIndent();
            }

            if (mRemovalHistory.size() > 0) {
                pw.println("Removal history: ");
                pw.increaseIndent();
                for (int i = 0; i < mRemovalHistory.size(); i++) {
                    UserHandle.formatUid(pw, mRemovalHistory.keyAt(i));
                    pw.println(":");
                    pw.increaseIndent();
                    final RemovedAlarm[] historyForUid = mRemovalHistory.valueAt(i).toArray();
                    for (final RemovedAlarm removedAlarm : historyForUid) {
                        removedAlarm.dump(pw, nowELAPSED, sdf);
                    }
                    pw.decreaseIndent();
                }
                pw.decreaseIndent();
                pw.println();
            }

            if (mLog.dump(pw, "Recent problems:")) {
                pw.println();
            }
@@ -3239,7 +3317,7 @@ public class AlarmManagerService extends SystemService {
            }
            return !hasScheduleExactAlarmInternal(a.packageName, a.uid);
        };
        removeAlarmsInternalLocked(whichAlarms);
        removeAlarmsInternalLocked(whichAlarms, REMOVE_REASON_EXACT_PERMISSION_REVOKED);
    }

    /**
@@ -3247,7 +3325,6 @@ public class AlarmManagerService extends SystemService {
     * that the app is no longer eligible to use.
     *
     * This is not expected to get called frequently.
     * TODO (b/179541791): Add revocation history to dumpsys.
     */
    void removeExactAlarmsOnPermissionRevokedLocked(int uid, String packageName) {
        Slog.w(TAG, "Package " + packageName + ", uid " + uid + " lost SCHEDULE_EXACT_ALARM!");
@@ -3263,26 +3340,22 @@ public class AlarmManagerService extends SystemService {
            }
            return false;
        };
        removeAlarmsInternalLocked(whichAlarms);
        removeAlarmsInternalLocked(whichAlarms, REMOVE_REASON_EXACT_PERMISSION_REVOKED);
    }

    private void removeAlarmsInternalLocked(Predicate<Alarm> whichAlarms) {
    private void removeAlarmsInternalLocked(Predicate<Alarm> whichAlarms, int reason) {
        final long nowRtc = mInjector.getCurrentTimeMillis();
        final long nowElapsed = mInjector.getElapsedRealtime();

        final ArrayList<Alarm> removedAlarms = mAlarmStore.remove(whichAlarms);
        final boolean didRemove = !removedAlarms.isEmpty();
        if (didRemove) {
            for (final Alarm removed : removedAlarms) {
                decrementAlarmCount(removed.uid, 1);
            }
        }
        final boolean removedFromStore = !removedAlarms.isEmpty();

        for (int i = mPendingBackgroundAlarms.size() - 1; i >= 0; i--) {
            final ArrayList<Alarm> alarmsForUid = mPendingBackgroundAlarms.valueAt(i);
            for (int j = alarmsForUid.size() - 1; j >= 0; j--) {
                final Alarm alarm = alarmsForUid.get(j);
                if (whichAlarms.test(alarm)) {
                    // Don't set didRemove, since this doesn't impact the scheduled alarms.
                    alarmsForUid.remove(j);
                    decrementAlarmCount(alarm.uid, 1);
                    removedAlarms.add(alarmsForUid.remove(j));
                }
            }
            if (alarmsForUid.size() == 0) {
@@ -3292,13 +3365,24 @@ public class AlarmManagerService extends SystemService {
        for (int i = mPendingNonWakeupAlarms.size() - 1; i >= 0; i--) {
            final Alarm a = mPendingNonWakeupAlarms.get(i);
            if (whichAlarms.test(a)) {
                // Don't set didRemove, since this doesn't impact the scheduled alarms.
                mPendingNonWakeupAlarms.remove(i);
                decrementAlarmCount(a.uid, 1);
                removedAlarms.add(mPendingNonWakeupAlarms.remove(i));
            }
        }

        if (didRemove) {
        for (final Alarm removed : removedAlarms) {
            decrementAlarmCount(removed.uid, 1);
            if (!RemovedAlarm.isLoggable(reason)) {
                continue;
            }
            RingBuffer<RemovedAlarm> bufferForUid = mRemovalHistory.get(removed.uid);
            if (bufferForUid == null) {
                bufferForUid = new RingBuffer<>(RemovedAlarm.class, REMOVAL_HISTORY_SIZE_PER_UID);
                mRemovalHistory.put(removed.uid, bufferForUid);
            }
            bufferForUid.append(new RemovedAlarm(removed, reason, nowRtc, nowElapsed));
        }

        if (removedFromStore) {
            boolean idleUntilUpdated = false;
            if (mPendingIdleUntil != null && whichAlarms.test(mPendingIdleUntil)) {
                mPendingIdleUntil = null;
@@ -3320,7 +3404,7 @@ public class AlarmManagerService extends SystemService {
        }
    }

    void removeLocked(PendingIntent operation, IAlarmListener directReceiver) {
    void removeLocked(PendingIntent operation, IAlarmListener directReceiver, int reason) {
        if (operation == null && directReceiver == null) {
            if (localLOGV) {
                Slog.w(TAG, "requested remove() of null operation",
@@ -3328,15 +3412,15 @@ public class AlarmManagerService extends SystemService {
            }
            return;
        }
        removeAlarmsInternalLocked(a -> a.matches(operation, directReceiver));
        removeAlarmsInternalLocked(a -> a.matches(operation, directReceiver), reason);
    }

    void removeLocked(final int uid) {
    void removeLocked(final int uid, int reason) {
        if (uid == Process.SYSTEM_UID) {
            // If a force-stop occurs for a system-uid package, ignore it.
            return;
        }
        removeAlarmsInternalLocked(a -> a.uid == uid);
        removeAlarmsInternalLocked(a -> a.uid == uid, reason);
    }

    void removeLocked(final String packageName) {
@@ -3347,7 +3431,7 @@ public class AlarmManagerService extends SystemService {
            }
            return;
        }
        removeAlarmsInternalLocked(a -> a.matches(packageName));
        removeAlarmsInternalLocked(a -> a.matches(packageName), REMOVE_REASON_UNDEFINED);
    }

    // Only called for ephemeral apps
@@ -3358,7 +3442,7 @@ public class AlarmManagerService extends SystemService {
        }
        final Predicate<Alarm> whichAlarms = (a) -> (a.uid == uid
                && mActivityManagerInternal.isAppStartModeDisabled(uid, a.packageName));
        removeAlarmsInternalLocked(whichAlarms);
        removeAlarmsInternalLocked(whichAlarms, REMOVE_REASON_UNDEFINED);
    }

    void removeUserLocked(int userHandle) {
@@ -3368,13 +3452,18 @@ public class AlarmManagerService extends SystemService {
        }
        final Predicate<Alarm> whichAlarms =
                (Alarm a) -> UserHandle.getUserId(a.uid) == userHandle;
        removeAlarmsInternalLocked(whichAlarms);
        removeAlarmsInternalLocked(whichAlarms, REMOVE_REASON_UNDEFINED);

        for (int i = mLastPriorityAlarmDispatch.size() - 1; i >= 0; i--) {
            if (UserHandle.getUserId(mLastPriorityAlarmDispatch.keyAt(i)) == userHandle) {
                mLastPriorityAlarmDispatch.removeAt(i);
            }
        }
        for (int i = mRemovalHistory.size() - 1; i >= 0; i--) {
            if (UserHandle.getUserId(mRemovalHistory.keyAt(i)) == userHandle) {
                mRemovalHistory.removeAt(i);
            }
        }
    }

    void interactiveStateChangedLocked(boolean interactive) {
@@ -4018,7 +4107,7 @@ public class AlarmManagerService extends SystemService {
                case REMOVE_FOR_CANCELED:
                    final PendingIntent operation = (PendingIntent) msg.obj;
                    synchronized (mLock) {
                        removeLocked(operation, null);
                        removeLocked(operation, null, REMOVE_REASON_PI_CANCELLED);
                    }
                    break;

@@ -4198,6 +4287,7 @@ public class AlarmManagerService extends SystemService {
                        return;
                    case Intent.ACTION_UID_REMOVED:
                        mLastPriorityAlarmDispatch.delete(uid);
                        mRemovalHistory.delete(uid);
                        return;
                    case Intent.ACTION_PACKAGE_REMOVED:
                        if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
@@ -4227,7 +4317,7 @@ public class AlarmManagerService extends SystemService {
                            // package-removed and package-restarted case
                            mAppWakeupHistory.removeForPackage(pkg, UserHandle.getUserId(uid));
                            mAllowWhileIdleHistory.removeForPackage(pkg, UserHandle.getUserId(uid));
                            removeLocked(uid);
                            removeLocked(uid, REMOVE_REASON_UNDEFINED);
                        } else {
                            // external-applications-unavailable case
                            removeLocked(pkg);
Loading