Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AOSP block installing apps from unknown source

Is there any way I can block the user from installing apps from an unknown source in custom android OS?

I am trying to create a custom variant of the Android OS using AOSP source, In which I want to allow users to install only apps from trusted sources that I specify during the build.

Block enabling developer option and USB debugging. The solution should block the user from installing an app from all the possible sources like sideload or by connecting with the system.

like image 813
GoSmash Avatar asked Jan 22 '20 10:01

GoSmash


People also ask

How do I lock a package installer?

You can use the Play Store's parental controls to restrict or block app installation on the Android device. Using your child's device, open the Play Store app and tap the menu in the top left corner. Choose Settings and then Parental controls, and turn on the controls.


1 Answers

I have meet the same requirements, and implement it in Android 8. It use the device policy controller to disable app install. It should be still work in new Android version.

https://cs.android.com/android/platform/superproject/+/master:frameworks/base/services/core/java/com/android/server/pm/UserManagerService.java;l=559

Add the following function applyInstallAppsRestritions, and call it in line 559.

private void applyInstallAppsRestritions() {
    synchronized (mRestrictionsLock) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(UserManager.DISALLOW_INSTALL_APPS, true);
        Slog.i(LOG_TAG, "disallow install app by default.");
        mBaseUserRestrictions.append(UserHandle.USER_SYSTEM, bundle);
    }
}
like image 97
Yong Avatar answered Sep 23 '22 14:09

Yong