public class Package extends AccountManager
silentPackageInstall.silentPackageUninstall.setPackageNameAndPermission.enablePackage.disablePackage.stopPackage.setWhitelistAppPermission. So it will allow runtime permission for the whitelisted package at installation.clearWhitelistAppPermission.clearAllWhitelistAppPermissionenableWhitelistPackages (new rule will be created or added to existing rule) and disableWhitelistPackages (all packages will be enabled)getPackageStatussetAppAutostartPinned, remove this setting using removeAppAutoStartPinned and get status of the pinned app using getAppAutoStartPinnedStatusreadSystemPropertysetSettingsPackageEnabledunregisterPackageInstallAPIListener,
unregisterPackageStatusChangeListener, unregisterPackageUninstallAPIListener,
Application Install Example:
1. Precondition: push the application package (apk file) to the sdcard partition on the device "adb push /sdcard/example.apk"
2. Get an auth token using getEloAccessToken
3. Install the application using silentPackageInstall. This process may take up to a minute. When complete, an install listener will register and will receive an update regarding the installation.
4. The installation listener will be automatically unregistered upon success
| Modifier and Type | Field and Description |
|---|---|
static int |
INSTALL_LISTENER_REGISTERED
Install listener has been registered and will be called when an app installation is complete
|
static int |
INSTALL_LISTENER_UNREGISTERED
Install listener was unregistered, no callback will be issued when an install completes
|
static int |
INSTALLER_RESULT_CODE
Used to send a response when a package installation is attempted.
|
static int |
LISTENER_REGISTRATION_ERROR
There was an error while trying to register the listener
|
static int |
PACKAGE_STATUS_CHANGE_CODE
Used to notify whether the package status changed successfully or not
|
static int |
PACKAGE_STATUS_CHANGE_LISTENER_CODE
Used to notify whether the listener has been registered or not
|
static int |
PACKAGE_STATUS_RESULT_CODE
Used to send the status of a given package (enabled or disabled)
|
static int |
SET_WHITELIST_APP_PERMISSION_RESULT_CODE
Used to notify whether the package app permission status changed successfully or not
|
static int |
SET_WHITELIST_RULE_RESULT_CODE
Used to notify whether package whitelist rule status change was successful or not
|
static int |
UNINSTALL_LISTENER_REGISTERED
Uninstall listener has been registered and will be called when a package is uninstalled
|
static int |
UNINSTALL_LISTENER_UNREGISTERED
Uninstall listener was unregistered, no callback will be issued when a package is uninstalled
|
ACCESS_TOKEN_INVALID, ACCESS_TOKEN_VALID, API_ACCESS_TOKEN_INVALID, API_ACCESS_TOKEN_VALID, instance, IS_USER_LOGIN_OAUTH, isPolaris, OAUTH_TOKEN_INVALID, OAUTH_TOKEN_VALID, REQUEST_AUTH_LOGIN, REQUEST_AUTH_LOGOUT, SETUP_OAUTH_ERROR, SETUP_OAUTH_SUCCESS, TOKEN_VERIFY_FAIL, TOKEN_VERIFY_SUCCESSGENERIC_ERROR, OAUTH_PATH_TOKEN, OAUTH_PATH_VERIFY| Constructor and Description |
|---|
Package() |
| Modifier and Type | Method and Description |
|---|---|
void |
bindService(android.content.Context context,
ServiceConnectionCallback callback,
java.lang.String accessToken)
This method is used to bind the service to the application.
|
boolean |
clearAllWhitelistAppPermission(boolean clearAllPackage)
This method used to clear all whitelisted packages so system don't allow runtime permissions on installation time.
|
boolean |
clearWhitelistAppPermission(java.lang.String packageName)
This method used to clear whitelisted packages so system don't allow runtime permissions on installation time.
|
boolean |
disablePackage(android.content.Context context,
java.lang.String packageName,
android.os.Handler handler)
This method is used to disable a given package.
|
boolean |
disableWhitelistPackages(android.content.Context context,
android.os.Handler handler)
This method is used to disable whitelisting rules for packages.
|
boolean |
enablePackage(android.content.Context context,
java.lang.String packageName,
android.os.Handler handler)
This method is used to enable the given package if it is currently installed
and is disabled.
|
boolean |
enableWhitelistPackages(android.content.Context context,
java.lang.String json,
android.os.Handler handler)
This method is used to set rules for enabling/disabling packages.
|
java.lang.String |
getAppAutoStartPinnedStatus()
API used to get information if the feature to auto start a task and lock it is currently enabled or not.
|
int |
getPackageStatus(java.lang.String packageName)
This method is used to check if a given package is enabled or disabled.
|
java.lang.String |
readSystemProperty(java.lang.String key)
Read system property
|
boolean |
removeAppAutostartPinned(java.lang.String password,
boolean tempUnlock)
API used to remove starting a task on boot and locking it.
|
boolean |
setAppAutostartPinned(java.lang.String newPassword,
java.lang.String oldPassword,
java.lang.String packageName)
API used to start a task on boot and lock it.
|
boolean |
setPackageNameAndPermission(java.lang.String packageName,
java.lang.String packagePermission)
This method is used to set Package name and Permission
|
void |
setSettingsPackageEnabled(android.content.Context context,
boolean enable,
android.os.Handler handler)
This method is used to enable/disable a settings package(com.android.settings).
|
boolean |
setWhitelistAppPermission(java.lang.String packageName)
This method used to whitelist the given package.
On package installation system will automatically allow runtime permissions for the whitelisted packages. So application doesn't popup runtime permission dialog. |
boolean |
silentPackageInstall(android.content.Context context,
java.lang.String accessToken,
java.lang.String uri,
android.os.Handler handler)
This method is used to install an APK silently in background
Registers a BroadcastReceiver to notify installation of apk is successful or not.
|
boolean |
silentPackageUninstall(android.content.Context context,
java.lang.String accessToken,
java.lang.String packageName,
android.os.Handler handler)
This method is used to uninstall package silently in background
Registers a listener for the package uninstallation status
|
boolean |
stopPackage(android.content.Context context,
java.lang.String packageName)
This method is used to stop a running package.
|
void |
unbindService(android.content.Context context)
This method is used to unbind the service from the application.
|
void |
unregisterPackageInstallAPIListener(android.content.Context context)
This method is used to unregister the broadcast receiver registered when the
silentPackageInstall(Context, String, String, Handler) (Context, String, Handler)} API.is used in your application. |
void |
unregisterPackageStatusChangeListener(android.content.Context context)
This method is used to unregister the broadcast receiver registered when using the
enablePackage(Context, String, Handler) and.disablePackage(Context, String, Handler) APIs in your application. |
void |
unregisterPackageUninstallAPIListener(android.content.Context context)
This method is used to unregister the broadcast receiver registered when the
silentPackageUninstall(Context, String, String, Handler) API.is used in your application. |
configureOAuthHostedUI, destroyOAuth, getBaseUri, getClientId, getEloAccessToken, getEloOAuthToken, getEnvironment, getProperty, isPolaris, isPolarisLocked, logoutOAuth, onOAuthActivityResult, selectEnvironment, setDefaultEnvironment, setProperty, stopOAuth, unregisterAccountManagerListener, verifyEloTokenclone, getEloIntentWithFlag, getMigrate, isDevice7Inch, isDeviceM100public static final int INSTALL_LISTENER_REGISTERED
public static final int UNINSTALL_LISTENER_REGISTERED
public static final int INSTALL_LISTENER_UNREGISTERED
public static final int UNINSTALL_LISTENER_UNREGISTERED
public static final int LISTENER_REGISTRATION_ERROR
public static final int INSTALLER_RESULT_CODE
public static final int PACKAGE_STATUS_CHANGE_LISTENER_CODE
public static final int PACKAGE_STATUS_CHANGE_CODE
public static final int PACKAGE_STATUS_RESULT_CODE
public static final int SET_WHITELIST_APP_PERMISSION_RESULT_CODE
public static final int SET_WHITELIST_RULE_RESULT_CODE
public java.lang.String readSystemProperty(java.lang.String key)
key - key of system propertypublic boolean enableWhitelistPackages(android.content.Context context,
java.lang.String json,
android.os.Handler handler)
context - A context object of the calling Class (Activity/Service).json - A json object containing the whitelist rules (eg: package name, type (package launching), action (allow, block). Refer test app for example)handler - A handler to receive one or more of the following callback messages:
AccountManager.TOKEN_VERIFY_FAIL
Consts.GENERIC_ERROR
SET_WHITELIST_APP_PERMISSION_RESULT_CODE
public boolean disableWhitelistPackages(android.content.Context context,
android.os.Handler handler)
context - A context object of the calling Class (Activity/Service).handler - A handler to receive one or more of the following callback messages:
AccountManager.TOKEN_VERIFY_FAIL
Consts.GENERIC_ERROR
SET_WHITELIST_APP_PERMISSION_RESULT_CODE
public boolean silentPackageInstall(android.content.Context context,
java.lang.String accessToken,
java.lang.String uri,
android.os.Handler handler)
context - A context object of the calling Class (Activity/Service).accessToken - An offline JWT Token.uri - A uri pointing to the apk file which needs to be installed
silentlyhandler - A handler to receive one or more of the following callback messages:
AccountManager.TOKEN_VERIFY_FAIL
Consts.GENERIC_ERROR
INSTALL_LISTENER_REGISTERED
INSTALLER_RESULT_CODE
public boolean setPackageNameAndPermission(java.lang.String packageName,
java.lang.String packagePermission)
packageName - PackageName of the application needing permissionspackagePermission - List of Permissions to be granted, separated by a colon ":"public boolean silentPackageUninstall(android.content.Context context,
java.lang.String accessToken,
java.lang.String packageName,
android.os.Handler handler)
context - A context object of the calling Class (Activity/Service).accessToken - An offline JWT Token.packageName - The name of the package that needs to be uninstalledhandler - A handler to receive one or more of the following callback messages:
AccountManager.TOKEN_VERIFY_FAIL
Consts.GENERIC_ERROR
UNINSTALL_LISTENER_REGISTERED
INSTALLER_RESULT_CODE
public boolean stopPackage(android.content.Context context,
java.lang.String packageName)
context - A context object of the calling Class (Activity/Service).packageName - The name of the package that needs to be stopped/killedpublic boolean disablePackage(android.content.Context context,
java.lang.String packageName,
android.os.Handler handler)
context - A context object of the calling Class (Activity/Service).packageName - package name that is to be disablehandler - A handler to receive one or more of the following callback messages:
AccountManager.TOKEN_VERIFY_FAIL
Consts.GENERIC_ERROR
LISTENER_REGISTRATION_ERROR
PACKAGE_STATUS_CHANGE_CODE
Note: Only the following system packages will be allowed to be disabled as disabling
some of the system apps may interfere with the core OS functionality.
com.android.providers.calendar
com.android.wallpapercropper
com.android.messaging
com.oem.camera
com.android.providers.userdictionary
org.codeaurora.gallery
com.android.dreams.phototable
com.android.dialer
com.elotouch.paypointdiagnostics
org.codeaurora.bluetooth
com.android.musicfx
com.android.music
com.android.providers.telephony
com.android.phone
com.android.mms.service
com.android.providers.media
com.android.wallpaper.livepicker
com.android.keychain
com.android.documentsui
com.android.htmlviewer
com.android.location.fused
com.android.emergency
com.example.eloViewSDKTestApp
com.elo.peripheral
com.elotouch.miami.testapp
com.elo.homescreen
com.android.providers.downloads.ui
com.android.providers.downloads
com.veniosg.dir
com.android.bips
com.android.systemui.theme.dark
com.android.providers.contacts
com.oem.location
com.android.wallpaperbackup
com.android.smspush
com.android.carrierconfig
com.android.deskclock
com.android.cellbroadcastreceiver
com.android.carrierdefaultapp
com.android.server.telecom
com.android.calllogbackup
com.android.calendar
com.android.calculator2
com.android.bookmarkprovider
com.android.bluetooth
com.android.bluetoothmidiservice
com.android.providers.blockednumber
com.dsi.ant.server
com.android.webview
com.android.egg
com.sis.autotool
com.google.android.calendar
public void setSettingsPackageEnabled(android.content.Context context,
boolean enable,
android.os.Handler handler)
context - A context object of the calling Class (Activity/Service).enable - package state that is to be true/false.handler - A handler to receive one or more of the following callback messages:
AccountManager.TOKEN_VERIFY_FAIL
Consts.GENERIC_ERROR
LISTENER_REGISTRATION_ERROR
PACKAGE_STATUS_CHANGE_CODE
public boolean enablePackage(android.content.Context context,
java.lang.String packageName,
android.os.Handler handler)
context - A context object of the calling Class (Activity/Service).packageName - package name that is to be enablehandler - A handler to receive one or more of the following callback messages:
AccountManager.TOKEN_VERIFY_FAIL
Consts.GENERIC_ERROR
LISTENER_REGISTRATION_ERROR
PACKAGE_STATUS_CHANGE_CODE
public int getPackageStatus(java.lang.String packageName)
packageName - PackageName of the package user needs to know is enabled or disabledpublic boolean setAppAutostartPinned(java.lang.String newPassword,
java.lang.String oldPassword,
java.lang.String packageName)
newPassword - new PIN to be set for unpinning an appoldPassword - old PIN which was set for unpinning an app. This is required while changing the pin. This can be empty if it's the first time setting
the pin.packageName - List of apps to use for auto start and pinning on boot in a decreasing order of prioritypublic boolean removeAppAutostartPinned(java.lang.String password,
boolean tempUnlock)
password - device pin required to unlock the tasktempUnlock - A boolean value indicating whether the task should be unlocked temporarily (true) or permanently (false).public java.lang.String getAppAutoStartPinnedStatus()
public boolean setWhitelistAppPermission(java.lang.String packageName)
After applying change on install time whitelisted package will grant all permissions automatically.
packageName - WhiteListPackageNamepublic boolean clearWhitelistAppPermission(java.lang.String packageName)
packageName - Stringpublic boolean clearAllWhitelistAppPermission(boolean clearAllPackage)
clearAllPackage - booleanpublic void unregisterPackageInstallAPIListener(android.content.Context context)
silentPackageInstall(Context, String, String, Handler) (Context, String, Handler)} API.silentPackageInstall(Context, String, String, Handler) API. This ensures the receiver is not leaked.context - Context in which the Network APIs were usedpublic void unregisterPackageUninstallAPIListener(android.content.Context context)
silentPackageUninstall(Context, String, String, Handler) API.silentPackageUninstall(Context, String, String, Handler) API. This ensures the receiver is not leaked.context - Context in which the Network APIs were usedpublic void unregisterPackageStatusChangeListener(android.content.Context context)
enablePackage(Context, String, Handler) and.disablePackage(Context, String, Handler) APIs in your application.
Please make sure to call this in the "onPause" and "onDestroy" methods in your activity Lifecycle if you made use of
any of these two APIs. This ensures the receiver is not leaked.context - Context in which the Network APIs were usedpublic void bindService(android.content.Context context,
ServiceConnectionCallback callback,
java.lang.String accessToken)
context - Context in which the Network APIs were usedcallback - ServiceConnectionCallbackaccessToken - Stringpublic void unbindService(android.content.Context context)
context - Context in which the Network APIs were used