get Revoked Permission Map - Android App

Android examples for App:Manifest

Description

get Revoked Permission Map

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

    }
}

Related Tutorials