Class ShadowAppOpsManager


  • @Implements(android.app.AppOpsManager.class)
    public class ShadowAppOpsManager
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int DURATION  
      protected static long OP_TIME  
      protected static java.lang.String PROXY_PACKAGE  
      protected static int PROXY_UID  
      protected static long REJECT_TIME  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void __constructor__​(android.content.Context context, com.android.internal.app.IAppOpsService service)  
      int checkOpNoThrow​(int op, int uid, java.lang.String packageName)
      Like AppOpsManager.checkOp(java.lang.String, int, java.lang.String) but instead of throwing a SecurityException it returns AppOpsManager.MODE_ERRORED.
      protected int checkOpNoThrow​(java.lang.String op, int uid, java.lang.String packageName)
      Deprecated.
      protected void checkPackage​(int uid, java.lang.String packageName)  
      java.util.List<android.app.AppOpsManager.PackageOps> getOpsForPackage​(int uid, java.lang.String packageName, int[] ops)  
      ShadowAppOpsManager.ModeAndException getRestriction​(int code, int usage)  
      int noteOp​(int op, int uid, java.lang.String packageName)  
      protected int noteOpNoThrow​(int op, int uid, java.lang.String packageName)  
      protected int noteProxyOpNoThrow​(int op, java.lang.String proxiedPackageName)  
      void setMode​(int op, int uid, java.lang.String packageName, int mode)
      void setMode​(java.lang.String op, int uid, java.lang.String packageName, int mode)
      Change the operating mode for the given op in the given app package.
      void setRestriction​(int code, int usage, int mode, java.lang.String[] exceptionPackages)
      Sets audio restrictions.
      protected void startWatchingMode​(int op, java.lang.String packageName, android.app.AppOpsManager.OnOpChangedListener callback)  
      protected void stopWatchingMode​(android.app.AppOpsManager.OnOpChangedListener callback)  
      protected android.app.AppOpsManager.OpEntry toOpEntry​(java.lang.Integer op)  
      int unsafeCheckOpNoThrow​(java.lang.String op, int uid, java.lang.String packageName)  
      int unsafeCheckOpRawNoThrow​(java.lang.String op, int uid, java.lang.String packageName)
      Like unsafeCheckOpNoThrow(String, int, String) but returns the raw mode associated with the op.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowAppOpsManager

        public ShadowAppOpsManager()
    • Method Detail

      • __constructor__

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

        @Implementation(minSdk=28)
        @HiddenApi
        public void setMode​(java.lang.String op,
                            int uid,
                            java.lang.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.
      • unsafeCheckOpNoThrow

        @Implementation(minSdk=29)
        public int unsafeCheckOpNoThrow​(java.lang.String op,
                                        int uid,
                                        java.lang.String packageName)
      • unsafeCheckOpRawNoThrow

        @Implementation(minSdk=29)
        public int unsafeCheckOpRawNoThrow​(java.lang.String op,
                                           int uid,
                                           java.lang.String packageName)
        Like unsafeCheckOpNoThrow(String, int, String) but returns the raw mode associated with the op. Does not throw a security exception, does not translate AppOpsManager.MODE_FOREGROUND.
      • checkOpNoThrow

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

        @Implementation(minSdk=19)
        @HiddenApi
        public int checkOpNoThrow​(int op,
                                  int uid,
                                  java.lang.String packageName)
        Like AppOpsManager.checkOp(java.lang.String, int, java.lang.String) but instead of throwing a SecurityException it returns AppOpsManager.MODE_ERRORED.

        Made public for testing setMode(java.lang.String, int, java.lang.String, int) as the method is .

      • noteOp

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

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

        @Implementation(minSdk=23)
        @HiddenApi
        protected int noteProxyOpNoThrow​(int op,
                                         java.lang.String proxiedPackageName)
      • getOpsForPackage

        @Implementation(minSdk=19)
        @HiddenApi
        public java.util.List<android.app.AppOpsManager.PackageOps> getOpsForPackage​(int uid,
                                                                                     java.lang.String packageName,
                                                                                     int[] ops)
      • checkPackage

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

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

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

      • startWatchingMode

        @Implementation(minSdk=19)
        @HiddenApi
        protected void startWatchingMode​(int op,
                                         java.lang.String packageName,
                                         android.app.AppOpsManager.OnOpChangedListener callback)
      • stopWatchingMode

        @Implementation(minSdk=19)
        protected void stopWatchingMode​(android.app.AppOpsManager.OnOpChangedListener callback)
      • toOpEntry

        protected android.app.AppOpsManager.OpEntry toOpEntry​(java.lang.Integer op)