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

Commit 47537a1c authored by Jeffrey Huang's avatar Jeffrey Huang
Browse files

Update activeConfigsChangedBroadcast

avoid using intentsender in #sendActiveConfigsChangedBroadcast
and #removeActiveConfigsChangedBroadcast.

Bug: 146074295
Test: Ran GTS Tests
Change-Id: I9313299ea0bc89f092b1c62fbfc34e06a127eaa9
parent ad213748
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -66,12 +66,6 @@ interface IStatsCompanionService {
    /** Pull the specified data. Results will be sent to statsd when complete. */
    StatsLogEventWrapper[] pullData(int pullCode);

    /**
     * Send a broadcast to the specified PendingIntent's as IBinder notifying it that the list
     * of active configs has changed.
     */
    oneway void sendActiveConfigsChangedBroadcast(in IBinder intentSender, in long[] configIds);

    /**
     * Requests StatsCompanionService to send a broadcast using the given intentSender
     * (which should cast to an IIntentSender), along with the other information specified.
+7 −0
Original line number Diff line number Diff line
@@ -52,6 +52,13 @@ interface IStatsManagerService {
     */
    long[] setActiveConfigsChangedOperation(in PendingIntent pendingIntent, in String packageName);

    /**
     * Removes the active configs changed operation for the specified package name.
     *
     * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
     */
    void removeActiveConfigsChangedOperation(in String packageName);

    /**
     * Set the PendingIntent to be used when broadcasting subscriber
     * information to the given subscriberId within the given config.
+2 −2
Original line number Diff line number Diff line
@@ -133,14 +133,14 @@ interface IStatsd {
     *
     * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
     */
    long[] setActiveConfigsChangedOperation(in IBinder intentSender, in String packageName);
    long[] setActiveConfigsChangedOperation(in IPendingIntentRef pendingIntentRef, int callingUid);

    /**
     * Removes the active configs changed operation for the specified package name.
     *
     * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
     */
    void removeActiveConfigsChangedOperation(in String packageName);
    void removeActiveConfigsChangedOperation(int callingUid);

    /**
     * Removes the configuration with the matching config key. No-op if this config key does not
+16 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.stats;

import android.app.PendingIntent;
import android.app.StatsManager;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
@@ -27,6 +28,8 @@ import android.util.Slog;

import com.android.server.SystemService;

import java.util.Arrays;

/**
 * @hide
 */
@@ -97,6 +100,8 @@ public class StatsCompanion {
         */
        private static final String EXTRA_LAST_REPORT_TIME = "android.app.extra.LAST_REPORT_TIME";
        private static final int CODE_DATA_BROADCAST = 1;
        private static final int CODE_ACTIVE_CONFIGS_BROADCAST = 1;


        private final PendingIntent mPendingIntent;
        private final Context mContext;
@@ -120,7 +125,17 @@ public class StatsCompanion {

        @Override
        public void sendActiveConfigsChangedBroadcast(long[] configIds) {
            // no-op
            enforceStatsCompanionPermission(mContext);
            Intent intent = new Intent();
            intent.putExtra(StatsManager.EXTRA_STATS_ACTIVE_CONFIG_KEYS, configIds);
            try {
                mPendingIntent.send(mContext, CODE_ACTIVE_CONFIGS_BROADCAST, intent, null, null);
                if (DEBUG) {
                    Slog.d(TAG, "Sent broadcast with config ids " + Arrays.toString(configIds));
                }
            } catch (PendingIntent.CanceledException e) {
                Slog.w(TAG, "Unable to send active configs changed broadcast using PendingIntent");
            }
        }

        @Override
+0 −17
Original line number Diff line number Diff line
@@ -203,7 +203,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
    private static final int INSTALLER_FIELD_ID = 5;

    public static final int CODE_SUBSCRIBER_BROADCAST = 1;
    public static final int CODE_ACTIVE_CONFIGS_BROADCAST = 1;
    public static final int DEATH_THRESHOLD = 10;
    /**
     * Which native processes to snapshot memory for.
@@ -443,22 +442,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                KernelCpuThreadReaderSettingsObserver.getSettingsModifiedReader(mContext);
    }

    @Override
    public void sendActiveConfigsChangedBroadcast(IBinder intentSenderBinder, long[] configIds) {
        StatsCompanion.enforceStatsCompanionPermission(mContext);
        IntentSender intentSender = new IntentSender(intentSenderBinder);
        Intent intent = new Intent();
        intent.putExtra(StatsManager.EXTRA_STATS_ACTIVE_CONFIG_KEYS, configIds);
        try {
            intentSender.sendIntent(mContext, CODE_ACTIVE_CONFIGS_BROADCAST, intent, null, null);
            if (DEBUG) {
                Slog.d(TAG, "Sent broadcast with config ids " + Arrays.toString(configIds));
            }
        } catch (IntentSender.SendIntentException e) {
            Slog.w(TAG, "Unable to send active configs changed broadcast using IntentSender");
        }
    }

    @Override
    public void sendSubscriberBroadcast(IBinder intentSenderBinder, long configUid, long configKey,
            long subscriptionId, long subscriptionRuleId, String[] cookies,
Loading