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

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

Introduction

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

Prototype

public static int noteProxyOp(@NonNull Context context, @NonNull String op,
        @NonNull String proxiedPackageName) 

Source Link

Document

Make note of an application performing an operation on behalf of another application when handling an IPC.

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;
    }// w w w .j a  va  2  s  .  c o m
    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;
}