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

Commit e53d4fb3 authored by Karishma Vakil's avatar Karishma Vakil
Browse files

[DeviceAware] Re-add proxy methods taking AttributionSource in

AppOpsService.aidl.

This is a follow up on ag/24622058, in light of some methods being mentioned in
hiddenapi-unsupported.txt.

Bug: 299160174
Test: atest CtsAppOpsTestCases CtsAppOps2TestCases
Change-Id: I8ff5f740f178111fd56bd270c73c1f255fa59a96
parent 9dd18822
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -8638,8 +8638,8 @@ public class AppOpsManager {
                }
            }

            SyncNotedAppOp syncOp = mService.noteProxyOperation(op, attributionSource.asState(),
                    collectionMode == COLLECT_ASYNC, message,
            SyncNotedAppOp syncOp = mService.noteProxyOperationWithState(op,
                    attributionSource.asState(), collectionMode == COLLECT_ASYNC, message,
                    shouldCollectMessage, skipProxyOperation);

            if (syncOp.getOpMode() == MODE_ALLOWED) {
@@ -9110,7 +9110,7 @@ public class AppOpsManager {
                }
            }

            SyncNotedAppOp syncOp = mService.startProxyOperation(clientId, op,
            SyncNotedAppOp syncOp = mService.startProxyOperationWithState(clientId, op,
                    attributionSource.asState(), false, collectionMode == COLLECT_ASYNC, message,
                    shouldCollectMessage, skipProxyOperation, proxyAttributionFlags,
                    proxiedAttributionFlags, attributionChainId);
@@ -9229,8 +9229,8 @@ public class AppOpsManager {
    public void finishProxyOp(@NonNull IBinder clientId, @NonNull String op,
            @NonNull AttributionSource attributionSource, boolean skipProxyOperation) {
        try {
            mService.finishProxyOperation(clientId, strOpToOp(op), attributionSource.asState(),
                    skipProxyOperation);
            mService.finishProxyOperationWithState(
                    clientId, strOpToOp(op), attributionSource.asState(), skipProxyOperation);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+32 −13
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.AppOpsManager;
import android.app.AsyncNotedAppOp;
import android.app.SyncNotedAppOp;
import android.app.RuntimeAppOpAccessMessage;
import android.content.AttributionSource;
import android.content.AttributionSourceState;
import android.content.pm.ParceledListSlice;
import android.os.Bundle;
@@ -32,10 +33,17 @@ import com.android.internal.app.IAppOpsNotedCallback;
import com.android.internal.app.IAppOpsStartedCallback;
import com.android.internal.app.MessageSamplingConfig;

// AppOpsService AIDL interface.
// PLEASE READ BEFORE MODIFYING THIS FILE.
// Some methods in this interface or their transaction codes are mentioned in
// frameworks/base/boot/hiddenapi/hiddenapi-unsupported.txt, meaning that we cannot change their
// signature or ordering as they may be used by 3p apps.
// Also, some methods are mentioned in native code, meaning that the numbering in
// frameworks/native/libs/permission/include/binder/IAppOpsService.h must match the order here.
// Please be careful to respect both these issues when modifying this file.
interface IAppOpsService {
    // These methods are also called by native code, so must
    // be kept in sync with frameworks/native/libs/permission/include/binder/IAppOpsService.h
    // and not be reordered
    // These methods are also called by native code, so please be careful that the number in
    // frameworks/native/libs/permission/include/binder/IAppOpsService.h matches the ordering here.
    int checkOperation(int code, int uid, String packageName);
    SyncNotedAppOp noteOperation(int code, int uid, String packageName, @nullable String attributionTag,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage);
@@ -54,21 +62,21 @@ interface IAppOpsService {
    void setCameraAudioRestriction(int mode);
    void startWatchingModeWithFlags(int op, String packageName, int flags,
            IAppOpsCallback callback);
    // End of methods also called by native code.
    // Any new method exposed to native must be added after the last one, do not reorder

    SyncNotedAppOp noteProxyOperation(int code, in AttributionSourceState attributionSourceState,
    // End of methods also called by native code (there may be more blocks like this of native
    // methods later in this file).
    // Deprecated, use noteProxyOperationWithState instead.
    SyncNotedAppOp noteProxyOperation(int code, in AttributionSource attributionSource,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
            boolean skipProxyOperation);
    // Deprecated, use startProxyOperationWithState instead.
    SyncNotedAppOp startProxyOperation(IBinder clientId, int code,
            in AttributionSourceState attributionSourceState, boolean startIfModeDefault,
            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 AttributionSourceState attributionSourceState, boolean skipProxyOperation);

    // Remaining methods are only used in Java.
    // Deprecated, use finishProxyOperationWithState instead.
    void finishProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource,
            boolean skipProxyOperation);
    int checkPackage(int uid, String packageName);
    RuntimeAppOpAccessMessage collectRuntimeAppOpAccessMessage();
    MessageSamplingConfig reportRuntimeAppOpAccessMessageAndGetConfig(String packageName,
@@ -127,8 +135,19 @@ interface IAppOpsService {
    List<AsyncNotedAppOp> extractAsyncOps(String packageName);

    int checkOperationRaw(int code, int uid, String packageName, @nullable String attributionTag);

    void reloadNonHistoricalState();

    void collectNoteOpCallsForValidation(String stackTrace, int op, String packageName, long version);

    SyncNotedAppOp noteProxyOperationWithState(int code,
                in AttributionSourceState attributionSourceStateState,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean skipProxyOperation);
    SyncNotedAppOp startProxyOperationWithState(IBinder clientId, int code,
                in AttributionSourceState attributionSourceStateState, boolean startIfModeDefault,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean skipProxyOperation, int proxyAttributionFlags, int proxiedAttributionFlags,
                int attributionChainId);
    void finishProxyOperationWithState(IBinder clientId, int code,
                in AttributionSourceState attributionSourceStateState, boolean skipProxyOperation);
}
+30 −0
Original line number Diff line number Diff line
@@ -2680,8 +2680,17 @@ public class AppOpsService extends IAppOpsService.Stub {
                .filterAppAccess(packageName, callingUid, userId);
    }

    /** @deprecated Use {@link #noteProxyOperationWithState} instead. */
    @Override
    public SyncNotedAppOp noteProxyOperation(int code,
            AttributionSource attributionSource, boolean shouldCollectAsyncNotedOp,
            String message, boolean shouldCollectMessage, boolean skipProxyOperation) {
        return mCheckOpsDelegateDispatcher.noteProxyOperation(code, attributionSource,
                shouldCollectAsyncNotedOp, message, shouldCollectMessage, skipProxyOperation);
    }

    @Override
    public SyncNotedAppOp noteProxyOperationWithState(int code,
            AttributionSourceState attributionSourceState, boolean shouldCollectAsyncNotedOp,
            String message, boolean shouldCollectMessage, boolean skipProxyOperation) {
        AttributionSource attributionSource = new AttributionSource(attributionSourceState);
@@ -3212,8 +3221,21 @@ public class AppOpsService extends IAppOpsService.Stub {
                attributionChainId);
    }

    /** @deprecated Use {@link #startProxyOperationWithState} instead. */
    @Override
    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) {
        return mCheckOpsDelegateDispatcher.startProxyOperation(clientId, code, attributionSource,
                startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage,
                skipProxyOperation, proxyAttributionFlags, proxiedAttributionFlags,
                attributionChainId);
    }

    @Override
    public SyncNotedAppOp startProxyOperationWithState(@NonNull IBinder clientId, int code,
            @NonNull AttributionSourceState attributionSourceState, boolean startIfModeDefault,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
            boolean skipProxyOperation, @AttributionFlags int proxyAttributionFlags,
@@ -3513,8 +3535,16 @@ public class AppOpsService extends IAppOpsService.Stub {
        finishOperationUnchecked(clientId, code, uid, resolvedPackageName, attributionTag);
    }

    /** @deprecated Use {@link #finishProxyOperationWithState} instead. */
    @Override
    public void finishProxyOperation(@NonNull IBinder clientId, int code,
            @NonNull AttributionSource attributionSource, boolean skipProxyOperation) {
        mCheckOpsDelegateDispatcher.finishProxyOperation(clientId, code, attributionSource,
                skipProxyOperation);
    }

    @Override
    public void finishProxyOperationWithState(@NonNull IBinder clientId, int code,
            @NonNull AttributionSourceState attributionSourceState, boolean skipProxyOperation) {
        AttributionSource attributionSource = new AttributionSource(attributionSourceState);
        mCheckOpsDelegateDispatcher.finishProxyOperation(clientId, code, attributionSource,