GoSmash
GoSmash

Reputation: 1108

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.

Upvotes: 11

Views: 2256

Answers (2)

Yong
Yong

Reputation: 1978

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);
    }
}

Upvotes: 2

dgp
dgp

Reputation: 711

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.

Upvotes: 0

Related Questions