Class AndroidMobileCommandHelper


  • public class AndroidMobileCommandHelper
    extends MobileCommand
    This util class helps to prepare parameters of Android-specific JSONWP commands.
    • Constructor Detail

      • AndroidMobileCommandHelper

        public AndroidMobileCommandHelper()
    • Method Detail

      • currentActivityCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> currentActivityCommand()
        This method forms a Map of parameters for the getting of the current activity.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • currentPackageCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> currentPackageCommand()
        This method forms a Map of parameters for the getting of the current package.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • endTestCoverageCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> endTestCoverageCommand​(java.lang.String intent,
                                                                                                                                 java.lang.String path)
        This method forms a Map of parameters for the ending of the test coverage.
        Parameters:
        intent - intent to broadcast.
        path - path to .ec file.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • getSupportedPerformanceDataTypesCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> getSupportedPerformanceDataTypesCommand()
        returns the information type of the system state which is supported to read as like cpu, memory, network traffic, and battery.
        Returns:
        output - array like below [cpuinfo, batteryinfo, networkinfo, memoryinfo]
      • getPerformanceDataCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> getPerformanceDataCommand​(java.lang.String packageName,
                                                                                                                                    java.lang.String dataType,
                                                                                                                                    int dataReadTimeout)
        returns the resource usage information of the application. the resource is one of the system state which means cpu, memory, network traffic, and battery.
        Parameters:
        packageName - the package name of the application
        dataType - the type of system state which wants to read. It should be one of the supported performance data types, the return value of the function "getSupportedPerformanceDataTypes"
        dataReadTimeout - the number of attempts to read
        Returns:
        table of the performance data, The first line of the table represents the type of data. The remaining lines represent the values of the data. in case of battery info : [[power], [23]] in case of memory info : [[totalPrivateDirty, nativePrivateDirty, dalvikPrivateDirty, eglPrivateDirty, glPrivateDirty, totalPss, nativePss, dalvikPss, eglPss, glPss, nativeHeapAllocatedSize, nativeHeapSize], [18360, 8296, 6132, null, null, 42588, 8406, 7024, null, null, 26519, 10344]] in case of network info : [[bucketStart, activeTime, rxBytes, rxPackets, txBytes, txPackets, operations, bucketDuration,], [1478091600000, null, 1099075, 610947, 928, 114362, 769, 0, 3600000], [1478095200000, null, 1306300, 405997, 509, 46359, 370, 0, 3600000]] in case of network info : [[st, activeTime, rb, rp, tb, tp, op, bucketDuration], [1478088000, null, null, 32115296, 34291, 2956805, 25705, 0, 3600], [1478091600, null, null, 2714683, 11821, 1420564, 12650, 0, 3600], [1478095200, null, null, 10079213, 19962, 2487705, 20015, 0, 3600], [1478098800, null, null, 4444433, 10227, 1430356, 10493, 0, 3600]] in case of cpu info : [[user, kernel], [0.9, 1.3]]
      • getDisplayDensityCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> getDisplayDensityCommand()
        This method forms a Map of parameters to Retrieve the display density of the Android device.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • getNetworkConnectionCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> getNetworkConnectionCommand()
        This method forms a Map of parameters for the getting of a network connection value.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • getSystemBarsCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> getSystemBarsCommand()
        This method forms a Map of parameters to Retrieve visibility and bounds information of the status and navigation bars.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • isLockedCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> isLockedCommand()
        This method forms a Map of parameters for the finger print authentication invocation.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • fingerPrintCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> fingerPrintCommand​(int fingerPrintId)
        This method forms a Map of parameters for the finger print authentication invocation.
        Parameters:
        fingerPrintId - finger prints stored in Android Keystore system (from 1 to 10)
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • openNotificationsCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> openNotificationsCommand()
        This method forms a Map of parameters for the notification opening.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • setConnectionCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> setConnectionCommand​(long bitMask)
        This method forms a Map of parameters for the setting of device network connection.
        Parameters:
        bitMask - The bitmask of the desired connection
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • startActivityCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> startActivityCommand​(java.lang.String appPackage,
                                                                                                                               java.lang.String appActivity,
                                                                                                                               java.lang.String appWaitPackage,
                                                                                                                               java.lang.String appWaitActivity,
                                                                                                                               java.lang.String intentAction,
                                                                                                                               java.lang.String intentCategory,
                                                                                                                               java.lang.String intentFlags,
                                                                                                                               java.lang.String optionalIntentArguments,
                                                                                                                               boolean stopApp)
                                                                                                                        throws java.lang.IllegalArgumentException
        This method forms a Map of parameters for the activity starting.
        Parameters:
        appPackage - The package containing the activity. [Required]
        appActivity - The activity to start. [Required]
        appWaitPackage - Automation will begin after this package starts. [Optional]
        appWaitActivity - Automation will begin after this activity starts. [Optional]
        intentAction - Intent action which will be used to start activity [Optional]
        intentCategory - Intent category which will be used to start activity [Optional]
        intentFlags - Flags that will be used to start activity [Optional]
        optionalIntentArguments - Additional intent arguments that will be used to start activity [Optional]
        stopApp - Stop app on reset or not
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
        Throws:
        java.lang.IllegalArgumentException - when any required argument is empty
      • toggleLocationServicesCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> toggleLocationServicesCommand()
        This method forms a Map of parameters for the toggling of location services.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • unlockCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> unlockCommand()
        This method forms a Map of parameters for the element.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • replaceElementValueCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> replaceElementValueCommand​(org.openqa.selenium.remote.RemoteWebElement remoteWebElement,
                                                                                                                                     java.lang.String value)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        remoteWebElement - an instance which contains an element ID
        value - a new value
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • sendSMSCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> sendSMSCommand​(java.lang.String phoneNumber,
                                                                                                                         java.lang.String message)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        phoneNumber - The phone number of message sender
        message - The message content
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • gsmCallCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> gsmCallCommand​(java.lang.String phoneNumber,
                                                                                                                         GsmCallActions gsmCallActions)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        phoneNumber - The phone number of message sender
        gsmCallActions - One of available GSM call actions
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • gsmSignalStrengthCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> gsmSignalStrengthCommand​(GsmSignalStrength gsmSignalStrength)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        gsmSignalStrength - One of available GSM signal strength
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • gsmVoiceCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> gsmVoiceCommand​(GsmVoiceState gsmVoiceState)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        gsmVoiceState - One of available GSM voice state
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • networkSpeedCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> networkSpeedCommand​(NetworkSpeed networkSpeed)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        networkSpeed - One of possible NETWORK_SPEED values
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • powerCapacityCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> powerCapacityCommand​(int percent)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        percent - A number in range [0, 4]
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • powerACCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> powerACCommand​(PowerACState powerACState)
        This method forms a Map of parameters for the element value replacement. It is used against input elements
        Parameters:
        powerACState - One of available power AC state
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • toggleWifiCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> toggleWifiCommand()
        This method forms a Map of parameters for the toggling of wifi.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • toggleAirplaneCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> toggleAirplaneCommand()
        This method forms a Map of parameters for the toggle airplane mode.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.
      • toggleDataCommand

        public static java.util.Map.Entry<java.lang.String,​java.util.Map<java.lang.String,​?>> toggleDataCommand()
        This method forms a Map of parameters for the toggle data.
        Returns:
        a key-value pair. The key is the command name. The value is a Map command arguments.