Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get installed applications permissions

I need to develop an android application to detect malwares.

I am looking to develop this based on permissions used by all the applications installed. Please let me know how to identify the permissions used by other applications

like image 292
Arun Avatar asked Oct 29 '11 08:10

Arun


People also ask

How do I get permission for Windows applications?

Select Start > Settings > Privacy & security. Select an App permission (for example, Location) then choose which apps can access it.

How do I get a list of installed apps on Android?

Go to Settings and find the App Management or Apps section, depending on your phone. If you can't locate it, simply perform a quick search within Settings. Once in App Management, tap on See All Apps or App Settings to see the list of apps installed on your device, excluding the system apps.

How do I extract permissions from a mobile app?

Open Settings, go to Privacy, and choose Permission manager. Here, you'll find a list that includes Body sensors, Calendar, Camera, Contacts, Location, Microphone, SMS, Storage, Telephone, and more. Tap any entry to see which apps can access that particular function.


1 Answers

You can get all installed applications permissions like this.

  • Get all installed applications
  • Iterate over the applications
  • Get each application permissions list
  • Iterate over the each permission
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

for (ApplicationInfo applicationInfo : packages) {
   Log.d("test", "App: " + applicationInfo.name + " Package: " + applicationInfo.packageName);

   try {
      PackageInfo packageInfo = pm.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS);

      //Get Permissions
      String[] requestedPermissions = packageInfo.requestedPermissions;

      if(requestedPermissions != null) {
         for (int i = 0; i < requestedPermissions.length; i++) {
            Log.d("test", requestedPermissions[i]);
         }
      }
   } catch (NameNotFoundException e) {
      e.printStackTrace();
   }
}
like image 154
evilone Avatar answered Sep 16 '22 16:09

evilone