package com.sec.tool;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.util.Log;

import pub.devrel.easypermissions.helper.PermissionHelper;

public class PermissionsHelper {
    public static String[] requestPermissions = {
             Manifest.permission.READ_PHONE_STATE};

    public static String[] requestAllPermissions = {
            Manifest.permission.READ_EXTERNAL_STORAGE
            , Manifest.permission.READ_PHONE_STATE
            , Manifest.permission.WRITE_EXTERNAL_STORAGE
            , Manifest.permission.REQUEST_INSTALL_PACKAGES
            , Manifest.permission.CAMERA
            , Manifest.permission.RECORD_AUDIO
//            ,Manifest.permission.ACCESS_WIFI_STATE
//            ,Manifest.permission.INTERNET
//            ,Manifest.permission.SET_WALLPAPER
//            ,Manifest.permission.ACCESS_NETWORK_STATE
//            ,Manifest.permission.RECEIVE_BOOT_COMPLETED
//            ,Manifest.permission.CHANGE_CONFIGURATION
//            ,Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
    };


    private static final String TAG = PermissionHelper.class.getSimpleName();

    public static boolean checkPermissions(Context context, String... permissions) {
        for (String permission : permissions) {
            int i = ActivityCompat.checkSelfPermission(context, permission);
            Log.i(TAG, "PermissionHelper-checkPermissions: " + permission + "=i=" + i);
            if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                return false;
            }
        }
        return true;
    }

    private static int count = 0;

    public static void requestPermissions(Activity activity, int requestCode, String... permissions) {
        ActivityCompat.requestPermissions(activity, permissions, requestCode);
    }
}
