Example usage for android.support.v4.app AppOpsManagerCompat MODE_ALLOWED

List of usage examples for android.support.v4.app AppOpsManagerCompat MODE_ALLOWED

Introduction

In this page you can find the example usage for android.support.v4.app AppOpsManagerCompat MODE_ALLOWED.

Prototype

int MODE_ALLOWED

To view the source code for android.support.v4.app AppOpsManagerCompat MODE_ALLOWED.

Click Source Link

Document

Result from #noteOp : the given caller is allowed to perform the given operation.

Usage

From source file:com.just.agentweb.AgentWebUtils.java

public static boolean hasPermission(@NonNull Context context, @NonNull List<String> permissions) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        return true;
    }//from w  w  w  .  j a v a  2  s .  c  om
    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;
}