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

Commit 6f44b5ef authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['ag/19744515', 'ag/19868476', 'ag/20404109',...

Merge cherrypicks of ['ag/19744515', 'ag/19868476', 'ag/20404109', 'ag/20406275', 'ag/20302522', 'ag/20541824', 'ag/20506676', 'ag/20510886'] into security-aosp-tm-release.

Change-Id: I41a6ce67747af5860f38b0a878a3ce09fed69554
parents 374238a9 8f55482f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -402,7 +402,7 @@ public class ChooseTypeAndAccountActivity extends Activity
                mExistingAccounts = AccountManager.get(this).getAccountsForPackage(mCallingPackage,
                        mCallingUid);
                intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivityForResult(intent, REQUEST_ADD_ACCOUNT);
                startActivityForResult(new Intent(intent), REQUEST_ADD_ACCOUNT);
                return;
            }
        } catch (OperationCanceledException e) {
+13 −9
Original line number Diff line number Diff line
@@ -9134,8 +9134,9 @@ public class AppOpsManager {
     */
    public int startProxyOpNoThrow(int op, @NonNull AttributionSource attributionSource,
            @Nullable String message, boolean skipProxyOperation) {
        return startProxyOpNoThrow(op, attributionSource, message, skipProxyOperation,
                ATTRIBUTION_FLAGS_NONE, ATTRIBUTION_FLAGS_NONE, ATTRIBUTION_CHAIN_ID_NONE);
        return startProxyOpNoThrow(attributionSource.getToken(), op, attributionSource, message,
                skipProxyOperation, ATTRIBUTION_FLAGS_NONE, ATTRIBUTION_FLAGS_NONE,
                ATTRIBUTION_CHAIN_ID_NONE);
    }

    /**
@@ -9147,7 +9148,8 @@ public class AppOpsManager {
     *
     * @hide
     */
    public int startProxyOpNoThrow(int op, @NonNull AttributionSource attributionSource,
    public int startProxyOpNoThrow(@NonNull IBinder clientId, int op,
            @NonNull AttributionSource attributionSource,
            @Nullable String message, boolean skipProxyOperation, @AttributionFlags
            int proxyAttributionFlags, @AttributionFlags int proxiedAttributionFlags,
            int attributionChainId) {
@@ -9165,7 +9167,7 @@ public class AppOpsManager {
                }
            }

            SyncNotedAppOp syncOp = mService.startProxyOperation(op,
            SyncNotedAppOp syncOp = mService.startProxyOperation(clientId, op,
                    attributionSource, false, collectionMode == COLLECT_ASYNC, message,
                    shouldCollectMessage, skipProxyOperation, proxyAttributionFlags,
                    proxiedAttributionFlags, attributionChainId);
@@ -9263,9 +9265,10 @@ public class AppOpsManager {
     */
    public void finishProxyOp(@NonNull String op, int proxiedUid,
            @NonNull String proxiedPackageName, @Nullable String proxiedAttributionTag) {
        finishProxyOp(op, new AttributionSource(mContext.getAttributionSource(),
        IBinder token = mContext.getAttributionSource().getToken();
        finishProxyOp(token, op, new AttributionSource(mContext.getAttributionSource(),
                new AttributionSource(proxiedUid, proxiedPackageName,  proxiedAttributionTag,
                        mContext.getAttributionSource().getToken())), /*skipProxyOperation*/ false);
                        token)), /*skipProxyOperation*/ false);
    }

    /**
@@ -9280,10 +9283,11 @@ public class AppOpsManager {
     *
     * @hide
     */
    public void finishProxyOp(@NonNull String op, @NonNull AttributionSource attributionSource,
            boolean skipProxyOperation) {
    public void finishProxyOp(@NonNull IBinder clientId, @NonNull String op,
            @NonNull AttributionSource attributionSource, boolean skipProxyOperation) {
        try {
            mService.finishProxyOperation(strOpToOp(op), attributionSource, skipProxyOperation);
            mService.finishProxyOperation(clientId, strOpToOp(op), attributionSource,
                    skipProxyOperation);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+14 −9
Original line number Diff line number Diff line
@@ -26,13 +26,11 @@ import android.util.SparseArray;
import android.util.SparseIntArray;

import com.android.internal.app.IAppOpsCallback;
import com.android.internal.util.function.DecFunction;
import com.android.internal.util.function.HeptFunction;
import com.android.internal.util.function.HexFunction;
import com.android.internal.util.function.QuadFunction;
import com.android.internal.util.function.QuintConsumer;
import com.android.internal.util.function.QuintFunction;
import com.android.internal.util.function.TriFunction;
import com.android.internal.util.function.UndecFunction;

/**
@@ -135,6 +133,7 @@ public abstract class AppOpsManagerInternal {
        /**
         * Allows overriding start proxy operation behavior.
         *
         * @param clientId The client calling start, represented by an IBinder
         * @param code The op code to start.
         * @param attributionSource The permission identity of the caller.
         * @param startIfModeDefault Whether to start the op of the mode is default.
@@ -148,11 +147,12 @@ public abstract class AppOpsManagerInternal {
         * @param superImpl The super implementation.
         * @return The app op note result.
         */
        SyncNotedAppOp startProxyOperation(int code, @NonNull AttributionSource attributionSource,
                boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message,
                boolean shouldCollectMessage, boolean skipProxyOperation, @AttributionFlags
                int proxyAttributionFlags, @AttributionFlags int proxiedAttributionFlags,
                int attributionChainId, @NonNull DecFunction<Integer, AttributionSource, Boolean,
        SyncNotedAppOp startProxyOperation(@NonNull IBinder clientId, int code,
                @NonNull AttributionSource attributionSource, boolean startIfModeDefault,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean skipProxyOperation, @AttributionFlags int proxyAttributionFlags,
                @AttributionFlags int proxiedAttributionFlags, int attributionChainId,
                @NonNull UndecFunction<IBinder, Integer, AttributionSource, Boolean,
                        Boolean, String, Boolean, Boolean, Integer, Integer, Integer,
                        SyncNotedAppOp> superImpl);

@@ -176,10 +176,15 @@ public abstract class AppOpsManagerInternal {
         *
         * @param code The op code to finish.
         * @param attributionSource The permission identity of the caller.
         * @param skipProxyOperation Whether to skip the proxy in the proxy/proxied operation
         * @param clientId The client calling finishProxyOperation
         * @param superImpl The "standard" implementation to potentially call
         */
        void finishProxyOperation(int code, @NonNull AttributionSource attributionSource,
        void finishProxyOperation(@NonNull IBinder clientId, int code,
                @NonNull AttributionSource attributionSource,
                boolean skipProxyOperation,
                @NonNull TriFunction<Integer, AttributionSource, Boolean, Void> superImpl);
                @NonNull QuadFunction<IBinder, Integer, AttributionSource, Boolean,
                        Void> superImpl);
    }

    /**
+6 −5
Original line number Diff line number Diff line
@@ -58,11 +58,12 @@ interface IAppOpsService {
    SyncNotedAppOp noteProxyOperation(int code, in AttributionSource attributionSource,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
            boolean skipProxyOperation);
    SyncNotedAppOp startProxyOperation(int code, in AttributionSource attributionSource,
            boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message,
            boolean shouldCollectMessage, boolean skipProxyOperation, int proxyAttributionFlags,
            int proxiedAttributionFlags, int attributionChainId);
    void finishProxyOperation(int code, in AttributionSource attributionSource,
    SyncNotedAppOp startProxyOperation(IBinder clientId, int code,
            in AttributionSource attributionSource, boolean startIfModeDefault,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
            boolean skipProxyOperation, int proxyAttributionFlags, int proxiedAttributionFlags,
            int attributionChainId);
    void finishProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource,
            boolean skipProxyOperation);

    // Remaining methods are only used in Java.
+33 −28
Original line number Diff line number Diff line
@@ -368,12 +368,10 @@ import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.MemInfoReader;
import com.android.internal.util.Preconditions;
import com.android.internal.util.function.DecFunction;
import com.android.internal.util.function.HeptFunction;
import com.android.internal.util.function.HexFunction;
import com.android.internal.util.function.QuadFunction;
import com.android.internal.util.function.QuintFunction;
import com.android.internal.util.function.TriFunction;
import com.android.internal.util.function.UndecFunction;
import com.android.server.AlarmManagerInternal;
import com.android.server.DeviceIdleInternal;
@@ -3760,22 +3758,27 @@ public class ActivityManagerService extends IActivityManager.Stub
                            finishForceStopPackageLocked(packageName, appInfo.uid);
                        }
                    }
                    if (succeeded) {
                        final Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED,
                            Uri.fromParts("package", packageName, null));
                                Uri.fromParts("package", packageName, null /* fragment */));
                        intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                    intent.putExtra(Intent.EXTRA_UID, (appInfo != null) ? appInfo.uid : -1);
                        intent.putExtra(Intent.EXTRA_UID,
                                (appInfo != null) ? appInfo.uid : INVALID_UID);
                        intent.putExtra(Intent.EXTRA_USER_HANDLE, resolvedUserId);
                    final int[] visibilityAllowList =
                            mPackageManagerInt.getVisibilityAllowList(packageName, resolvedUserId);
                        if (isInstantApp) {
                            intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName);
                        broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent,
                                null, null, 0, null, null, permission.ACCESS_INSTANT_APPS, null,
                                false, false, resolvedUserId, false, null, visibilityAllowList);
                    } else {
                        broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent,
                                null, null, 0, null, null, null, null, false, false, resolvedUserId,
                                false, null, visibilityAllowList);
                        }
                        final int[] visibilityAllowList = mPackageManagerInt.getVisibilityAllowList(
                                packageName, resolvedUserId);
                        broadcastIntentInPackage("android", null /* featureId */, SYSTEM_UID,
                                uid, pid, intent, null /* resolvedType */, null /* resultTo */,
                                0 /* resultCode */, null /* resultData */, null /* resultExtras */,
                                isInstantApp ? permission.ACCESS_INSTANT_APPS : null,
                                null /* bOptions */, false /* serialized */, false /* sticky */,
                                resolvedUserId, false /* allowBackgroundActivityStarts */,
                                null /* backgroundActivityStartsToken */, visibilityAllowList);
                    }
                    if (observer != null) {
@@ -18275,19 +18278,20 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        @Override
        public SyncNotedAppOp startProxyOperation(int code,
        public SyncNotedAppOp startProxyOperation(@NonNull IBinder clientId, int code,
                @NonNull AttributionSource attributionSource, boolean startIfModeDefault,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean skipProxyOperation, @AttributionFlags int proxyAttributionFlags,
                @AttributionFlags int proxiedAttributionFlags, int attributionChainId,
                @NonNull DecFunction<Integer, AttributionSource, Boolean, Boolean, String, Boolean,
                        Boolean, Integer, Integer, Integer, SyncNotedAppOp> superImpl) {
                @NonNull UndecFunction<IBinder, Integer, AttributionSource,
                        Boolean, Boolean, String, Boolean, Boolean, Integer, Integer, Integer,
                        SyncNotedAppOp> superImpl) {
            if (attributionSource.getUid() == mTargetUid && isTargetOp(code)) {
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(
                        attributionSource.getUid()), Process.SHELL_UID);
                final long identity = Binder.clearCallingIdentity();
                try {
                    return superImpl.apply(code, new AttributionSource(shellUid,
                    return superImpl.apply(clientId, code, new AttributionSource(shellUid,
                            "com.android.shell", attributionSource.getAttributionTag(),
                            attributionSource.getToken(), attributionSource.getNext()),
                            startIfModeDefault, shouldCollectAsyncNotedOp, message,
@@ -18297,21 +18301,22 @@ public class ActivityManagerService extends IActivityManager.Stub
                    Binder.restoreCallingIdentity(identity);
                }
            }
            return superImpl.apply(code, attributionSource, startIfModeDefault,
            return superImpl.apply(clientId, code, attributionSource, startIfModeDefault,
                    shouldCollectAsyncNotedOp, message, shouldCollectMessage, skipProxyOperation,
                    proxyAttributionFlags, proxiedAttributionFlags, attributionChainId);
        }
        @Override
        public void finishProxyOperation(int code, @NonNull AttributionSource attributionSource,
                boolean skipProxyOperation, @NonNull TriFunction<Integer, AttributionSource,
                        Boolean, Void> superImpl) {
        public void finishProxyOperation(@NonNull IBinder clientId, int code,
                @NonNull AttributionSource attributionSource, boolean skipProxyOperation,
                @NonNull QuadFunction<IBinder, Integer, AttributionSource, Boolean,
                        Void> superImpl) {
            if (attributionSource.getUid() == mTargetUid && isTargetOp(code)) {
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(
                        attributionSource.getUid()), Process.SHELL_UID);
                final long identity = Binder.clearCallingIdentity();
                try {
                    superImpl.apply(code, new AttributionSource(shellUid,
                    superImpl.apply(clientId, code, new AttributionSource(shellUid,
                            "com.android.shell", attributionSource.getAttributionTag(),
                            attributionSource.getToken(), attributionSource.getNext()),
                            skipProxyOperation);
@@ -18319,7 +18324,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    Binder.restoreCallingIdentity(identity);
                }
            }
            superImpl.apply(code, attributionSource, skipProxyOperation);
            superImpl.apply(clientId, code, attributionSource, skipProxyOperation);
        }
        private boolean isTargetOp(int code) {
Loading