refresh Revoked Permissions - Android App

Android examples for App:Manifest

Description

refresh Revoked Permissions

Demo Code


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PermissionInfo;
import android.util.Log;

public class Main{
    public static HashMap<String, ArrayList<String>> mRevokedPermissionsMap;
    public static List<PackageInfo> mPackages;
    public static Context mCTX;
    public static void refreshRevokedPermissions() {
        getRevokedPermMap();//from  w w  w.j a  va  2 s . co  m
    }
    private static void getRevokedPermMap() {
        //if(!(CyanogenModHelper.isRunningOnCyanogenmod() && CyanogenModHelper.hasRevokablePermissions()))
        //   return;
        mRevokedPermissionsMap = new HashMap<String, ArrayList<String>>();

        for (PackageInfo pi : mPackages) {
            String[] rPerms = CyanogenModHelper.getRevokedPerms(
                    pi.packageName, mCTX);
            if (rPerms == null)
                rPerms = new String[0];
            ArrayList<String> revokedPerms = new ArrayList<String>(
                    Arrays.asList(rPerms));
            mRevokedPermissionsMap.put(pi.packageName, revokedPerms);
        }

    }
}

Related Tutorials