AOSP block installing apps from unknown source
Asked Answered
A

2

11

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.

Anapest answered 22/1, 2020 at 10:56 Comment(1)
Check out this https://mcmap.net/q/803526/-android-known-sourcesNucleate
M
2

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);
    }
}
Microstructure answered 23/7, 2020 at 7:49 Comment(1)
This is a quick easy fix if you're building from AOSP source. For android 10, I had to modify the patch slightly but the core is the same. gist.github.com/djmuhlestein/be15a80062f98dc904810a13ef2c9dafSublimate
K
0

You can disable installing app from unknown source, block access to some apps, and many more by creating a device policy controller (DPC) app.

You can take a look at this sample and check if a device admin or device owner app have all features you need.

Kendy answered 4/2, 2020 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.