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

Commit cf2ef0c0 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add wtf log when starting activities with different uids

To know more about the use cases of startActivities.

Bug: 145669109
Test: Use startActivities to launch multiple activities
      in different apps (uids) and check event log.

Change-Id: Ica905b2c81b7b587ca55f29f82ed7685f15ca001
parent c3527d7e
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.os.Message;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
import android.view.RemoteAnimationAdapter;

@@ -385,6 +386,7 @@ public class ActivityStartController {
        } else {
            callingPid = callingUid = -1;
        }
        final SparseArray<String> startingUidPkgs = new SparseArray<>();
        final long origId = Binder.clearCallingIdentity();
        try {
            intents = ArrayUtils.filterNotNull(intents, Intent[]::new);
@@ -411,9 +413,14 @@ public class ActivityStartController {
                                callingUid, realCallingUid, UserHandle.USER_NULL));
                aInfo = mService.mAmInternal.getActivityInfoForUser(aInfo, userId);

                if (aInfo != null && (aInfo.applicationInfo.privateFlags
                if (aInfo != null) {
                    if ((aInfo.applicationInfo.privateFlags
                            & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) {
                    throw new IllegalArgumentException("FLAG_CANT_SAVE_STATE not supported here");
                        throw new IllegalArgumentException(
                                "FLAG_CANT_SAVE_STATE not supported here");
                    }
                    startingUidPkgs.put(aInfo.applicationInfo.uid,
                            aInfo.applicationInfo.packageName);
                }

                final boolean top = i == intents.length - 1;
@@ -439,6 +446,16 @@ public class ActivityStartController {
                        .setOriginatingPendingIntent(originatingPendingIntent)
                        .setAllowBackgroundActivityStart(allowBackgroundActivityStart);
            }
            // Log if the activities to be started have different uids.
            if (startingUidPkgs.size() > 1) {
                final StringBuilder sb = new StringBuilder("startActivities: different apps [");
                final int size = startingUidPkgs.size();
                for (int i = 0; i < size; i++) {
                    sb.append(startingUidPkgs.valueAt(i)).append(i == size - 1 ? "]" : ", ");
                }
                sb.append(" from ").append(callingPackage);
                Slog.wtf(TAG, sb.toString());
            }

            final ActivityRecord[] outActivity = new ActivityRecord[1];
            // Lock the loop to ensure the activities launched in a sequence.