Home > Software engineering >  Is there a way to get the installer source of android app
Is there a way to get the installer source of android app

Time:12-21

image

How can we possibly get the information of install source that installed a package on our device.

I want to get the installer source of other installed applications not just my application to verify it's integrity

CodePudding user response:

Yes you can get the installer of the apps :

You can get the package name of the installer by using getInstallerSourceInfo (Api 30 ) or getInstallerPackageName (Api 29 or below) function :

 String installerInfo;
 PackageManager packageManager = getPackageManager();

 try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) 
        installerInfo = packageManager.getInstallSourceInfo("package name").getInstallingPackageName();
        else installerInfo = packageManager.getInstallerPackageName("package name");

     } catch (Exception e) {
        installerInfo = "--";
        e.printStackTrace();
     }

And if you want to format that package name to the app name you can do something like this :

 if(installerInfo!=null){

    switch (installerInfo){

    case "com.android.vending" : installerInfo = "Google PlayStore";                     
    break;

    case "com.amazon.venezia" : installerInfo = "Amazon App Store";                      
    break;

    case "com.android.chrome" : installerInfo = "Google Chrome";                     
    break;

    case "com.google.android.packageinstaller" : installerInfo = "Package Installer";                      
    break;

    case "com.whatsapp" : installerInfo = "Whatsapp";                    
    break;

    case "org.mozilla.firefox" : installerInfo = "Firefox";                   
    break;

     }
       } else { installerInfo = "--"; }
  • Related