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

Commit e69cf6bc authored by Jing Ji's avatar Jing Ji Committed by Automerger Merge Worker
Browse files

Merge "Log the package name of the broadcast/service/provider requests" into...

Merge "Log the package name of the broadcast/service/provider requests" into udc-dev am: ab286e47 am: 1cbae357

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22134479



Change-Id: Iefab06a1703ea33658f9227afbe5290cdd6b56ea
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6820a5b7 1cbae357
Loading
Loading
Loading
Loading
+15 −11
Original line number Original line Diff line number Diff line
@@ -602,7 +602,7 @@ public final class ActiveServices {
                    try {
                    try {
                        final ServiceRecord.StartItem si = r.pendingStarts.get(0);
                        final ServiceRecord.StartItem si = r.pendingStarts.get(0);
                        startServiceInnerLocked(this, si.intent, r, false, true, si.callingId,
                        startServiceInnerLocked(this, si.intent, r, false, true, si.callingId,
                                si.mCallingProcessName, r.startRequested);
                                si.mCallingProcessName, r.startRequested, si.mCallingPackageName);
                    } catch (TransactionTooLargeException e) {
                    } catch (TransactionTooLargeException e) {
                        // Ignore, nobody upstack cares.
                        // Ignore, nobody upstack cares.
                    }
                    }
@@ -969,7 +969,7 @@ public final class ActiveServices {
                startServiceInnerLocked(r, service, callingUid, callingPid,
                startServiceInnerLocked(r, service, callingUid, callingPid,
                        getCallingProcessNameLocked(callingUid, callingPid, callingPackage),
                        getCallingProcessNameLocked(callingUid, callingPid, callingPackage),
                        fgRequired, callerFg,
                        fgRequired, callerFg,
                        backgroundStartPrivileges);
                        backgroundStartPrivileges, callingPackage);
        if (res.aliasComponent != null
        if (res.aliasComponent != null
                && !realResult.getPackageName().startsWith("!")
                && !realResult.getPackageName().startsWith("!")
                && !realResult.getPackageName().startsWith("?")) {
                && !realResult.getPackageName().startsWith("?")) {
@@ -990,7 +990,7 @@ public final class ActiveServices {
    private ComponentName startServiceInnerLocked(ServiceRecord r, Intent service,
    private ComponentName startServiceInnerLocked(ServiceRecord r, Intent service,
            int callingUid, int callingPid, String callingProcessName, boolean fgRequired,
            int callingUid, int callingPid, String callingProcessName, boolean fgRequired,
            boolean callerFg,
            boolean callerFg,
            BackgroundStartPrivileges backgroundStartPrivileges)
            BackgroundStartPrivileges backgroundStartPrivileges, String callingPackage)
            throws TransactionTooLargeException {
            throws TransactionTooLargeException {
        NeededUriGrants neededGrants = mAm.mUgmInternal.checkGrantUriPermissionFromIntent(
        NeededUriGrants neededGrants = mAm.mUgmInternal.checkGrantUriPermissionFromIntent(
                service, callingUid, r.packageName, r.userId);
                service, callingUid, r.packageName, r.userId);
@@ -1003,7 +1003,7 @@ public final class ActiveServices {
        r.delayedStop = false;
        r.delayedStop = false;
        r.fgRequired = fgRequired;
        r.fgRequired = fgRequired;
        r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(),
        r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(),
                service, neededGrants, callingUid, callingProcessName));
                service, neededGrants, callingUid, callingProcessName, callingPackage));


        if (fgRequired) {
        if (fgRequired) {
            // We are now effectively running a foreground service.
            // We are now effectively running a foreground service.
@@ -1088,7 +1088,7 @@ public final class ActiveServices {
            r.allowBgActivityStartsOnServiceStart(backgroundStartPrivileges);
            r.allowBgActivityStartsOnServiceStart(backgroundStartPrivileges);
        }
        }
        ComponentName cmp = startServiceInnerLocked(smap, service, r, callerFg, addToStarting,
        ComponentName cmp = startServiceInnerLocked(smap, service, r, callerFg, addToStarting,
                callingUid, callingProcessName, wasStartRequested);
                callingUid, callingProcessName, wasStartRequested, callingPackage);
        return cmp;
        return cmp;
    }
    }


@@ -1241,7 +1241,7 @@ public final class ActiveServices {
                        try {
                        try {
                            startServiceInnerLocked(s, serviceIntent, callingUid, callingPid,
                            startServiceInnerLocked(s, serviceIntent, callingUid, callingPid,
                                    callingProcessName, fgRequired, callerFg,
                                    callingProcessName, fgRequired, callerFg,
                                    backgroundStartPrivileges);
                                    backgroundStartPrivileges, callingPackage);
                        } catch (TransactionTooLargeException e) {
                        } catch (TransactionTooLargeException e) {
                            /* ignore - local call */
                            /* ignore - local call */
                        }
                        }
@@ -1287,7 +1287,7 @@ public final class ActiveServices {


    ComponentName startServiceInnerLocked(ServiceMap smap, Intent service, ServiceRecord r,
    ComponentName startServiceInnerLocked(ServiceMap smap, Intent service, ServiceRecord r,
            boolean callerFg, boolean addToStarting, int callingUid, String callingProcessName,
            boolean callerFg, boolean addToStarting, int callingUid, String callingProcessName,
            boolean wasStartRequested) throws TransactionTooLargeException {
            boolean wasStartRequested, String callingPackage) throws TransactionTooLargeException {
        synchronized (mAm.mProcessStats.mLock) {
        synchronized (mAm.mProcessStats.mLock) {
            final ServiceState stracker = r.getTracker();
            final ServiceState stracker = r.getTracker();
            if (stracker != null) {
            if (stracker != null) {
@@ -1328,7 +1328,9 @@ public final class ActiveServices {
                : SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM),
                : SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM),
                getShortProcessNameForStats(callingUid, callingProcessName),
                getShortProcessNameForStats(callingUid, callingProcessName),
                getShortServiceNameForStats(r),
                getShortServiceNameForStats(r),
                packageState);
                packageState,
                packageName,
                callingPackage);


        if (r.startRequested && addToStarting) {
        if (r.startRequested && addToStarting) {
            boolean first = smap.mStartingBackground.size() == 0;
            boolean first = smap.mStartingBackground.size() == 0;
@@ -3661,7 +3663,9 @@ public final class ActiveServices {
                    : SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM),
                    : SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM),
                    getShortProcessNameForStats(callingUid, callerApp.processName),
                    getShortProcessNameForStats(callingUid, callerApp.processName),
                    getShortServiceNameForStats(s),
                    getShortServiceNameForStats(s),
                    packageState);
                    packageState,
                    s.packageName,
                    callerApp.info.packageName);


            if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Bind " + s + " with " + b
            if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Bind " + s + " with " + b
                    + ": received=" + b.intent.received
                    + ": received=" + b.intent.received
@@ -5253,7 +5257,7 @@ public final class ActiveServices {
        // be called.
        // be called.
        if (r.startRequested && r.callStart && r.pendingStarts.size() == 0) {
        if (r.startRequested && r.callStart && r.pendingStarts.size() == 0) {
            r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(),
            r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(),
                    null, null, 0, null));
                    null, null, 0, null, null));
        }
        }


        sendServiceArgsLocked(r, execInFg, true);
        sendServiceArgsLocked(r, execInFg, true);
@@ -6247,7 +6251,7 @@ public final class ActiveServices {
                    stopServiceLocked(sr, true);
                    stopServiceLocked(sr, true);
                } else {
                } else {
                    sr.pendingStarts.add(new ServiceRecord.StartItem(sr, true,
                    sr.pendingStarts.add(new ServiceRecord.StartItem(sr, true,
                            sr.getLastStartId(), baseIntent, null, 0, null));
                            sr.getLastStartId(), baseIntent, null, 0, null, null));
                    if (sr.app != null && sr.app.getThread() != null) {
                    if (sr.app != null && sr.app.getThread() != null) {
                        // We always run in the foreground, since this is called as
                        // We always run in the foreground, since this is called as
                        // part of the "remove task" UI operation.
                        // part of the "remove task" UI operation.
+5 −2
Original line number Original line Diff line number Diff line
@@ -601,7 +601,9 @@ public class BroadcastQueueImpl extends BroadcastQueue {
                    r.dispatchTime - r.enqueueTime,
                    r.dispatchTime - r.enqueueTime,
                    r.receiverTime - r.dispatchTime,
                    r.receiverTime - r.dispatchTime,
                    finishTime - r.receiverTime,
                    finishTime - r.receiverTime,
                    packageState);
                    packageState,
                    r.curApp.info.packageName,
                    r.callerPackage);
        }
        }
        if (state == BroadcastRecord.IDLE) {
        if (state == BroadcastRecord.IDLE) {
            Slog.w(TAG_BROADCAST, "finishReceiver [" + mQueueName + "] called but state is IDLE");
            Slog.w(TAG_BROADCAST, "finishReceiver [" + mQueueName + "] called but state is IDLE");
@@ -780,7 +782,8 @@ public class BroadcastQueueImpl extends BroadcastQueue {
                    BROADCAST_DELIVERY_EVENT_REPORTED__RECEIVER_TYPE__RUNTIME,
                    BROADCAST_DELIVERY_EVENT_REPORTED__RECEIVER_TYPE__RUNTIME,
                    BROADCAST_DELIVERY_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                    BROADCAST_DELIVERY_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                    dispatchDelay, receiveDelay, 0 /* finish_delay */,
                    dispatchDelay, receiveDelay, 0 /* finish_delay */,
                    SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL);
                    SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL,
                    app != null ? app.info.packageName : null, callingPackage);
        }
        }
    }
    }


+8 −5
Original line number Original line Diff line number Diff line
@@ -1122,7 +1122,7 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
            }
            }


            r.terminalCount++;
            r.terminalCount++;
            notifyFinishReceiver(queue, r, index, receiver);
            notifyFinishReceiver(queue, app, r, index, receiver);
            checkFinished = true;
            checkFinished = true;
        }
        }
        // When entire ordered broadcast finished, deliver final result
        // When entire ordered broadcast finished, deliver final result
@@ -1597,9 +1597,10 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
     * typically for internal bookkeeping.
     * typically for internal bookkeeping.
     */
     */
    private void notifyFinishReceiver(@Nullable BroadcastProcessQueue queue,
    private void notifyFinishReceiver(@Nullable BroadcastProcessQueue queue,
            @NonNull BroadcastRecord r, int index, @NonNull Object receiver) {
            @Nullable ProcessRecord app, @NonNull BroadcastRecord r, int index,
            @NonNull Object receiver) {
        if (r.wasDeliveryAttempted(index)) {
        if (r.wasDeliveryAttempted(index)) {
            logBroadcastDeliveryEventReported(queue, r, index, receiver);
            logBroadcastDeliveryEventReported(queue, app, r, index, receiver);
        }
        }


        final boolean recordFinished = (r.terminalCount == r.receivers.size());
        final boolean recordFinished = (r.terminalCount == r.receivers.size());
@@ -1609,7 +1610,8 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
    }
    }


    private void logBroadcastDeliveryEventReported(@Nullable BroadcastProcessQueue queue,
    private void logBroadcastDeliveryEventReported(@Nullable BroadcastProcessQueue queue,
            @NonNull BroadcastRecord r, int index, @NonNull Object receiver) {
            @Nullable ProcessRecord app, @NonNull BroadcastRecord r, int index,
            @NonNull Object receiver) {
        // Report statistics for each individual receiver
        // Report statistics for each individual receiver
        final int uid = getReceiverUid(receiver);
        final int uid = getReceiverUid(receiver);
        final int senderUid = (r.callingUid == -1) ? Process.SYSTEM_UID : r.callingUid;
        final int senderUid = (r.callingUid == -1) ? Process.SYSTEM_UID : r.callingUid;
@@ -1635,7 +1637,8 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
                    ? SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_STOPPED
                    ? SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_STOPPED
                    : SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL;
                    : SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL;
            FrameworkStatsLog.write(BROADCAST_DELIVERY_EVENT_REPORTED, uid, senderUid, actionName,
            FrameworkStatsLog.write(BROADCAST_DELIVERY_EVENT_REPORTED, uid, senderUid, actionName,
                    receiverType, type, dispatchDelay, receiveDelay, finishDelay, packageState);
                    receiverType, type, dispatchDelay, receiveDelay, finishDelay, packageState,
                    app != null ? app.info.packageName : null, r.callerPackage);
        }
        }
    }
    }


+7 −4
Original line number Original line Diff line number Diff line
@@ -262,7 +262,8 @@ public class ContentProviderHelper {
                            PROVIDER_ACQUISITION_EVENT_REPORTED,
                            PROVIDER_ACQUISITION_EVENT_REPORTED,
                            r.uid, callingUid,
                            r.uid, callingUid,
                            PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                            PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                            PROVIDER_ACQUISITION_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL);
                            PROVIDER_ACQUISITION_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL,
                            cpi.packageName, callingPackage);
                    return holder;
                    return holder;
                }
                }


@@ -333,7 +334,8 @@ public class ContentProviderHelper {
                                PROVIDER_ACQUISITION_EVENT_REPORTED,
                                PROVIDER_ACQUISITION_EVENT_REPORTED,
                                cpr.proc.uid, callingUid,
                                cpr.proc.uid, callingUid,
                                PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                                PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                                PROVIDER_ACQUISITION_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL);
                                PROVIDER_ACQUISITION_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL,
                                cpi.packageName, callingPackage);
                    }
                    }
                } finally {
                } finally {
                    Binder.restoreCallingIdentity(origId);
                    Binder.restoreCallingIdentity(origId);
@@ -509,7 +511,8 @@ public class ContentProviderHelper {
                                    PROVIDER_ACQUISITION_EVENT_REPORTED,
                                    PROVIDER_ACQUISITION_EVENT_REPORTED,
                                    proc.uid, callingUid,
                                    proc.uid, callingUid,
                                    PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                                    PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
                                    PROVIDER_ACQUISITION_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL);
                                    PROVIDER_ACQUISITION_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL,
                                    cpi.packageName, callingPackage);
                        } else {
                        } else {
                            final int packageState =
                            final int packageState =
                                    ((cpr.appInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0)
                                    ((cpr.appInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0)
@@ -534,7 +537,7 @@ public class ContentProviderHelper {
                                    PROVIDER_ACQUISITION_EVENT_REPORTED,
                                    PROVIDER_ACQUISITION_EVENT_REPORTED,
                                    proc.uid, callingUid,
                                    proc.uid, callingUid,
                                    PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_COLD,
                                    PROVIDER_ACQUISITION_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_COLD,
                                    packageState);
                                    packageState, cpi.packageName, callingPackage);
                        }
                        }
                        cpr.launchingApp = proc;
                        cpr.launchingApp = proc;
                        mLaunchingProviders.add(cpr);
                        mLaunchingProviders.add(cpr);
+3 −1
Original line number Original line Diff line number Diff line
@@ -249,6 +249,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
        final String mCallingProcessName;
        final String mCallingProcessName;
        final Intent intent;
        final Intent intent;
        final NeededUriGrants neededGrants;
        final NeededUriGrants neededGrants;
        final @Nullable String mCallingPackageName;
        long deliveredTime;
        long deliveredTime;
        int deliveryCount;
        int deliveryCount;
        int doneExecutingCount;
        int doneExecutingCount;
@@ -258,7 +259,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN


        StartItem(ServiceRecord _sr, boolean _taskRemoved, int _id,
        StartItem(ServiceRecord _sr, boolean _taskRemoved, int _id,
                Intent _intent, NeededUriGrants _neededGrants, int _callingId,
                Intent _intent, NeededUriGrants _neededGrants, int _callingId,
                String callingProcessName) {
                String callingProcessName, @Nullable String callingPackageName) {
            sr = _sr;
            sr = _sr;
            taskRemoved = _taskRemoved;
            taskRemoved = _taskRemoved;
            id = _id;
            id = _id;
@@ -266,6 +267,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
            neededGrants = _neededGrants;
            neededGrants = _neededGrants;
            callingId = _callingId;
            callingId = _callingId;
            mCallingProcessName = callingProcessName;
            mCallingProcessName = callingProcessName;
            mCallingPackageName = callingPackageName;
        }
        }


        UriPermissionOwner getUriPermissionsLocked() {
        UriPermissionOwner getUriPermissionsLocked() {
Loading