Class AppManagementCtrl


  • public class AppManagementCtrl
    extends java.lang.Object
    *Need to install AppCtrlService to use this controller. This controller provide the ability to manage the applications on device. This controller can install, uninstall, enable, disable, activate, deactivate the applications. This controller can also get the app list which is running, installed or belonging to system.
    • Constructor Summary

      Constructors 
      Constructor Description
      AppManagementCtrl​(android.content.Context context)
      Instantiates a new AppManagementCtrl.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      android.os.Bundle activateApp​(java.lang.String pkgName)
      Activate an app on device.
      android.os.Bundle clearAppData​(java.lang.String pkgName)
      Clear the storage data and the cache data of the app.
      android.os.Bundle clearDefaultApps​(java.lang.String[] packages)
      Clear the settings of the preferred apps by giving the package name list
      android.os.Bundle clearDefaultApps​(java.lang.String action, java.lang.String[] categories)
      Clear the settings of the preferred apps by giving the filter (action and categories)
      android.os.Bundle deactivateApp​(java.lang.String pkgName)
      Deactivate an app on device.
      android.os.Bundle disableApp​(java.lang.String pkgName)
      Disable an app on device.
      android.os.Bundle enableApp​(java.lang.String pkgName)
      Enable an app on device.
      android.os.Bundle getAppInfoByAppName​(java.lang.String appName)
      Get the app version name and version code by the app name (App label)
      android.os.Bundle getAppInfoByPkgName​(java.lang.String pkgName)
      Get the app version name and version code by the package name
      java.lang.String getAppPackageName​(java.lang.String apkPath)  
      android.os.Bundle getBuiltinSystemAppNameList()
      Get the built-in system apps list with their app name (Only return apps which have app label)
      android.os.Bundle getBuiltinSystemPkgNameList()
      Get the built-in system apps list with their package name
      android.os.Bundle getDisabledAppNameList()
      Get the disabled apps list with their app name (Only return apps which have app label)
      android.os.Bundle getDisabledPkgNameList()
      Get the disabled apps list with their package name
      android.os.Bundle getInstallAppNameList()
      Get the installed apps list with their app name (Only return apps which have app label)
      android.os.Bundle getInstallPkgNameList()
      Get the installed apps list with their package name
      android.os.Bundle getRunningAppNameList()
      Get the current running apps list with their app name (Only return apps which have app label)
      android.os.Bundle getRunningPkgNameList()
      Get the current running apps list with their package name
      android.os.Bundle installApp​(java.lang.String apkFilePath, java.lang.String pkgName)
      Install an application by the apk that user mention tha apk file path.
      android.os.Bundle osUpdate​(java.lang.String updateZipPath)
      Update device's OS by the zip file
      android.os.Bundle removeApp​(java.lang.String pkgName)
      Remove an app from device
      android.os.Bundle runSysCmd​(java.lang.String command)
      Run shell command with system user
      android.os.Bundle setDefaultApp​(java.lang.String action, java.lang.String[] categories, java.lang.String packageName, java.lang.String activityName)
      Set the preferred app with the given filter (action and categories)
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BUNDLE_ERROR_CODE

        public static final java.lang.String BUNDLE_ERROR_CODE
        See Also:
        Constant Field Values
      • BUNDLE_ERROR_MSG

        public static final java.lang.String BUNDLE_ERROR_MSG
        See Also:
        Constant Field Values
      • BUNDLE_RESULT_APP_NAME_LIST

        public static final java.lang.String BUNDLE_RESULT_APP_NAME_LIST
        See Also:
        Constant Field Values
      • BUNDLE_RESULT_PKG_NAME_LIST

        public static final java.lang.String BUNDLE_RESULT_PKG_NAME_LIST
        See Also:
        Constant Field Values
      • BUNDLE_RESULT_CMD

        public static final java.lang.String BUNDLE_RESULT_CMD
        See Also:
        Constant Field Values
      • BUNDLE_RESULT_APP_INFO

        public static final java.lang.String BUNDLE_RESULT_APP_INFO
        See Also:
        Constant Field Values
    • Constructor Detail

      • AppManagementCtrl

        public AppManagementCtrl​(android.content.Context context)
        Instantiates a new AppManagementCtrl.
        Parameters:
        context - the context
    • Method Detail

      • getAppPackageName

        public java.lang.String getAppPackageName​(java.lang.String apkPath)
      • installApp

        public android.os.Bundle installApp​(java.lang.String apkFilePath,
                                            java.lang.String pkgName)
        Install an application by the apk that user mention tha apk file path.
        Parameters:
        apkFilePath - The path where is the apk file at.
        pkgName - The package name of the apk
        Returns:
        A bundle contains the error code and message
        int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • removeApp

        public android.os.Bundle removeApp​(java.lang.String pkgName)
        Remove an app from device
        Parameters:
        pkgName - The package name of the app that you want to remove.
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • activateApp

        public android.os.Bundle activateApp​(java.lang.String pkgName)
        Activate an app on device.
        Parameters:
        pkgName - The package name of the app that you want to activate.
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • deactivateApp

        public android.os.Bundle deactivateApp​(java.lang.String pkgName)
        Deactivate an app on device.
        Parameters:
        pkgName - The package name of the app that you want to deactivate.
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • enableApp

        public android.os.Bundle enableApp​(java.lang.String pkgName)
        Enable an app on device.
        Parameters:
        pkgName - The package name of the app that you want to enable.
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • disableApp

        public android.os.Bundle disableApp​(java.lang.String pkgName)
        Disable an app on device.
        Parameters:
        pkgName - The package name of the app that you want to disable.
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • clearAppData

        public android.os.Bundle clearAppData​(java.lang.String pkgName)
        Clear the storage data and the cache data of the app.
        Parameters:
        pkgName - The package name of the app that you want to clear. PackageName Array, (split with , ) (example: com.ute.eu.ELauncher,com.unitech.unote)
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • getRunningAppNameList

        public android.os.Bundle getRunningAppNameList()
        Get the current running apps list with their app name (Only return apps which have app label)
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("AppNameList");
      • getRunningPkgNameList

        public android.os.Bundle getRunningPkgNameList()
        Get the current running apps list with their package name
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("PkgNameList");
      • getInstallAppNameList

        public android.os.Bundle getInstallAppNameList()
        Get the installed apps list with their app name (Only return apps which have app label)
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("AppNameList");
      • getInstallPkgNameList

        public android.os.Bundle getInstallPkgNameList()
        Get the installed apps list with their package name
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("PkgNameList");
      • getBuiltinSystemAppNameList

        public android.os.Bundle getBuiltinSystemAppNameList()
        Get the built-in system apps list with their app name (Only return apps which have app label)
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("AppNameList");
      • getBuiltinSystemPkgNameList

        public android.os.Bundle getBuiltinSystemPkgNameList()
        Get the built-in system apps list with their package name
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("PkgNameList");
      • getDisabledAppNameList

        public android.os.Bundle getDisabledAppNameList()
        Get the disabled apps list with their app name (Only return apps which have app label)
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("AppNameList");
      • getDisabledPkgNameList

        public android.os.Bundle getDisabledPkgNameList()
        Get the disabled apps list with their package name
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        StringArrayList strAL = bundle.getStringArrayList("PkgNameList");
      • osUpdate

        public android.os.Bundle osUpdate​(java.lang.String updateZipPath)
        Update device's OS by the zip file
        Parameters:
        updateZipPath - The zip path of the OS OTA pack
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • runSysCmd

        public android.os.Bundle runSysCmd​(java.lang.String command)
        Run shell command with system user
        Parameters:
        command - The shell command
        Returns:
        Bundle contain BUNDLE_ERROR_CODE, BUNDLE_ERROR_MSG, BUNDLE_RESULT_CMD
      • getAppInfoByAppName

        public android.os.Bundle getAppInfoByAppName​(java.lang.String appName)
        Get the app version name and version code by the app name (App label)
        Parameters:
        appName - The app name that you want to get its information
        Returns:
        Bundle contain BUNDLE_ERROR_CODE, BUNDLE_ERROR_MSG, BUNDLE_RESULT_APP_INFO
      • getAppInfoByPkgName

        public android.os.Bundle getAppInfoByPkgName​(java.lang.String pkgName)
        Get the app version name and version code by the package name
        Parameters:
        pkgName - The package name that you want to get its information
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
        Bundle bundle = bundle.getBundle("AppInfo");
      • setDefaultApp

        public android.os.Bundle setDefaultApp​(java.lang.String action,
                                               java.lang.String[] categories,
                                               java.lang.String packageName,
                                               java.lang.String activityName)
        Set the preferred app with the given filter (action and categories)
        Parameters:
        action -
        categories -
        packageName - The package name of the target app
        activityName - The target activity in the package
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • clearDefaultApps

        public android.os.Bundle clearDefaultApps​(java.lang.String[] packages)
        Clear the settings of the preferred apps by giving the package name list
        Parameters:
        packages - All the package names that you want to clear
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");
      • clearDefaultApps

        public android.os.Bundle clearDefaultApps​(java.lang.String action,
                                                  java.lang.String[] categories)
        Clear the settings of the preferred apps by giving the filter (action and categories)
        Parameters:
        action - The action that the intent-filter needs to query
        categories - The categories that the intent-filter needs to query
        Returns:
        A bundle contains the error code and message
        int erroeCode = bundle.getInt("errorCode"), (error:1, success=0)
        String errorMsg = bundle.getString("errorMsg");