Ejemplo n.º 1
0
    def installAPK(self, device_id=None, apk_full_path=None):
        """Performs the installation of an APK file"""
        if apk_full_path is None:
            Log.warn(self.__class__, 'The supplied path of apk is invalid')
            return

        command = 'install {apkpath}'.format(apkpath=apk_full_path)

        result = self.__execute_adb_cmd__(command)
        Log.info(self.__class__, result, device_id)
Ejemplo n.º 2
0
    def uninstall_app(self, device_id=None, package_name=None):
        """Performs the uninstall of an application """
        if package_name is None:
            Log.warn(self.__class__, 'The supplied PackageName is invalid')
            return

        command = "uninstall {package}".format(package=package_name)

        result = self.__execute_adb_cmd__(command, device_id)
        Log.info(self.__class__, result.decode())
Ejemplo n.º 3
0
 def get_app_info(self, device_id, package_name, full_info=False):
     """Get system state associated with the given PACKAGE"""
     if package_name is None:
         Log.warn(self.__class__, 'The supplied PackageName is invalid')
         return
     if full_info:
         command = "shell pm dump {package}".format(package=package_name)
     else:
         command = "shell dumpsys package {package}".format(package=package_name)
     return self.__execute_adb_cmd__(command, device_id)
Ejemplo n.º 4
0
    def get_app_state(self, device_id=None, package_name=None):
        """Check is a certain application is enabled"""
        if package_name is None:
            Log.warn(self.__class__, 'The supplied PackageName is invalid')
            return

        command = "shell pm list packages -e {package}".format(package=package_name)

        result = self.__execute_adb_cmd__(command, device_id).decode()
        filtered_apps = Utils.replace_all(result, {'\r': '', 'package:': ''}).splitlines()

        if package_name in filtered_apps:
            return EzADB.State.ENABLED
        else:
            return EzADB.State.DISABLED
Ejemplo n.º 5
0
    def enable_disable_app(self, device_id, package_name, app_state):
        """Enables/Disables a certain application/component """
        if package_name is None:
            Log.warn(self.__class__, 'The supplied PackageName is invalid')
            return

        # Type checking
        if not isinstance(app_state, EzADB.State):
            raise TypeError('appState must be an instance of State Enum')

        command = "shell pm {state} {package}" \
            .format(state="enable" if EzADB.State.ENABLED == app_state else "disable", package=package_name)

        result = self.__execute_adb_cmd__(command, device_id)
        Log.info(self.__class__, result.decode())