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

Commit 9f5879f7 authored by Alex Buynytskyy's avatar Alex Buynytskyy Committed by Android (Google) Code Review
Browse files

Merge "Add new method notifyComponentUsed." into main

parents 8e331f99 a02c6340
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1369,6 +1369,13 @@ public abstract class PackageManagerInternal {
    public abstract void setPackageStoppedState(@NonNull String packageName, boolean stopped,
            @UserIdInt int userId);

    /**
     * Tells PackageManager when a component (except BroadcastReceivers) of the package is used
     * and the package should get out of stopped state and be enabled.
     */
    public abstract void notifyComponentUsed(@NonNull String packageName,
            @UserIdInt int userId, @NonNull String recentCallingPackage);

    /** @deprecated For legacy shell command only. */
    @Deprecated
    public abstract void legacyDumpProfiles(@NonNull String packageName,
+2 −3
Original line number Diff line number Diff line
@@ -5116,10 +5116,9 @@ public final class ActiveServices {
                    r.packageName, r.userId, UsageEvents.Event.APP_COMPONENT_USED);
        }

        // Service is now being launched, its package can't be stopped.
        try {
            mAm.mPackageManagerInt.setPackageStoppedState(
                    r.packageName, false, r.userId);
            mAm.mPackageManagerInt.notifyComponentUsed(
                    r.packageName, r.userId, r.mRecentCallingPackage);
        } catch (IllegalArgumentException e) {
            Slog.w(TAG, "Failed trying to unstop package "
                    + r.packageName + ": " + e);
+2 −3
Original line number Diff line number Diff line
@@ -505,12 +505,11 @@ public class ContentProviderHelper {
                                    cpr.appInfo.packageName, userId, Event.APP_COMPONENT_USED);
                        }

                        // Content provider is now in use, its package can't be stopped.
                        try {
                            checkTime(startTime,
                                    "getContentProviderImpl: before set stopped state");
                            mService.mPackageManagerInt.setPackageStoppedState(
                                    cpr.appInfo.packageName, false, userId);
                            mService.mPackageManagerInt.notifyComponentUsed(
                                    cpr.appInfo.packageName, userId, callingPackage);
                            checkTime(startTime, "getContentProviderImpl: after set stopped state");
                        } catch (IllegalArgumentException e) {
                            Slog.w(TAG, "Failed trying to unstop package "
+7 −0
Original line number Diff line number Diff line
@@ -745,6 +745,13 @@ abstract class PackageManagerInternalBase extends PackageManagerInternal {
        mService.setPackageStoppedState(snapshot(), packageName, stopped, userId);
    }

    @Override
    public void notifyComponentUsed(@NonNull String packageName,
            @UserIdInt int userId, @NonNull String recentCallingPackage) {
        mService.notifyComponentUsed(snapshot(), packageName, userId,
                recentCallingPackage);
    }

    @NonNull
    @Override
    @Deprecated
+7 −0
Original line number Diff line number Diff line
@@ -4582,6 +4582,13 @@ public class PackageManagerService implements PackageSender, TestUtilityService
        }
    }

    void notifyComponentUsed(@NonNull Computer snapshot, @NonNull String packageName,
            @UserIdInt int userId, @NonNull String recentCallingPackage) {
        PackageManagerService.this
                .setPackageStoppedState(snapshot, packageName, false /* stopped */,
                        userId);
    }

    public class IPackageManagerImpl extends IPackageManagerBase {

        public IPackageManagerImpl() {
Loading