public final class AppOpsManagerCompat
extends Object
| java.lang.Object | |
| android.support.v4.app.AppOpsManagerCompat | |
Helper用于访问以向后兼容的方式在API级别4之后引入的android.app.AppOpsManager中的功能。
常量(Constants) |
|
|---|---|
int |
MODE_ALLOWED 来自 |
int |
MODE_DEFAULT 来自 |
int |
MODE_IGNORED 来自 |
公共方法(Public methods) |
|
|---|---|
static int |
noteOp(Context context, String op, int uid, String packageName) 记下执行操作的应用程序。 |
static int |
noteProxyOp(Context context, String op, String proxiedPackageName) 记下一个应用程序在处理IPC时代表另一个应用程序执行操作。 |
static String |
permissionToOp(String permission) 获取与给定权限关联的应用op名称。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
int MODE_ALLOWED
来自 noteOp(Context, String, int, String)结果:允许给定的调用者执行给定的操作。
常量值:0(0x00000000)
int MODE_DEFAULT
来自noteOp(Context, String, int, String)结果:给定的主叫方应该使用其默认安全检查。 这种模式通常不被使用; 它只能与appop权限一起使用,调用者必须明确检查并处理它。
常量值:3(0x00000003)
int MODE_IGNORED
来自 noteOp(Context, String, int, String)结果:给定的调用方不允许执行给定的操作,并且此尝试应该 悄然失败 (它不应导致应用程序崩溃)。
常数值:1(0x00000001)
int noteOp (Context context, String op, int uid, String packageName)
记下执行操作的应用程序。 请注意,您必须同时传入要检查的应用程序的uid和名称; 此功能将验证这两个匹配,如果不匹配,则返回MODE_IGNORED 。 如果此调用成功,则此应用程序的最后执行时间将更新为当前时间。
| 参数(Parameters) | |
|---|---|
context |
Context: Your context. |
op |
String: The operation to note. One of the OPSTR_* constants. |
uid |
int: The user id of the application attempting to perform the operation. |
packageName |
String: The name of the application attempting to perform the operation. |
| 返回(Returns) | |
|---|---|
int |
Returns MODE_ALLOWED if the operation is allowed, or MODE_IGNORED if it is not allowed and should be silently ignored (without causing the app to crash). |
| 抛出异常(Throws) | |
|---|---|
SecurityException |
If the app has been configured to crash on this op. |
int noteProxyOp (Context context, String op, String proxiedPackageName)
记下一个应用程序在处理IPC时代表另一个应用程序执行操作。 请注意,您必须传递正在进行代理的应用程序的程序包名称,同时将从IPC状态中推断其UID; 此函数将验证呼叫的uid和代理包名称是否匹配,如果不匹配,则返回MODE_IGNORED 。 如果此调用成功,则代理应用程序和您的应用程序的最后执行时间将更新为当前时间。
| 参数(Parameters) | |
|---|---|
context |
Context: Your context. |
op |
String: The operation to note. One of the OPSTR_* constants. |
proxiedPackageName |
String: The name of the application calling into the proxy application. |
| 返回(Returns) | |
|---|---|
int |
Returns MODE_ALLOWED if the operation is allowed, or MODE_IGNORED if it is not allowed and should be silently ignored (without causing the app to crash). |
| 抛出异常(Throws) | |
|---|---|
SecurityException |
If the app has been configured to crash on this op. |