本文整理汇总了Java中android.support.v4.app.AppOpsManagerCompat类的典型用法代码示例。如果您正苦于以下问题:Java AppOpsManagerCompat类的具体用法?Java AppOpsManagerCompat怎么用?Java AppOpsManagerCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppOpsManagerCompat类属于android.support.v4.app包,在下文中一共展示了AppOpsManagerCompat类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkPermission
import android.support.v4.app.AppOpsManagerCompat; //导入依赖的package包/类
public static int checkPermission(@NonNull Context context, @NonNull String permission, int pid, int uid, String packageName) {
if (context.checkPermission(permission, pid, uid) == -1) {
return -1;
}
String op = AppOpsManagerCompat.permissionToOp(permission);
if (op == null) {
return 0;
}
if (packageName == null) {
String[] packageNames = context.getPackageManager().getPackagesForUid(uid);
if (packageNames == null || packageNames.length <= 0) {
return -1;
}
packageName = packageNames[0];
}
return AppOpsManagerCompat.noteProxyOp(context, op, packageName) != 0 ? -2 : 0;
}
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:PermissionChecker.java
示例2: hasPermission
import android.support.v4.app.AppOpsManagerCompat; //导入依赖的package包/类
static boolean hasPermission(@NonNull Context context, @NonNull List<String> permissions) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true;
for (String permission : permissions) {
int result = ContextCompat.checkSelfPermission(context, permission);
if (result == PackageManager.PERMISSION_DENIED) return false;
String op = AppOpsManagerCompat.permissionToOp(permission);
if (TextUtils.isEmpty(op)) continue;
result = AppOpsManagerCompat.noteProxyOp(context, op, context.getPackageName());
if (result != AppOpsManagerCompat.MODE_ALLOWED) return false;
}
return true;
}
开发者ID:Justson,项目名称:AgentWeb,代码行数:15,代码来源:AgentWebUtils.java
示例3: hasPermission
import android.support.v4.app.AppOpsManagerCompat; //导入依赖的package包/类
/**
* Check if the calling context has a set of permissions.
*
* @param context {@link Context}.
* @param permissions one or more permissions.
* @return true, other wise is false.
*/
public static boolean hasPermission(@NonNull Context context, @NonNull List<String> permissions) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true;
for (String permission : permissions) {
int result = ContextCompat.checkSelfPermission(context, permission);
if (result == PackageManager.PERMISSION_DENIED) return false;
String op = AppOpsManagerCompat.permissionToOp(permission);
if (TextUtils.isEmpty(op)) continue;
result = AppOpsManagerCompat.noteProxyOp(context, op, context.getPackageName());
if (result != AppOpsManagerCompat.MODE_ALLOWED) return false;
}
return true;
}
开发者ID:yanzhenjie,项目名称:AndPermission,代码行数:22,代码来源:AndPermission.java
示例4: hasSelfPermissionForXiaomi
import android.support.v4.app.AppOpsManagerCompat; //导入依赖的package包/类
private static boolean hasSelfPermissionForXiaomi(Context context, String permission) {
String permissionToOp = AppOpsManagerCompat.permissionToOp(permission);
if (permissionToOp == null) {
// in case of normal permissions(e.g. INTERNET)
return true;
}
int noteOp = AppOpsManagerCompat.noteOp(context, permissionToOp, Process.myUid(), context.getPackageName());
return noteOp == AppOpsManagerCompat.MODE_ALLOWED && checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
}
开发者ID:permissions-dispatcher,项目名称:PermissionsDispatcher,代码行数:10,代码来源:PermissionUtils.java
注:本文中的android.support.v4.app.AppOpsManagerCompat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论