当前位置: 首页>>代码示例>>Java>>正文


Java Utilities.ATLEAST_MARSHMALLOW属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:20,代码来源:UserManagerCompat.java

示例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;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:48,代码来源:PackageManagerHelper.java


注:本文中的com.android.launcher3.Utilities.ATLEAST_MARSHMALLOW属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。