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

Commit c676cdfc authored by Omar Eissa's avatar Omar Eissa
Browse files

Call notifyComponentUsed for broadcast flow

Replace the call to setPackageStoppedState with notifyComponentUsed when
sending a broadcast to be consistent with all other package components usages (Activities, Services, ContentProviders).

Bug: 269127435
Test: manual + presubmit
Change-Id: If3047e1361535440667befc9b3e9772ff074af69
parent 0b4290ca
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1387,11 +1387,12 @@ public abstract class PackageManagerInternal {
            @UserIdInt int userId);

    /**
     * Tells PackageManager when a component (except BroadcastReceivers) of the package is used
     * Tells PackageManager when a component 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, @NonNull String debugInfo);
            @UserIdInt int userId, @Nullable String recentCallingPackage,
            @NonNull String debugInfo);

    /** @deprecated For legacy shell command only. */
    @Deprecated
+2 −3
Original line number Diff line number Diff line
@@ -1440,10 +1440,9 @@ public class BroadcastQueueImpl extends BroadcastQueue {
                    r.curComponent.getPackageName(), r.userId, Event.APP_COMPONENT_USED);
        }

        // Broadcast is being executed, its package can't be stopped.
        try {
            mService.mPackageManagerInt.setPackageStoppedState(
                    r.curComponent.getPackageName(), false, r.userId);
            mService.mPackageManagerInt.notifyComponentUsed(
                    r.curComponent.getPackageName(), r.userId, r.callerPackage, r.toString());
        } catch (IllegalArgumentException e) {
            Slog.w(TAG, "Failed trying to unstop package "
                    + r.curComponent.getPackageName() + ": " + e);
+2 −2
Original line number Diff line number Diff line
@@ -1977,8 +1977,8 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
        mService.notifyPackageUse(receiverPackageName,
                PackageManager.NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER);

        mService.mPackageManagerInt.setPackageStoppedState(
                receiverPackageName, false, r.userId);
        mService.mPackageManagerInt.notifyComponentUsed(
                receiverPackageName, r.userId, r.callerPackage, r.toString());
    }

    private void reportUsageStatsBroadcastDispatched(@NonNull ProcessRecord app,
+1 −1
Original line number Diff line number Diff line
@@ -747,7 +747,7 @@ abstract class PackageManagerInternalBase extends PackageManagerInternal {

    @Override
    public void notifyComponentUsed(@NonNull String packageName, @UserIdInt int userId,
            @NonNull String recentCallingPackage, @NonNull String debugInfo) {
            @Nullable String recentCallingPackage, @NonNull String debugInfo) {
        mService.notifyComponentUsed(snapshot(), packageName, userId,
                recentCallingPackage, debugInfo);
    }
+1 −1
Original line number Diff line number Diff line
@@ -4557,7 +4557,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    }

    void notifyComponentUsed(@NonNull Computer snapshot, @NonNull String packageName,
            @UserIdInt int userId, @NonNull String recentCallingPackage,
            @UserIdInt int userId, @Nullable String recentCallingPackage,
            @NonNull String debugInfo) {
        synchronized (mLock) {
            final PackageSetting pkgSetting = mSettings.getPackageLPr(packageName);
Loading