Added in API level 1
public interface

IAppInstallManager

com.ardic.android.managers.appinstall.IAppInstallManager

Class Overview

Provides a set APIs to manage applications silent installation and uninstallation.

AppInstallManager class defines and uses blacklist, whitelist, trustedsignature and trustedstore entities. The installation APIs relies on the active policies set by the user. For more details please refer to

isInstallBlocked(AppInstallItem).

By using this manager user can define installation policies, installs and uninstalls an applications silently and do much more.

Installation policy decision needs some steps as follows;

 AppInstallManager aim = AppInstallManager.getInterface(Context);
 
 
 

1- Add specified policy with specified control order to installation policy list by;

     aim.addInstallPolicy(PolicyName.POLICYNAME_WHITELIST, 5);
 
2- Initialize the added installation policy related list by;
     aim.addAppToWhitelist("com.xxx.yyy", null);
 
3- Then installation policy can be queried by;
     aim.isInstallBlocked("com.xxx.yyy"); // Returns false because it is in whitelist.
 
a) User can add another installation policy after preceding operations by;
     aim.addInstallPolicy(PolicyName.POLICYNAME_TRUSTEDSTORE, 2);
 
b) User should initialize the preceding installation policy related list by;
     aim.addTrustedStore("com.android.playstore");
 
c) Then installation policy can be queried by;
     aim.isInstallBlocked("com.xxx.zzz"); // Returns false while it is installing from AndroidPlayStore else true.
 
Kind of variances can be created by choosing installation policy and initialization of chose policy list. Each installation policy is represent on OR (||) decision item. All policies making OR'ed (||) one by one from lower order to higher order which means if whitelist is order 5 and blacklist is order 2 then blacklist control is done firstly and if there is no decision for blacklist, whitelist control is done secondly and returns OR'ed (||) installation result. Adding item to related policy (for example addAppToWhitelist and etc) is not sufficient to activate the policy. User have to add related policies to installation policy list by calling addInstallPolicy else nothing will be controlled. Sample Usages as follows; Sample-1:
 AppInstallManager aim = AppInstallManager.getInterface(Context);
 aim.addInstallPolicy(PolicyName.POLICYNAME_WHITELIST, 1);
 aim.addAppToWhitelist("com.xxx.yyy", null);
 boolean resultY = aim.isInstallBlocked("com.xxx.yyy");
 boolean resultZ = aim.isInstallBlocked("com.xxx.zzz");
 
Sample-1 results will be as resultY=false and resultZ=true. Warning: If user would not add any item to whitelist, all application installation will be blocked because of empty whitelist. Sample-2:
 AppInstallManager aim = AppInstallManager.getInterface(Context);
 aim.addInstallPolicy(PolicyName.POLICYNAME_WHITELIST, 2);
 aim.addInstallPolicy(PolicyName.POLICYNAME_BLACKLIST, 1);
 aim.addAppToWhitelist("com.xxx.yyy", null);
 aim.addAppToBlacklist("com.xxx.zzz", null);
 boolean resultY = aim.isInstallBlocked("com.xxx.yyy");
 boolean resultZ = aim.isInstallBlocked("com.xxx.zzz");
 boolean resultQ = aim.isInstallBlocked("com.xxx.qqq");
 
Sample-2 results will be as resultY=false, resultZ=true and resultQ=true. Sample-3:
 AppInstallManager aim = AppInstallManager.getInterface(Context);
 aim.addInstallPolicy(PolicyName.POLICYNAME_TRUSTEDSTORE, 3);
 aim.addInstallPolicy(PolicyName.POLICYNAME_TRUSTEDSIGNATURE, 4);
 aim.addTrustedStore("com.android.playstore");
 aim.addTrustedSignature("ABC123");
 boolean resultY = aim.isInstallBlocked("com.xxx.yyy"); // yyy's signature is "ABC123"
 boolean resultZ = aim.isInstallBlocked("com.xxx.zzz"); // zzz is installing from "com.android.playstore"
 boolean resultQ = aim.isInstallBlocked("com.xxx.qqq"); // qqq is not complying any prerequisite to pass policies.
 
Sample-2 results will be as resultY=false, resultZ=false and resultQ=true. So as sample represents setting policies and related parts, user has many options while defining installation policy by using blacklist, whitelist, trustedstore and trustedsignature.

Summary

Constants
int DELETE_ALL_USERS Flag parameter for uninstall(String, int) to indicate that you want the package deleted for all users.
int DELETE_FAILED_AFEX_UNINSTALL_POLICY Deletion failed return code: this is passed to the IPackageDeleteObserver by uninstall(String, int) if the system failed to delete the package for the afex uninstallation policies.
int DELETE_FAILED_DEVICE_POLICY_MANAGER Deletion failed return code: this is passed to the IPackageDeleteObserver by uninstall(String, int) if the system failed to delete the package because it is the active DevicePolicy manager.
int DELETE_FAILED_INTERNAL_ERROR Deletion failed return code: this is passed to the IPackageDeleteObserver by uninstall(String, int) if the system failed to delete the package for an unspecified reason.
int DELETE_KEEP_DATA Flag parameter for uninstall(String, int) to indicate that you don't want to delete the package's data directory.
int DELETE_SUCCEEDED Return code for when package deletion succeeds.
int INSTALL_ALLOW_DOWNGRADE Flag parameter for install(String, int) to indicate that it is okay to install an update to an app where the newly installed app has a lower version code than the currently installed app.
int INSTALL_ALLOW_TEST Flag parameter for install(String, int) to indicate that you want to allow test packages (those that have set android:testOnly in their manifest) to be installed.
int INSTALL_ALL_USERS Flag parameter for install(String, int) to indicate that this install should immediately be visible to all users.
int INSTALL_EXTERNAL Flag parameter for install(String, int) to indicate that this package has to be installed on the sdcard.
int INSTALL_FAILED_AFEX_INSTALL_POLICY Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed in the specified install location because of the afex installation policies.
int INSTALL_FAILED_ALREADY_EXISTS Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package is already installed.
int INSTALL_FAILED_CONFLICTING_PROVIDER Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because it contains a content provider with the same authority as a provider already installed in the system.
int INSTALL_FAILED_CONTAINER_ERROR Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if a secure container mount point couldn't be accessed on external media.
int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package being installed contains native code, but none that is compatible with the the device's CPU_ABI.
int INSTALL_FAILED_DEXOPT Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed while optimizing and validating its dex files, either because there was not enough storage or the validation failed.
int INSTALL_FAILED_DUPLICATE_PACKAGE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if a package is already installed with the same name.
int INSTALL_FAILED_INSUFFICIENT_STORAGE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package manager service found that the device didn't have enough storage space to install the app.
int INSTALL_FAILED_INTERNAL_ERROR Installation failed return code: this is passed to the IPackageInstallObserver by install(String, int) if the system failed to install the package because of system issues.
int INSTALL_FAILED_INVALID_APK Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package archive file is invalid.
int INSTALL_FAILED_INVALID_INSTALL_LOCATION Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed in the specified install location.
int INSTALL_FAILED_INVALID_URI Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the URI passed in is invalid.
int INSTALL_FAILED_MEDIA_UNAVAILABLE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed in the specified install location because the media is not available.
int INSTALL_FAILED_MISSING_FEATURE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package uses a feature that is not available.
int INSTALL_FAILED_MISSING_SHARED_LIBRARY Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package uses a shared library that is not available.
int INSTALL_FAILED_NEWER_SDK Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because the current SDK version is newer than that required by the package.
int INSTALL_FAILED_NO_SHARED_USER Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the requested shared user does not exist.
int INSTALL_FAILED_OLDER_SDK Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because the current SDK version is older than that required by the package.
int INSTALL_FAILED_PACKAGE_CHANGED Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package changed from what the calling program expected.
int INSTALL_FAILED_REPLACE_COULDNT_DELETE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package uses a shared library that is not available.
int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package is requested a shared user which is already installed on the device and does not have matching signature.
int INSTALL_FAILED_TEST_ONLY Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because it has specified that it is a test-only package and the caller has not supplied the INSTALL_ALLOW_TEST flag.
int INSTALL_FAILED_UID_CHANGED Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package is assigned a different UID than it previously held.
int INSTALL_FAILED_UPDATE_INCOMPATIBLE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if a previously installed package of the same name has a different signature than the new package (and the old package's data was not removed).
int INSTALL_FAILED_VERIFICATION_FAILURE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed because the verification did not succeed.
int INSTALL_FAILED_VERIFICATION_TIMEOUT Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed because the verification timed out.
int INSTALL_FAILED_VERSION_DOWNGRADE Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package has an older version code than the currently installed package.
int INSTALL_FORWARD_LOCK Flag parameter for install(String, int) to indicate that this package should be installed as forward locked, i.e.
int INSTALL_FROM_ADB Flag parameter for install(String, int) to indicate that this install was initiated via ADB.
int INSTALL_INTERNAL Flag parameter for install(String, int) to indicate that this package has to be installed on the sdcard.
int INSTALL_PARSE_FAILED_BAD_MANIFEST Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser was unable to retrieve the AndroidManifest.xml file.
int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered a bad or missing package name in the manifest.
int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered a bad shared user id name in the manifest.
int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered a CertificateEncodingException in one of the files in the .apk.
int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser found inconsistent certificates on the files in the .apk.
int INSTALL_PARSE_FAILED_MANIFEST_EMPTY Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser did not find any actionable tags (instrumentation or application) in the manifest.
int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered some structural problem in the manifest.
int INSTALL_PARSE_FAILED_NOT_APK Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser was given a path that is not a file, or does not end with the expected '.apk' extension.
int INSTALL_PARSE_FAILED_NO_CERTIFICATES Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser did not find any certificates in the .apk.
int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered an unexpected exception.
int INSTALL_REPLACE_EXISTING Flag parameter for install(String, int) to indicate that you want to replace an already installed package, if one exists.
int INSTALL_SUCCEEDED Installation return code: this is passed to the IPackageInstallObserver by install(String, int) on success.
Public Methods
abstract boolean addAppToBlacklist(String packageName, String signature)
Adds the given application to the installation black list.
abstract boolean addAppToWhitelist(String packageName, String signature)
Adds the given application to the installation white list.
abstract boolean addInstallPolicy(PolicyItem.PolicyName policyName, int policyOrder)
Adds the given policy to the installation policy list.
abstract boolean addTrustedSignature(String signature)
Adds the given trusted signature to the installation trusted signature list.
abstract boolean addTrustedStore(String store)
Adds the given trusted store to the installation trusted store list.
abstract boolean clearBlacklist()
Clears all applications in the installation black list.
abstract boolean clearInstallPolicies()
Clears all policies in the installation policy list.
abstract boolean clearTrustedSignatures()
Clears all trusted signatures in the installation trusted signature list.
abstract boolean clearTrustedStores()
Clears all trusted stores in the installation trusted store list.
abstract boolean clearWhitelist()
Clears all applications in the installation white list.
abstract List<String> getBlacklist()
Returns all applications in the installation black list.
abstract List<PolicyItem> getInstallPolicyList()
Returns all policies in the installation policy list.
abstract List<String> getInstalledList()
Returns installed application list.
abstract List<String> getTrustedSignatureList()
Returns all trusted signatures in the installation trusted signatures list.
abstract List<String> getTrustedStoreList()
Returns all trusted stores in the installation trusted store list.
abstract List<String> getWhitelist()
Returns all applications in the installation black list.
abstract List<Integer> install(List<String> apkPathList, int installFlags)
Installs the given application list with specified installation flag.
abstract List<Integer> install(List<String> apkPathList)
Installs the given application list with specified installation flag.
abstract int install(String apkPath)
Installs the given application with default installation flag.
abstract int install(String apkPath, int installFlags)
Installs the given application with specified installation flag.
abstract String installResultToString(int result)
Returns passed installation result's enumaration name which is used for converting results in more understandable format.
abstract boolean isInstallBlocked()
Returns installation blocked state.
abstract boolean isInstallBlocked(AppInstallItem item)
Checks if application complies with the current application installation policies.
abstract boolean isInstalled(String packageName)
Checks if the given application installed on the system or not.
abstract boolean isNonMarketInstallBlocked()
Returns non market install blocked state.
abstract boolean isNonMarketInstallEnabled()
Returns non market installation state.
abstract boolean isPackageVerifierBlocked()
Returns the package verifier blocked state.
abstract boolean isPackageVerifierEnabled()
Returns the package verifier state.
abstract boolean isUninstallBlocked()
Returns uninstallation blocked state.
abstract boolean removeAppFromBlacklist(String packageName)
Removes the given application from the installation black list.
abstract boolean removeAppFromWhitelist(String packageName)
Removes the given application from the installation white list.
abstract boolean removeInstallPolicy(PolicyItem.PolicyName policyName)
Removes the given policy from the installation policy list.
abstract boolean removeTrustedSignature(String signature)
Removes the given trusted signature from the installation trusted signature list.
abstract boolean removeTrustedStore(String store)
Removes the given trusted store from the installation trusted store list.
abstract boolean setInstallBlocked(boolean state)
Sets system install state which blocks all application installation on the system regardless of any other attributes.
abstract boolean setNonMarketInstallBlocked(boolean state)
Sets system non market install state which blocks all non market installation on the system regardless of any other attributes.
abstract boolean setNonMarketInstallEnabled(boolean enabled)
Sets non market installation enabled.
abstract boolean setPackageVerifierBlocked(boolean state)
Sets the package verifier blocked state.
abstract boolean setPackageVerifierEnabled(boolean enabled)
Sets the package verifier enabled.
abstract boolean setUninstallBlocked(boolean state)
Sets system uninstall state which blocks all application uninstallation on the system regardless of any other attributes.
abstract List<Integer> uninstall(List<String> packageNameList, int uninstallFlags)
Uninstalls the given application list with specified uninstallation flag.
abstract int uninstall(String packageName, int uninstallFlags)
Uninstalls the given application with specified uninstallation flag.
abstract int uninstall(String packageName)
Uninstalls the given application.
abstract List<Integer> uninstall(List<String> packageNameList)
Uninstalls the given application list.
abstract String uninstallResultToString(int result)
Returns passed uninstallation result's enumaration name which is used for converting results in more understandable format.

Constants

public static final int DELETE_ALL_USERS

Added in API level 1

Flag parameter for uninstall(String, int) to indicate that you want the package deleted for all users.

Constant Value: 2 (0x00000002)

public static final int DELETE_FAILED_AFEX_UNINSTALL_POLICY

Added in API level 1

Deletion failed return code: this is passed to the IPackageDeleteObserver by uninstall(String, int) if the system failed to delete the package for the afex uninstallation policies.

Constant Value: -99 (0xffffff9d)

public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER

Added in API level 1

Deletion failed return code: this is passed to the IPackageDeleteObserver by uninstall(String, int) if the system failed to delete the package because it is the active DevicePolicy manager.

Constant Value: -2 (0xfffffffe)

public static final int DELETE_FAILED_INTERNAL_ERROR

Added in API level 1

Deletion failed return code: this is passed to the IPackageDeleteObserver by uninstall(String, int) if the system failed to delete the package for an unspecified reason.

Constant Value: -1 (0xffffffff)

public static final int DELETE_KEEP_DATA

Added in API level 1

Flag parameter for uninstall(String, int) to indicate that you don't want to delete the package's data directory.

Constant Value: 1 (0x00000001)

public static final int DELETE_SUCCEEDED

Added in API level 1

Return code for when package deletion succeeds. This is passed to the IPackageDeleteObserver by uninstall(String, int) if the system succeeded in deleting the package.

Constant Value: 1 (0x00000001)

public static final int INSTALL_ALLOW_DOWNGRADE

Added in API level 1

Flag parameter for install(String, int) to indicate that it is okay to install an update to an app where the newly installed app has a lower version code than the currently installed app.

Constant Value: 128 (0x00000080)

public static final int INSTALL_ALLOW_TEST

Added in API level 1

Flag parameter for install(String, int) to indicate that you want to allow test packages (those that have set android:testOnly in their manifest) to be installed.

Constant Value: 4 (0x00000004)

public static final int INSTALL_ALL_USERS

Added in API level 1

Flag parameter for install(String, int) to indicate that this install should immediately be visible to all users.

Constant Value: 64 (0x00000040)

public static final int INSTALL_EXTERNAL

Added in API level 1

Flag parameter for install(String, int) to indicate that this package has to be installed on the sdcard.

Constant Value: 8 (0x00000008)

public static final int INSTALL_FAILED_AFEX_INSTALL_POLICY

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed in the specified install location because of the afex installation policies.

Constant Value: -99 (0xffffff9d)

public static final int INSTALL_FAILED_ALREADY_EXISTS

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package is already installed.

Constant Value: -1 (0xffffffff)

public static final int INSTALL_FAILED_CONFLICTING_PROVIDER

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because it contains a content provider with the same authority as a provider already installed in the system.

Constant Value: -13 (0xfffffff3)

public static final int INSTALL_FAILED_CONTAINER_ERROR

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if a secure container mount point couldn't be accessed on external media.

Constant Value: -18 (0xffffffee)

public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package being installed contains native code, but none that is compatible with the the device's CPU_ABI.

Constant Value: -16 (0xfffffff0)

public static final int INSTALL_FAILED_DEXOPT

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed while optimizing and validating its dex files, either because there was not enough storage or the validation failed.

Constant Value: -11 (0xfffffff5)

public static final int INSTALL_FAILED_DUPLICATE_PACKAGE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if a package is already installed with the same name.

Constant Value: -5 (0xfffffffb)

public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package manager service found that the device didn't have enough storage space to install the app.

Constant Value: -4 (0xfffffffc)

public static final int INSTALL_FAILED_INTERNAL_ERROR

Added in API level 1

Installation failed return code: this is passed to the IPackageInstallObserver by install(String, int) if the system failed to install the package because of system issues.

Constant Value: -110 (0xffffff92)

public static final int INSTALL_FAILED_INVALID_APK

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package archive file is invalid.

Constant Value: -2 (0xfffffffe)

public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed in the specified install location.

Constant Value: -19 (0xffffffed)

public static final int INSTALL_FAILED_INVALID_URI

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the URI passed in is invalid.

Constant Value: -3 (0xfffffffd)

public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed in the specified install location because the media is not available.

Constant Value: -20 (0xffffffec)

public static final int INSTALL_FAILED_MISSING_FEATURE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package uses a feature that is not available.

Constant Value: -17 (0xffffffef)

public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package uses a shared library that is not available.

Constant Value: -9 (0xfffffff7)

public static final int INSTALL_FAILED_NEWER_SDK

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because the current SDK version is newer than that required by the package.

Constant Value: -14 (0xfffffff2)

public static final int INSTALL_FAILED_NO_SHARED_USER

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the requested shared user does not exist.

Constant Value: -6 (0xfffffffa)

public static final int INSTALL_FAILED_OLDER_SDK

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because the current SDK version is older than that required by the package.

Constant Value: -12 (0xfffffff4)

public static final int INSTALL_FAILED_PACKAGE_CHANGED

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the package changed from what the calling program expected.

Constant Value: -23 (0xffffffe9)

public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package uses a shared library that is not available.

Constant Value: -10 (0xfffffff6)

public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package is requested a shared user which is already installed on the device and does not have matching signature.

Constant Value: -8 (0xfffffff8)

public static final int INSTALL_FAILED_TEST_ONLY

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package failed because it has specified that it is a test-only package and the caller has not supplied the INSTALL_ALLOW_TEST flag.

Constant Value: -15 (0xfffffff1)

public static final int INSTALL_FAILED_UID_CHANGED

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package is assigned a different UID than it previously held.

Constant Value: -24 (0xffffffe8)

public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if a previously installed package of the same name has a different signature than the new package (and the old package's data was not removed).

Constant Value: -7 (0xfffffff9)

public static final int INSTALL_FAILED_VERIFICATION_FAILURE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed because the verification did not succeed.

Constant Value: -22 (0xffffffea)

public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package couldn't be installed because the verification timed out.

Constant Value: -21 (0xffffffeb)

public static final int INSTALL_FAILED_VERSION_DOWNGRADE

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) if the new package has an older version code than the currently installed package.

Constant Value: -25 (0xffffffe7)

public static final int INSTALL_FORWARD_LOCK

Added in API level 1

Flag parameter for install(String, int) to indicate that this package should be installed as forward locked, i.e. only the app itself should have access to its code and non-resource assets.

Constant Value: 1 (0x00000001)

public static final int INSTALL_FROM_ADB

Added in API level 1

Flag parameter for install(String, int) to indicate that this install was initiated via ADB.

Constant Value: 32 (0x00000020)

public static final int INSTALL_INTERNAL

Added in API level 1

Flag parameter for install(String, int) to indicate that this package has to be installed on the sdcard.

Constant Value: 16 (0x00000010)

public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser was unable to retrieve the AndroidManifest.xml file.

Constant Value: -101 (0xffffff9b)

public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered a bad or missing package name in the manifest.

Constant Value: -106 (0xffffff96)

public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered a bad shared user id name in the manifest.

Constant Value: -107 (0xffffff95)

public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered a CertificateEncodingException in one of the files in the .apk.

Constant Value: -105 (0xffffff97)

public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser found inconsistent certificates on the files in the .apk.

Constant Value: -104 (0xffffff98)

public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser did not find any actionable tags (instrumentation or application) in the manifest.

Constant Value: -109 (0xffffff93)

public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered some structural problem in the manifest.

Constant Value: -108 (0xffffff94)

public static final int INSTALL_PARSE_FAILED_NOT_APK

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser was given a path that is not a file, or does not end with the expected '.apk' extension.

Constant Value: -100 (0xffffff9c)

public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser did not find any certificates in the .apk.

Constant Value: -103 (0xffffff99)

public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION

Added in API level 1

Installation parse return code: this is passed to the IPackageInstallObserver by install(String, int) if the parser encountered an unexpected exception.

Constant Value: -102 (0xffffff9a)

public static final int INSTALL_REPLACE_EXISTING

Added in API level 1

Flag parameter for install(String, int) to indicate that you want to replace an already installed package, if one exists.

Constant Value: 2 (0x00000002)

public static final int INSTALL_SUCCEEDED

Added in API level 1

Installation return code: this is passed to the IPackageInstallObserver by install(String, int) on success.

Constant Value: 1 (0x00000001)

Public Methods

public abstract boolean addAppToBlacklist (String packageName, String signature)

Added in API level 1

Adds the given application to the installation black list.

Parameters
packageName String: Application package name
signature String: Application package public signature. If public signature won't be used user can give null as parameter.
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean addAppToWhitelist (String packageName, String signature)

Added in API level 1

Adds the given application to the installation white list.

Parameters
packageName String: Application package name
signature String: Application package public signature. If public signature won't be used, user can give null as parameter.
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean addInstallPolicy (PolicyItem.PolicyName policyName, int policyOrder)

Added in API level 1

Adds the given policy to the installation policy list.

Parameters
policyName PolicyItem.PolicyName: PolicyItem.PolicyName is predefined policy types
policyOrder int: Order of policy which defines policy priority which is not unique parameter. There could be more than one policy which has same order so executing can be change due to same order. policyOrder can be any integer value without 0.
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean addTrustedSignature (String signature)

Added in API level 1

Adds the given trusted signature to the installation trusted signature list.

Parameters
signature String: Trusted signature
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean addTrustedStore (String store)

Added in API level 1

Adds the given trusted store to the installation trusted store list.

Parameters
store String: Trusted store package name
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearBlacklist ()

Added in API level 1

Clears all applications in the installation black list.

Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearInstallPolicies ()

Added in API level 1

Clears all policies in the installation policy list.

Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearTrustedSignatures ()

Added in API level 1

Clears all trusted signatures in the installation trusted signature list.

Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearTrustedStores ()

Added in API level 1

Clears all trusted stores in the installation trusted store list.

Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearWhitelist ()

Added in API level 1

Clears all applications in the installation white list.

Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract List<String> getBlacklist ()

Added in API level 1

Returns all applications in the installation black list.

Returns
List<String> List of application package name
Throws
AfexException

public abstract List<PolicyItem> getInstallPolicyList ()

Added in API level 1

Returns all policies in the installation policy list.

Returns
List<PolicyItem> List of installation PolicyItem
Throws
AfexException

public abstract List<String> getInstalledList ()

Added in API level 1

Returns installed application list.

Returns
List<String> List of installed application package names
Throws
AfexException

public abstract List<String> getTrustedSignatureList ()

Added in API level 1

Returns all trusted signatures in the installation trusted signatures list.

Returns
List<String> List of trusted signature hash.
Throws
AfexException

public abstract List<String> getTrustedStoreList ()

Added in API level 1

Returns all trusted stores in the installation trusted store list.

Returns
List<String> List of trusted store package name
Throws
AfexException

public abstract List<String> getWhitelist ()

Added in API level 1

Returns all applications in the installation black list.

Returns
List<String> List of application package name
Throws
AfexException

public abstract List<Integer> install (List<String> apkPathList, int installFlags)

Added in API level 1

Installs the given application list with specified installation flag.

Warning; Application installation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

Parameters
apkPathList List: Full path list of target applications
installFlags int: Possible values:
  • 0
  • INSTALL_FORWARD_LOCK
  • INSTALL_REPLACE_EXISTING
  • INSTALL_ALLOW_TEST
  • INSTALL_EXTERNAL
  • INSTALL_INTERNAL
  • INSTALL_FROM_ADB
  • INSTALL_ALL_USERS
  • INSTALL_ALLOW_DOWNGRADE
  • Returns
    List<Integer> Installation result in integer format as follows;
  • INSTALL_SUCCEEDED
  • INSTALL_FAILED_***
  • INSTALL_PARSE_FAILED_***
  • Throws
    AfexException

    public abstract List<Integer> install (List<String> apkPathList)

    Added in API level 1

    Installs the given application list with specified installation flag.

    Warning; Application installation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

    Parameters
    apkPathList List: Full path list of target applications
    Returns
    List<Integer> Installation result in integer format as follows;
  • INSTALL_SUCCEEDED
  • INSTALL_FAILED_***
  • INSTALL_PARSE_FAILED_***
  • Throws
    AfexException

    public abstract int install (String apkPath)

    Added in API level 1

    Installs the given application with default installation flag. If application already installed default flag is set to INSTALL_REPLACE_EXISTING else 0 Warning; Application installation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

    Parameters
    apkPath String: Full path of target application
    Returns
    int Installation result in integer format as follows;
  • INSTALL_SUCCEEDED
  • INSTALL_FAILED_***
  • INSTALL_PARSE_FAILED_***
  • Throws
    AfexException

    public abstract int install (String apkPath, int installFlags)

    Added in API level 1

    Installs the given application with specified installation flag.

    Warning; Application installation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

    Parameters
    apkPath String: Full path of target application
    installFlags int: Possible values:
  • 0
  • INSTALL_FORWARD_LOCK
  • INSTALL_REPLACE_EXISTING
  • INSTALL_ALLOW_TEST
  • INSTALL_EXTERNAL
  • INSTALL_INTERNAL
  • INSTALL_FROM_ADB
  • INSTALL_ALL_USERS
  • INSTALL_ALLOW_DOWNGRADE
  • Returns
    int Installation result in integer format as follows;
  • INSTALL_SUCCEEDED
  • INSTALL_FAILED_***
  • INSTALL_PARSE_FAILED_***
  • Throws
    AfexException

    public abstract String installResultToString (int result)

    Added in API level 1

    Returns passed installation result's enumaration name which is used for converting results in more understandable format.

    Parameters
    result int: Installation result in integer format
    Returns
    String Passed installation result's enumaration name

    public abstract boolean isInstallBlocked ()

    Added in API level 1

    Returns installation blocked state.

    Returns
    boolean true if installation blocked, else false
    Throws
    AfexException

    public abstract boolean isInstallBlocked (AppInstallItem item)

    Added in API level 1

    Checks if application complies with the current application installation policies. Installation policy list is used to check if application is installable or not. Prior to checking if application is installable or not, the user must execute the following steps to setup the installation policy. For example; the steps to add a blacklist policy are:

    Similar steps should be executed to set up the policies for whitelist and trustedstore.

    Parameters
    item AppInstallItem: AppInstallItem
    Returns
    boolean true if complies with the installation policies or no policies are defined else false
    Throws
    AfexException

    public abstract boolean isInstalled (String packageName)

    Added in API level 1

    Checks if the given application installed on the system or not.

    Parameters
    packageName String: Application package name
    Returns
    boolean true if the application has installed else false
    Throws
    AfexException

    public abstract boolean isNonMarketInstallBlocked ()

    Added in API level 1

    Returns non market install blocked state.

    Returns
    boolean true if non market install blocked, else false
    Throws
    AfexException

    public abstract boolean isNonMarketInstallEnabled ()

    Added in API level 1

    Returns non market installation state.

    Returns
    boolean true if non market installation enabled else false
    Throws
    AfexException

    public abstract boolean isPackageVerifierBlocked ()

    Added in API level 1

    Returns the package verifier blocked state.

    Returns
    boolean true if package verifier blocked, else false
    Throws
    AfexException

    public abstract boolean isPackageVerifierEnabled ()

    Added in API level 1

    Returns the package verifier state.

    Returns
    boolean true if package verifier enabled else false
    Throws
    AfexException

    public abstract boolean isUninstallBlocked ()

    Added in API level 1

    Returns uninstallation blocked state.

    Returns
    boolean true if uninstallation blocked, else false
    Throws
    AfexException

    public abstract boolean removeAppFromBlacklist (String packageName)

    Added in API level 1

    Removes the given application from the installation black list.

    Parameters
    packageName String: Application package name
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean removeAppFromWhitelist (String packageName)

    Added in API level 1

    Removes the given application from the installation white list.

    Parameters
    packageName String: Application package name
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean removeInstallPolicy (PolicyItem.PolicyName policyName)

    Added in API level 1

    Removes the given policy from the installation policy list.

    Parameters
    policyName PolicyItem.PolicyName: PolicyItem.PolicyName is predefined policy types
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean removeTrustedSignature (String signature)

    Added in API level 1

    Removes the given trusted signature from the installation trusted signature list.

    Parameters
    signature String: Trusted signature hash
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean removeTrustedStore (String store)

    Added in API level 1

    Removes the given trusted store from the installation trusted store list.

    Parameters
    store String: Trusted store package name
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setInstallBlocked (boolean state)

    Added in API level 1

    Sets system install state which blocks all application installation on the system regardless of any other attributes.

    Parameters
    state boolean: true to block installation, else false
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setNonMarketInstallBlocked (boolean state)

    Added in API level 1

    Sets system non market install state which blocks all non market installation on the system regardless of any other attributes.

    Parameters
    state boolean: true to block non market install, else false
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setNonMarketInstallEnabled (boolean enabled)

    Added in API level 1

    Sets non market installation enabled.

    Parameters
    enabled boolean: true to enable non market application installation, else false
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setPackageVerifierBlocked (boolean state)

    Added in API level 1

    Sets the package verifier blocked state.

    Parameters
    state boolean: true to block package verifier, else false
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setPackageVerifierEnabled (boolean enabled)

    Added in API level 1

    Sets the package verifier enabled.

    Parameters
    enabled boolean: true to enable package verifier else false
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setUninstallBlocked (boolean state)

    Added in API level 1

    Sets system uninstall state which blocks all application uninstallation on the system regardless of any other attributes.

    Parameters
    state boolean: true to block uninstallation, else false
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract List<Integer> uninstall (List<String> packageNameList, int uninstallFlags)

    Added in API level 1

    Uninstalls the given application list with specified uninstallation flag.

    Warning; Application uninstallation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

    Parameters
    packageNameList List: Application package name list
    uninstallFlags int: Possible values:
  • 0
  • DELETE_KEEP_DATA
  • DELETE_ALL_USERS
  • Returns
    List<Integer> Uninstallation result in integer format as follows;
  • DELETE_SUCCEEDED
  • DELETE_FAILED_***
  • Throws
    AfexException

    public abstract int uninstall (String packageName, int uninstallFlags)

    Added in API level 1

    Uninstalls the given application with specified uninstallation flag.

    Warning; Application uninstallation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

    Parameters
    packageName String: Application package name
    uninstallFlags int: Possible values:
  • 0
  • DELETE_KEEP_DATA
  • DELETE_ALL_USERS
  • Returns
    int Uninstallation result in integer format as follows;
  • DELETE_SUCCEEDED
  • DELETE_FAILED_***
  • Throws
    AfexException

    public abstract int uninstall (String packageName)

    Added in API level 1

    Uninstalls the given application.

    Warning; Application uninstallation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

    Parameters
    packageName String: Application package name
    Returns
    int Uninstallation result in integer format as follows;
  • DELETE_SUCCEEDED
  • DELETE_FAILED_***
  • Throws
    AfexException

    public abstract List<Integer> uninstall (List<String> packageNameList)

    Added in API level 1

    Uninstalls the given application list.

    Warning; Application uninstallation time can be change due to apk size so if apk size large than 10MB use this api in Thread and Handler to avoid ANR.

    Parameters
    packageNameList List: Application package name list
    Returns
    List<Integer> Uninstallation result in integer format as follows;
  • DELETE_SUCCEEDED
  • DELETE_FAILED_***
  • Throws
    AfexException

    public abstract String uninstallResultToString (int result)

    Added in API level 1

    Returns passed uninstallation result's enumaration name which is used for converting results in more understandable format.

    Parameters
    result int: Uninstallation result in integer format
    Returns
    String Passed uninstallation result's enumaration name