Obtaining App Info
The Anti-Malware feature, and several RASP features, return a list of apps. The apps installed on the device are primarily identified by their application IDs (package names). For convenience, we provide a utility method for obtaining application info, that is useful for displaying in the UI.
You can use the utility method by calling:
val appInfo: AppInfo? = AppInfoUtils.getAppInfo(context, packageName, getPermissions)
Note that the method should be called only on a worker thread or on an appropriate coroutine dispatcher.
The last argument of the method indicates whether to get the list of required permissions. App’s required permissions are declared with <uses-permission>
in the app’s AndroidManifest.xml file. The last argument has a default value false
, so it’s optional to use (in Kotlin) when you don’t want the required permissions. Then, you can call it with:
val appInfo: AppInfo? = AppInfoUtils.getAppInfo(context, packageName)
When the app with the given application ID (package name) cannot be found on the device, the method returns ‘null’.
Argument | Default value | Description |
---|---|---|
context: Context |
the application context. | |
packageName: String |
the application ID (package name) of the app. | |
getPermission: Boolean |
false |
indicate whether to fetch list of requried permissions. When ‘false’ the returned list is empty. |
The returned AppInfo
data class contains the following properties:
Property | Description |
---|---|
packageName: String |
contains the app’s application ID (package name). |
appName: String |
contains the application name obtained from the system. The application name will be localized according to the currently used device localization. |
icon: Drawable |
contains a drawable of the application icon. |
permissions: Collection<String> |
contains a list of required application permissions (declared with <uses-permission> permission tags in the application’s AndroidManifest.xml). |