本文整理汇总了Java中com.android.launcher3.Utilities.ATLEAST_MARSHMALLOW属性的典型用法代码示例。如果您正苦于以下问题:Java Utilities.ATLEAST_MARSHMALLOW属性的具体用法?Java Utilities.ATLEAST_MARSHMALLOW怎么用?Java Utilities.ATLEAST_MARSHMALLOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.android.launcher3.Utilities
的用法示例。
在下文中一共展示了Utilities.ATLEAST_MARSHMALLOW属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
public static UserManagerCompat getInstance(Context context) {
synchronized (sInstanceLock) {
if (sInstance == null) {
if (Utilities.isNycMR1OrAbove()) {
sInstance = new UserManagerCompatVNMr1(context.getApplicationContext());
} else if (Utilities.isNycOrAbove()) {
sInstance = new UserManagerCompatVN(context.getApplicationContext());
} else if (Utilities.ATLEAST_MARSHMALLOW) {
sInstance = new UserManagerCompatVM(context.getApplicationContext());
} else if (Utilities.ATLEAST_LOLLIPOP) {
sInstance = new UserManagerCompatVL(context.getApplicationContext());
} else if (Utilities.ATLEAST_JB_MR1) {
sInstance = new UserManagerCompatV17(context.getApplicationContext());
} else {
sInstance = new UserManagerCompatV16();
}
}
return sInstance;
}
}
示例2: hasPermissionForActivity
/**
* Returns true if {@param srcPackage} has the permission required to start the activity from
* {@param intent}. If {@param srcPackage} is null, then the activity should not need
* any permissions
*/
public static boolean hasPermissionForActivity(Context context, Intent intent,
String srcPackage) {
PackageManager pm = context.getPackageManager();
ResolveInfo target = pm.resolveActivity(intent, 0);
if (target == null) {
// Not a valid target
return false;
}
if (TextUtils.isEmpty(target.activityInfo.permission)) {
// No permission is needed
return true;
}
if (TextUtils.isEmpty(srcPackage)) {
// The activity requires some permission but there is no source.
return false;
}
// Source does not have sufficient permissions.
if(pm.checkPermission(target.activityInfo.permission, srcPackage) !=
PackageManager.PERMISSION_GRANTED) {
return false;
}
if (!Utilities.ATLEAST_MARSHMALLOW) {
// These checks are sufficient for below M devices.
return true;
}
// On M and above also check AppOpsManager for compatibility mode permissions.
if (TextUtils.isEmpty(AppOpsManager.permissionToOp(target.activityInfo.permission))) {
// There is no app-op for this permission, which could have been disabled.
return true;
}
// There is no direct way to check if the app-op is allowed for a particular app. Since
// app-op is only enabled for apps running in compatibility mode, simply block such apps.
try {
return pm.getApplicationInfo(srcPackage, 0).targetSdkVersion >= Build.VERSION_CODES.M;
} catch (NameNotFoundException e) { }
return false;
}