package com.lc.myapplication.security.locks.tool;

import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

import com.lc.myapplication.security.locks.value.MeValues;

public class LockPremission {
    private static AppOpsManager appOpsManager = (AppOpsManager) MeValues.lock.getSystemService(Context.APP_OPS_SERVICE);
    public static void Privacypremit(Context context){
        Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
        context.startActivity(intent);
    }
    public static void ShowOnpremit(Context context){
        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
        context.startActivity(intent);
    }
    public static boolean privacysuccess(Context context){
        int mode = appOpsManager.checkOpNoThrow("android:get_usage_stats", android.os.Process.myUid(), context.getPackageName());//检查是否有某项权限
        if(mode == AppOpsManager.MODE_ALLOWED){
            return true;
        }
        return false;
    }
    public static boolean showonsuccess(Context context){
        if (Settings.canDrawOverlays(context)){
            return true;
        }
        return false;
    }
    public static boolean allpermiss(Context context){
        boolean privacy = LockPremission.privacysuccess(context);
        boolean showon = LockPremission.showonsuccess(context);
        return privacy && showon;
    }
}
