Reputation: 8433
I am working at an OEM and would like to know how to deactivate the "Disable option" so that our device user can't remove pre loaded App, which is a security App. Is there an AndroidManifest Attribute in SDK 4.0. If so please let me know. Thank you much.
Upvotes: 2
Views: 2989
Reputation: 32051
I checked the sourcecode of the Settings app which contains the following function.
The SUPPORT_DISABLE_APPS
is a systemwide flag. If you want to prevent any(!) app from beeing disabled, you can set this flag to false
.
In short, the comment tells everything: The only apps which can not be disabled are:
ACTION_MAIN
and category CATEGORY_HOME
.apps signed with the system cert. As you can modifiy and create this certificate during the build-process of the system image, it should be possible to sign your application with this key and thus prevent the disableing.
if (SUPPORT_DISABLE_APPS) {
try {
// Try to prevent the user from bricking their phone
// by not allowing disabling of apps signed with the
// system cert and any launcher app in the system.
PackageInfo sys = mPm.getPackageInfo("android",
PackageManager.GET_SIGNATURES);
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setPackage(mAppEntry.info.packageName);
List<ResolveInfo> homes = mPm.queryIntentActivities(intent, 0);
if ((homes != null && homes.size() > 0) ||
(mPackageInfo != null && mPackageInfo.signatures != null &&
sys.signatures[0].equals(mPackageInfo.signatures[0]))) {
// Disable button for core system applications.
mUninstallButton.setText(R.string.disable_text);
} else if (mAppEntry.info.enabled) {
mUninstallButton.setText(R.string.disable_text);
enabled = true;
} else {
mUninstallButton.setText(R.string.enable_text);
enabled = true;
}
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Unable to get package info", e);
}
Upvotes: 2
Reputation: 91331
No there is not a way to prevent the user from disabling pre-installed apps, and that is very much by design. The philosophy for this is that if disabling an app will not prevent the user from being able to get to settings and re-enable it, then they should be allowed to disable it.
Upvotes: 4
Reputation: 1006974
There is nothing in the SDK for this. However, an app you put in the firmware cannot be uninstalled by the user, unless they root their device.
Upvotes: 0