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

Commit 385d3899 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Make note/startOperation return SyncNotedAppOp, add mode" into sc-dev am: 0751e1b1

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

Change-Id: I9236a6abd710e5847f332cab5caa115ae1fa6f33
parents 9193412b 0751e1b1
Loading
Loading
Loading
Loading
+29 −30
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
import android.compat.annotation.EnabledAfter;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.AttributionSource;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
@@ -50,7 +51,6 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.content.AttributionSource;
import android.os.Process;
import android.os.Process;
import android.os.RemoteCallback;
import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -8029,18 +8029,18 @@ public class AppOpsManager {
                }
                }
            }
            }


            int mode = mService.noteOperation(op, uid, packageName, attributionTag,
            SyncNotedAppOp syncOp = mService.noteOperation(op, uid, packageName, attributionTag,
                    collectionMode == COLLECT_ASYNC, message, shouldCollectMessage);
                    collectionMode == COLLECT_ASYNC, message, shouldCollectMessage);


            if (mode == MODE_ALLOWED) {
            if (syncOp.getOpMode()== MODE_ALLOWED) {
                if (collectionMode == COLLECT_SELF) {
                if (collectionMode == COLLECT_SELF) {
                    collectNotedOpForSelf(op, attributionTag);
                    collectNotedOpForSelf(syncOp);
                } else if (collectionMode == COLLECT_SYNC) {
                } else if (collectionMode == COLLECT_SYNC) {
                    collectNotedOpSync(op, attributionTag);
                    collectNotedOpSync(syncOp);
                }
                }
            }
            }


            return mode;
            return syncOp.getOpMode();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -8197,23 +8197,23 @@ public class AppOpsManager {
                }
                }
            }
            }


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


            if (mode == MODE_ALLOWED) {
            if (syncOp.getOpMode() == MODE_ALLOWED) {
                if (collectionMode == COLLECT_SELF) {
                if (collectionMode == COLLECT_SELF) {
                    collectNotedOpForSelf(op, attributionSource.getNextAttributionTag());
                    collectNotedOpForSelf(syncOp);
                } else if (collectionMode == COLLECT_SYNC
                } else if (collectionMode == COLLECT_SYNC
                        // Only collect app-ops when the proxy is trusted
                        // Only collect app-ops when the proxy is trusted
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        myUid) == PackageManager.PERMISSION_GRANTED ||
                        myUid) == PackageManager.PERMISSION_GRANTED ||
                            Binder.getCallingUid() == attributionSource.getNextUid())) {
                            Binder.getCallingUid() == attributionSource.getNextUid())) {
                    collectNotedOpSync(op, attributionSource.getNextAttributionTag());
                    collectNotedOpSync(syncOp);
                }
                }
            }
            }


            return mode;
            return syncOp.getOpMode();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -8510,19 +8510,19 @@ public class AppOpsManager {
                }
                }
            }
            }


            int mode = mService.startOperation(getClientId(), op, uid, packageName,
            SyncNotedAppOp syncOp = mService.startOperation(getClientId(), op, uid, packageName,
                    attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message,
                    attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message,
                    shouldCollectMessage);
                    shouldCollectMessage);


            if (mode == MODE_ALLOWED) {
            if (syncOp.getOpMode() == MODE_ALLOWED) {
                if (collectionMode == COLLECT_SELF) {
                if (collectionMode == COLLECT_SELF) {
                    collectNotedOpForSelf(op, attributionTag);
                    collectNotedOpForSelf(syncOp);
                } else if (collectionMode == COLLECT_SYNC) {
                } else if (collectionMode == COLLECT_SYNC) {
                    collectNotedOpSync(op, attributionTag);
                    collectNotedOpSync(syncOp);
                }
                }
            }
            }


            return mode;
            return syncOp.getOpMode();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -8625,24 +8625,23 @@ public class AppOpsManager {
                }
                }
            }
            }


            int mode = mService.startProxyOperation(getClientId(), op,
            SyncNotedAppOp syncOp = mService.startProxyOperation(getClientId(), op,
                    attributionSource, false, collectionMode == COLLECT_ASYNC, message,
                    attributionSource, false, collectionMode == COLLECT_ASYNC, message,
                    shouldCollectMessage, skipProxyOperation);
                    shouldCollectMessage, skipProxyOperation);


            if (mode == MODE_ALLOWED) {
            if (syncOp.getOpMode() == MODE_ALLOWED) {
                if (collectionMode == COLLECT_SELF) {
                if (collectionMode == COLLECT_SELF) {
                    collectNotedOpForSelf(op,
                    collectNotedOpForSelf(syncOp);
                            attributionSource.getNextAttributionTag());
                } else if (collectionMode == COLLECT_SYNC
                } else if (collectionMode == COLLECT_SYNC
                        // Only collect app-ops when the proxy is trusted
                        // Only collect app-ops when the proxy is trusted
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        Process.myUid()) == PackageManager.PERMISSION_GRANTED
                        Process.myUid()) == PackageManager.PERMISSION_GRANTED
                        || Binder.getCallingUid() == attributionSource.getNextUid())) {
                        || Binder.getCallingUid() == attributionSource.getNextUid())) {
                    collectNotedOpSync(op, attributionSource.getNextAttributionTag());
                    collectNotedOpSync(syncOp);
                }
                }
            }
            }


            return mode;
            return syncOp.getOpMode();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -8883,13 +8882,13 @@ public class AppOpsManager {
     * @param op The noted op
     * @param op The noted op
     * @param attributionTag The attribution tag the op is noted for
     * @param attributionTag The attribution tag the op is noted for
     */
     */
    private void collectNotedOpForSelf(int op, @Nullable String attributionTag) {
    private void collectNotedOpForSelf(SyncNotedAppOp syncOp) {
        synchronized (sLock) {
        synchronized (sLock) {
            if (sOnOpNotedCallback != null) {
            if (sOnOpNotedCallback != null) {
                sOnOpNotedCallback.onSelfNoted(new SyncNotedAppOp(op, attributionTag));
                sOnOpNotedCallback.onSelfNoted(syncOp);
            }
            }
        }
        }
        sMessageCollector.onSelfNoted(new SyncNotedAppOp(op, attributionTag));
        sMessageCollector.onSelfNoted(syncOp);
    }
    }


    /**
    /**
@@ -8897,23 +8896,23 @@ public class AppOpsManager {
     *
     *
     * <p> Delivered to caller via {@link #prefixParcelWithAppOpsIfNeeded}
     * <p> Delivered to caller via {@link #prefixParcelWithAppOpsIfNeeded}
     *
     *
     * @param op The noted op
     * @param syncOp the op and attribution tag to note for
     * @param attributionTag The attribution tag the op is noted for
     */
     */
    private void collectNotedOpSync(int op, @Nullable String attributionTag) {
    private void collectNotedOpSync(@NonNull SyncNotedAppOp syncOp) {
        // If this is inside of a two-way binder call:
        // If this is inside of a two-way binder call:
        // We are inside of a two-way binder call. Delivered to caller via
        // We are inside of a two-way binder call. Delivered to caller via
        // {@link #prefixParcelWithAppOpsIfNeeded}
        // {@link #prefixParcelWithAppOpsIfNeeded}
        int op = sOpStrToOp.get(syncOp.getOp());
        ArrayMap<String, long[]> appOpsNoted = sAppOpsNotedInThisBinderTransaction.get();
        ArrayMap<String, long[]> appOpsNoted = sAppOpsNotedInThisBinderTransaction.get();
        if (appOpsNoted == null) {
        if (appOpsNoted == null) {
            appOpsNoted = new ArrayMap<>(1);
            appOpsNoted = new ArrayMap<>(1);
            sAppOpsNotedInThisBinderTransaction.set(appOpsNoted);
            sAppOpsNotedInThisBinderTransaction.set(appOpsNoted);
        }
        }


        long[] appOpsNotedForAttribution = appOpsNoted.get(attributionTag);
        long[] appOpsNotedForAttribution = appOpsNoted.get(syncOp.getAttributionTag());
        if (appOpsNotedForAttribution == null) {
        if (appOpsNotedForAttribution == null) {
            appOpsNotedForAttribution = new long[2];
            appOpsNotedForAttribution = new long[2];
            appOpsNoted.put(attributionTag, appOpsNotedForAttribution);
            appOpsNoted.put(syncOp.getAttributionTag(), appOpsNotedForAttribution);
        }
        }


        if (op < 64) {
        if (op < 64) {
+6 −6
Original line number Original line Diff line number Diff line
@@ -76,11 +76,11 @@ public abstract class AppOpsManagerInternal {
         * @param superImpl The super implementation.
         * @param superImpl The super implementation.
         * @return The app op note result.
         * @return The app op note result.
         */
         */
        int noteOperation(int code, int uid, @Nullable String packageName,
        SyncNotedAppOp noteOperation(int code, int uid, @Nullable String packageName,
                @Nullable String featureId, boolean shouldCollectAsyncNotedOp,
                @Nullable String featureId, boolean shouldCollectAsyncNotedOp,
                @Nullable String message, boolean shouldCollectMessage,
                @Nullable String message, boolean shouldCollectMessage,
                @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean,
                @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean,
                        Integer> superImpl);
                        SyncNotedAppOp> superImpl);


        /**
        /**
         * Allows overriding note proxy operation behavior.
         * Allows overriding note proxy operation behavior.
@@ -94,11 +94,11 @@ public abstract class AppOpsManagerInternal {
         * @param superImpl The super implementation.
         * @param superImpl The super implementation.
         * @return The app op note result.
         * @return The app op note result.
         */
         */
        int noteProxyOperation(int code, @NonNull AttributionSource attributionSource,
        SyncNotedAppOp noteProxyOperation(int code, @NonNull AttributionSource attributionSource,
                boolean shouldCollectAsyncNotedOp, @Nullable String message,
                boolean shouldCollectAsyncNotedOp, @Nullable String message,
                boolean shouldCollectMessage, boolean skipProxyOperation,
                boolean shouldCollectMessage, boolean skipProxyOperation,
                @NonNull HexFunction<Integer, AttributionSource, Boolean, String, Boolean,
                @NonNull HexFunction<Integer, AttributionSource, Boolean, String, Boolean,
                        Boolean, Integer> superImpl);
                        Boolean, SyncNotedAppOp> superImpl);


        /**
        /**
         * Allows overriding start proxy operation behavior.
         * Allows overriding start proxy operation behavior.
@@ -113,12 +113,12 @@ public abstract class AppOpsManagerInternal {
         * @param superImpl The super implementation.
         * @param superImpl The super implementation.
         * @return The app op note result.
         * @return The app op note result.
         */
         */
        int startProxyOperation(IBinder token, int code,
        SyncNotedAppOp startProxyOperation(IBinder token, int code,
                @NonNull AttributionSource attributionSource, boolean startIfModeDefault,
                @NonNull AttributionSource attributionSource, boolean startIfModeDefault,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean skipProxyOperation, @NonNull OctFunction<IBinder, Integer,
                boolean skipProxyOperation, @NonNull OctFunction<IBinder, Integer,
                        AttributionSource, Boolean, Boolean, String, Boolean, Boolean,
                        AttributionSource, Boolean, Boolean, String, Boolean, Boolean,
                        Integer> superImpl);
                        SyncNotedAppOp> superImpl);


        /**
        /**
         * Allows overriding finish proxy op.
         * Allows overriding finish proxy op.
+43 −16
Original line number Original line Diff line number Diff line
@@ -34,18 +34,36 @@ import com.android.internal.util.DataClass;
 * itself}.
 * itself}.
 */
 */
@Immutable
@Immutable
/*@DataClass(
@DataClass(
        genEqualsHashCode = true,
        genEqualsHashCode = true,
        genAidl = true,
        genConstructor = false
        genConstructor = false
)
)
@DataClass.Suppress("getOpCode")*/
@DataClass.Suppress({"getOpCode", "getOpMode"})
public final class SyncNotedAppOp implements Parcelable {
public final class SyncNotedAppOp implements Parcelable {


    /** mode returned by the system on a call to note/startOp, if applicable */
    private final int mOpMode;
    /** op code of synchronous appop noted */
    /** op code of synchronous appop noted */
    private final @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int mOpCode;
    private final @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int mOpCode;
    /** attributionTag of synchronous appop noted */
    /** attributionTag of synchronous appop noted */
    private final @Nullable String mAttributionTag;
    private final @Nullable String mAttributionTag;


    /**
     * Native code relies on parcel ordering, do not change
     * @hide
     */
    public SyncNotedAppOp(int opMode, @IntRange(from = 0L) int opCode,
            @Nullable String attributionTag) {
        this.mOpCode = opCode;
        com.android.internal.util.AnnotationValidations.validate(
                IntRange.class, null, mOpCode,
                "from", 0,
                "to", AppOpsManager._NUM_OP - 1);
        this.mAttributionTag = attributionTag;
        this.mOpMode = opMode;
    }

    /**
    /**
     * Creates a new SyncNotedAppOp.
     * Creates a new SyncNotedAppOp.
     *
     *
@@ -55,12 +73,7 @@ public final class SyncNotedAppOp implements Parcelable {
     *   attributionTag of synchronous appop noted
     *   attributionTag of synchronous appop noted
     */
     */
    public SyncNotedAppOp(@IntRange(from = 0L) int opCode, @Nullable String attributionTag) {
    public SyncNotedAppOp(@IntRange(from = 0L) int opCode, @Nullable String attributionTag) {
        this.mOpCode = opCode;
        this(AppOpsManager.MODE_IGNORED, opCode, attributionTag);
        com.android.internal.util.AnnotationValidations.validate(
                IntRange.class, null, mOpCode,
                "from", 0,
                "to", AppOpsManager._NUM_OP - 1);
        this.mAttributionTag = attributionTag;
    }
    }


    /**
    /**
@@ -70,7 +83,16 @@ public final class SyncNotedAppOp implements Parcelable {
        return AppOpsManager.opToPublicName(mOpCode);
        return AppOpsManager.opToPublicName(mOpCode);
    }
    }


    // Code below generated by codegen v1.0.14.
    /**
     * @hide
     */
    public int getOpMode() {
        return mOpMode;
    }



    // Code below generated by codegen v1.0.23.
    //
    //
    // DO NOT MODIFY!
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    // CHECKSTYLE:OFF Generated code
@@ -104,6 +126,7 @@ public final class SyncNotedAppOp implements Parcelable {
        SyncNotedAppOp that = (SyncNotedAppOp) o;
        SyncNotedAppOp that = (SyncNotedAppOp) o;
        //noinspection PointlessBooleanExpression
        //noinspection PointlessBooleanExpression
        return true
        return true
                && mOpMode == that.mOpMode
                && mOpCode == that.mOpCode
                && mOpCode == that.mOpCode
                && java.util.Objects.equals(mAttributionTag, that.mAttributionTag);
                && java.util.Objects.equals(mAttributionTag, that.mAttributionTag);
    }
    }
@@ -115,6 +138,7 @@ public final class SyncNotedAppOp implements Parcelable {
        // int fieldNameHashCode() { ... }
        // int fieldNameHashCode() { ... }


        int _hash = 1;
        int _hash = 1;
        _hash = 31 * _hash + mOpMode;
        _hash = 31 * _hash + mOpCode;
        _hash = 31 * _hash + mOpCode;
        _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag);
        _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag);
        return _hash;
        return _hash;
@@ -127,8 +151,9 @@ public final class SyncNotedAppOp implements Parcelable {
        // void parcelFieldName(Parcel dest, int flags) { ... }
        // void parcelFieldName(Parcel dest, int flags) { ... }


        byte flg = 0;
        byte flg = 0;
        if (mAttributionTag != null) flg |= 0x2;
        if (mAttributionTag != null) flg |= 0x4;
        dest.writeByte(flg);
        dest.writeByte(flg);
        dest.writeInt(mOpMode);
        dest.writeInt(mOpCode);
        dest.writeInt(mOpCode);
        if (mAttributionTag != null) dest.writeString(mAttributionTag);
        if (mAttributionTag != null) dest.writeString(mAttributionTag);
    }
    }
@@ -145,13 +170,15 @@ public final class SyncNotedAppOp implements Parcelable {
        // static FieldType unparcelFieldName(Parcel in) { ... }
        // static FieldType unparcelFieldName(Parcel in) { ... }


        byte flg = in.readByte();
        byte flg = in.readByte();
        int opMode = in.readInt();
        int opCode = in.readInt();
        int opCode = in.readInt();
        String attributionTag = (flg & 0x2) == 0 ? null : in.readString();
        String attributionTag = (flg & 0x4) == 0 ? null : in.readString();


        this.mOpMode = opMode;
        this.mOpCode = opCode;
        this.mOpCode = opCode;
        com.android.internal.util.AnnotationValidations.validate(
        com.android.internal.util.AnnotationValidations.validate(
                IntRange.class, null, mOpCode,
                IntRange.class, null, mOpCode,
                "from", 0,
                "from", 0L,
                "to", AppOpsManager._NUM_OP - 1);
                "to", AppOpsManager._NUM_OP - 1);
        this.mAttributionTag = attributionTag;
        this.mAttributionTag = attributionTag;


@@ -172,11 +199,11 @@ public final class SyncNotedAppOp implements Parcelable {
        }
        }
    };
    };


    /*@DataClass.Generated(
    @DataClass.Generated(
            time = 1579188889960L,
            time = 1617317997768L,
            codegenVersion = "1.0.14",
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/app/SyncNotedAppOp.java",
            sourceFile = "frameworks/base/core/java/android/app/SyncNotedAppOp.java",
            inputSignatures = "private final @android.annotation.IntRange(from=0L, to=AppOpsManager._NUM_OP - 1) int mOpCode\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\npublic @android.annotation.NonNull java.lang.String getOp()\npublic @android.annotation.SystemApi int getOpCode()\nclass SyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genConstructor=false)")*/
            inputSignatures = "private final  int mOpMode\nprivate final @android.annotation.IntRange int mOpCode\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\npublic @android.annotation.NonNull java.lang.String getOp()\npublic  int getOpMode()\nclass SyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genAidl=true, genConstructor=false)")
    @Deprecated
    @Deprecated
    private void __metadata() {}
    private void __metadata() {}


+4 −4
Original line number Original line Diff line number Diff line
@@ -36,9 +36,9 @@ interface IAppOpsService {
    // be kept in sync with frameworks/native/libs/binder/include/binder/IAppOpsService.h
    // be kept in sync with frameworks/native/libs/binder/include/binder/IAppOpsService.h
    // and not be reordered
    // and not be reordered
    int checkOperation(int code, int uid, String packageName);
    int checkOperation(int code, int uid, String packageName);
    int noteOperation(int code, int uid, String packageName, @nullable String attributionTag,
    SyncNotedAppOp noteOperation(int code, int uid, String packageName, @nullable String attributionTag,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage);
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage);
    int startOperation(IBinder clientId, int code, int uid, String packageName,
    SyncNotedAppOp startOperation(IBinder clientId, int code, int uid, String packageName,
            @nullable String attributionTag, boolean startIfModeDefault,
            @nullable String attributionTag, boolean startIfModeDefault,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage);
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage);
    @UnsupportedAppUsage
    @UnsupportedAppUsage
@@ -53,10 +53,10 @@ interface IAppOpsService {
    // End of methods also called by native code.
    // End of methods also called by native code.
    // Any new method exposed to native must be added after the last one, do not reorder
    // Any new method exposed to native must be added after the last one, do not reorder


    int noteProxyOperation(int code, in AttributionSource attributionSource,
    SyncNotedAppOp noteProxyOperation(int code, in AttributionSource attributionSource,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
            boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
            boolean skipProxyOperation);
            boolean skipProxyOperation);
    int startProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource,
    SyncNotedAppOp startProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource,
            boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message,
            boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message,
            boolean shouldCollectMessage, boolean skipProxyOperation);
            boolean shouldCollectMessage, boolean skipProxyOperation);
    void finishProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource);
    void finishProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource);
+11 −11
Original line number Original line Diff line number Diff line
@@ -179,6 +179,7 @@ import android.app.PendingIntent;
import android.app.ProcessMemoryState;
import android.app.ProcessMemoryState;
import android.app.ProfilerInfo;
import android.app.ProfilerInfo;
import android.app.PropertyInvalidatedCache;
import android.app.PropertyInvalidatedCache;
import android.app.SyncNotedAppOp;
import android.app.WaitResult;
import android.app.WaitResult;
import android.app.backup.BackupManager.OperationType;
import android.app.backup.BackupManager.OperationType;
import android.app.backup.IBackupManager;
import android.app.backup.IBackupManager;
@@ -344,7 +345,6 @@ import com.android.internal.util.function.HeptFunction;
import com.android.internal.util.function.HexFunction;
import com.android.internal.util.function.HexFunction;
import com.android.internal.util.function.OctFunction;
import com.android.internal.util.function.OctFunction;
import com.android.internal.util.function.QuadFunction;
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.TriFunction;
import com.android.server.AlarmManagerInternal;
import com.android.server.AlarmManagerInternal;
import com.android.server.DeviceIdleInternal;
import com.android.server.DeviceIdleInternal;
@@ -2744,7 +2744,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    private boolean hasUsageStatsPermission(String callingPackage) {
    private boolean hasUsageStatsPermission(String callingPackage) {
        final int mode = mAppOpsService.noteOperation(AppOpsManager.OP_GET_USAGE_STATS,
        final int mode = mAppOpsService.noteOperation(AppOpsManager.OP_GET_USAGE_STATS,
                Binder.getCallingUid(), callingPackage, null, false, "", false);
                Binder.getCallingUid(), callingPackage, null, false, "", false).getOpMode();
        if (mode == AppOpsManager.MODE_DEFAULT) {
        if (mode == AppOpsManager.MODE_DEFAULT) {
            return checkCallingPermission(Manifest.permission.PACKAGE_USAGE_STATS)
            return checkCallingPermission(Manifest.permission.PACKAGE_USAGE_STATS)
                    == PackageManager.PERMISSION_GRANTED;
                    == PackageManager.PERMISSION_GRANTED;
@@ -5244,7 +5244,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            // TODO moltmann: Allow to specify featureId
            // TODO moltmann: Allow to specify featureId
            return mActivityManagerService.mAppOpsService
            return mActivityManagerService.mAppOpsService
                    .noteOperation(AppOpsManager.strOpToOp(op), uid, packageName, null,
                    .noteOperation(AppOpsManager.strOpToOp(op), uid, packageName, null,
                            false, "", false);
                            false, "", false).getOpMode();
        }
        }
        @Override
        @Override
@@ -16606,11 +16606,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        }
        @Override
        @Override
        public int noteOperation(int code, int uid, @Nullable String packageName,
        public SyncNotedAppOp noteOperation(int code, int uid, @Nullable String packageName,
                @Nullable String featureId, boolean shouldCollectAsyncNotedOp,
                @Nullable String featureId, boolean shouldCollectAsyncNotedOp,
                @Nullable String message, boolean shouldCollectMessage,
                @Nullable String message, boolean shouldCollectMessage,
                @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean,
                @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean,
                        Integer> superImpl) {
                        SyncNotedAppOp> superImpl) {
            if (uid == mTargetUid && isTargetOp(code)) {
            if (uid == mTargetUid && isTargetOp(code)) {
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(uid),
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(uid),
                        Process.SHELL_UID);
                        Process.SHELL_UID);
@@ -16627,11 +16627,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        }
        @Override
        @Override
        public int noteProxyOperation(int code, @NonNull AttributionSource attributionSource,
        public SyncNotedAppOp noteProxyOperation(int code,
                boolean shouldCollectAsyncNotedOp, @Nullable String message,
                @NonNull AttributionSource attributionSource, boolean shouldCollectAsyncNotedOp,
                boolean shouldCollectMessage, boolean skiProxyOperation,
                @Nullable String message, boolean shouldCollectMessage, boolean skiProxyOperation,
                @NonNull HexFunction<Integer, AttributionSource, Boolean, String, Boolean,
                @NonNull HexFunction<Integer, AttributionSource, Boolean, String, Boolean,
                                Boolean, Integer> superImpl) {
                                Boolean, SyncNotedAppOp> superImpl) {
            if (attributionSource.getUid() == mTargetUid && isTargetOp(code)) {
            if (attributionSource.getUid() == mTargetUid && isTargetOp(code)) {
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(
                        attributionSource.getUid()), Process.SHELL_UID);
                        attributionSource.getUid()), Process.SHELL_UID);
@@ -16651,12 +16651,12 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        }
        @Override
        @Override
        public int startProxyOperation(IBinder token, int code,
        public SyncNotedAppOp startProxyOperation(IBinder token, int code,
                @NonNull AttributionSource attributionSource, boolean startIfModeDefault,
                @NonNull AttributionSource attributionSource, boolean startIfModeDefault,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
                boolean skipProsyOperation, @NonNull OctFunction<IBinder, Integer,
                boolean skipProsyOperation, @NonNull OctFunction<IBinder, Integer,
                        AttributionSource, Boolean, Boolean, String, Boolean, Boolean,
                        AttributionSource, Boolean, Boolean, String, Boolean, Boolean,
                        Integer> superImpl) {
                        SyncNotedAppOp> superImpl) {
            if (attributionSource.getUid() == mTargetUid && isTargetOp(code)) {
            if (attributionSource.getUid() == mTargetUid && isTargetOp(code)) {
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(
                final int shellUid = UserHandle.getUid(UserHandle.getUserId(
                        attributionSource.getUid()), Process.SHELL_UID);
                        attributionSource.getUid()), Process.SHELL_UID);
Loading