Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install app silently on Android devices?

So, I found this answer here by #CommonsWare about allowing an app to install apps silently to the phone like Google Play does. There, it is mentioned that the app should be either signed with the firmware-signing certificate or so, or add the app to System folder. What I need to know is, if I add the app to system\app\ or system\priv-app\, then is it possible to install app silently to an Android device? Or do I need to utilize INSTALL_PACKAGES permission? If so, how?

I'm asking this question because I've only 10 reputations so I cannot comment there.

I found an answer by #inazaruk here, but it's complicated and the provided links are dead.

like image 838
Neeraj Avatar asked Oct 29 '22 12:10

Neeraj


1 Answers

It's the app doing the installation that needs to be system signed or reside in system/app system/priv-app, for those you do need to hold the correct permission in order to install an app (even if you're system signed), the difference is that you are able to get the necessary permission to do so at all. The fact that you use a permission is not the same as that the user gets a pop-up asking if it's OK.

In order to install a package you can call (ApplicationPackageManager.installPackage): http://androidxref.com/7.1.1_r6/xref/frameworks/base/core/java/android/app/ApplicationPackageManager.java#1561

public void installPackage(Uri packageURI, PackageInstallObserver observer,
        int flags, String installerPackageName) {

Since the ApplicationPackageManager has @hide on it you're going to have to use something like reflection to access it. You get an ApplicationPackageManager when you call "Context.getPackageManager".

like image 75
JohanShogun Avatar answered Nov 15 '22 06:11

JohanShogun