Installing the application in a managed profile

I play with the BasicManagedProfile sample and want to install a custom application for a managed profile only. I can easily go to the game store, download and install the application, and it will only appear in work profile applications.

However, using the standard Intent method to install apk from the device does not work.

final Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.setDataAndType(Uri.fromFile(new File(APK_LOC)), "application/vnd.android.package-archive"); intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, getPackageName()); startActivityForResult(intent, REQUEST_INSTALL, null); 

As usual, if the “Install from unknown sources” security option is not enabled, a dialog box will appear that will send you to the Settings application to enable it. However, in a managed profile application, this dialog always appears regardless of whether this security setting is set. It seems that the settings are not reflected in the managed profile (which makes sense because it is a completely separate settings database).

I tried to open the Settings app directly, but it's still the same. It just fits the default settings of the application, and not the settings of the managed profile settings.

Is there a way to change this security setting for a managed profile or install the application from the profile owner application? Since my application is the owner of the profile, it seems like this should be allowed. This is easily possible for system applications, but third-party applications will not work with the DevicePolicyManager#enableSystemApp() method.

EDIT:

I also tried installing from the Manage Profile Gmail application. Same. Unable to install apps outside of the Google Play store in a managed profile.

+5
source share
1 answer

Google has restricted the direct installation of .apk files in a managed profile.

The unusual behavior of the warning window, which says that the user goes to settings and allows "install from unknown sources", even if it is turned on, is considered a problem. See the Google issues page here .

Is there a way to change this security setting for a managed profile or install the application from the profile owner’s application?

Currently, the API or does not work to install the .apk file in a managed profile. But for testing, you can try adb

  adb install appname.apk 

This command will install the application in both a personal and a managed profile. Hope this helps you!

+2
source

Source: https://habr.com/ru/post/1207702/


All Articles