Class ShadowAppOpsManager

    • Constructor Detail

      • ShadowAppOpsManager

        public ShadowAppOpsManager()
    • Method Detail

      • __constructor__

        @Implementation(minSdk=19)
        protected void __constructor__​(Context context,
                                       com.android.internal.app.IAppOpsService service)
      • __staticInitializer__

        @Implementation(minSdk=19)
        protected static void __staticInitializer__()
      • setMode

        @Implementation(minSdk=28)
        @HiddenApi
        public void setMode​(String op,
                            int uid,
                            String packageName,
                            int mode)
        Change the operating mode for the given op in the given app package. You must pass in both the uid and name of the application whose mode is being modified; if these do not match, the modification will not be applied.

        This method is public for testing checkOpNoThrow(java.lang.String, int, java.lang.String). If checkOpNoThrow(java.lang.String, int, java.lang.String) is called afterwards with the op, ui, and packageName provided, it will return the mode set here.

        Parameters:
        op - The operation to modify. One of the OPSTR_* constants.
        uid - The user id of the application whose mode will be changed.
        packageName - The name of the application package name whose mode will be changed.
      • getPackagesForOps

        @Implementation(minSdk=29)
        @HiddenApi
        protected List<AppOpsManager.PackageOps> getPackagesForOps​(String[] ops)
        Returns app op details for all packages for which one of setMode(java.lang.String, int, java.lang.String, int) methods was used to set the value of one of the given app ops (it does return those set to 'default' mode, while the true implementation usually doesn't). Also, we don't enforce any permission checks which might be needed in the true implementation.
        Parameters:
        ops - The set of operations you are interested in, or null if you want all of them.
        Returns:
        app ops information about each package, containing only ops that were specified as an argument
      • getPackagesForOps

        @Implementation(minSdk=19)
        @HiddenApi
        protected List<AppOpsManager.PackageOps> getPackagesForOps​(int[] ops)
        Returns app op details for all packages for which one of setMode(java.lang.String, int, java.lang.String, int) methods was used to set the value of one of the given app ops (it does return those set to 'default' mode, while the true implementation usually doesn't). Also, we don't enforce any permission checks which might be needed in the true implementation.
        Parameters:
        ops - The set of operations you are interested in, or null if you want all of them.
        Returns:
        app ops information about each package, containing only ops that were specified as an argument
      • unsafeCheckOpNoThrow

        @Implementation(minSdk=29)
        public int unsafeCheckOpNoThrow​(String op,
                                        int uid,
                                        String packageName)
      • startOp

        @Implementation(minSdk=30)
        protected int startOp​(String op,
                              int uid,
                              String packageName,
                              String attributionTag,
                              String message)
        Stores a fake long-running operation. It does not throw if a wrong uid is passed.
      • startOpNoThrow

        @Implementation(minSdk=19,
                        maxSdk=29)
        protected int startOpNoThrow​(int op,
                                     int uid,
                                     String packageName)
        Stores a fake long-running operation. It does not throw if a wrong uid is passed.
      • startOpNoThrow

        @Implementation(minSdk=30)
        protected int startOpNoThrow​(String op,
                                     int uid,
                                     String packageName,
                                     String attributionTag,
                                     String message)
        Stores a fake long-running operation. It does not throw if a wrong uid is passed.
      • finishOp

        @Implementation(minSdk=19,
                        maxSdk=29)
        protected void finishOp​(int op,
                                int uid,
                                String packageName)
        Removes a fake long-running operation from the set.
      • finishOp

        @Implementation(minSdk=30)
        protected void finishOp​(String op,
                                int uid,
                                String packageName,
                                String attributionTag)
        Removes a fake long-running operation from the set.
      • checkOpNoThrow

        @Implementation(minSdk=28)
        @Deprecated
        protected int checkOpNoThrow​(String op,
                                     int uid,
                                     String packageName)
        Deprecated.
      • noteOp

        @Implementation(minSdk=19)
        public int noteOp​(int op,
                          int uid,
                          String packageName)
      • noteOp

        @Implementation(minSdk=30)
        protected int noteOp​(int op,
                             int uid,
                             String packageName,
                             String attributionTag,
                             String message)
      • noteOpNoThrow

        @Implementation(minSdk=19)
        protected int noteOpNoThrow​(int op,
                                    int uid,
                                    String packageName)
      • noteOpNoThrow

        @Implementation(minSdk=30)
        protected int noteOpNoThrow​(int op,
                                    int uid,
                                    String packageName,
                                    String attributionTag,
                                    String message)
      • noteProxyOpNoThrow

        @Implementation(minSdk=23,
                        maxSdk=29)
        @HiddenApi
        protected int noteProxyOpNoThrow​(int op,
                                         String proxiedPackageName)
      • noteProxyOpNoThrow

        @Implementation(minSdk=29,
                        maxSdk=29)
        @HiddenApi
        protected int noteProxyOpNoThrow​(int op,
                                         String proxiedPackageName,
                                         int proxiedUid)
      • noteProxyOpNoThrow

        @Implementation(minSdk=30,
                        maxSdk=30)
        @HiddenApi
        protected int noteProxyOpNoThrow​(int op,
                                         String proxiedPackageName,
                                         int proxiedUid,
                                         String proxiedAttributionTag,
                                         String message)
      • noteProxyOpNoThrow

        @Implementation(minSdk=31)
        protected int noteProxyOpNoThrow​(Object op,
                                         Object attributionSource,
                                         Object message,
                                         Object ignoredSkipProxyOperation)
      • checkPackage

        @Implementation(minSdk=19)
        protected void checkPackage​(int uid,
                                    String packageName)
      • setRestriction

        @Implementation(minSdk=21)
        @HiddenApi
        public void setRestriction​(int code,
                                   int usage,
                                   int mode,
                                   String[] exceptionPackages)
        Sets audio restrictions.

        This method is public for testing, as the original method is @hide.

      • reset

        @Resetter
        public static void reset()