Exemplo n.º 1
0
        private void Devices(out string retValue)
        {
            string adbResult;

            AdbCommand.ExecuteAdbCommand("get-state", out adbResult);
            retValue = "Res=" + adbResult.Trim();
        }
Exemplo n.º 2
0
        private void ExecuteAdbShellCmd(string param, out string retValue)
        {
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell " + param, out adbResult);
            retValue = "Res=Pass";
        }
Exemplo n.º 3
0
        private void Pull(string param, out string retValue)
        {
            string pullParam = param.Substring("pull".Length);
            string adbResult;

            AdbCommand.ExecuteAdbCommand("pull" + pullParam, out adbResult);
            retValue = "Res=Pass";
        }
Exemplo n.º 4
0
        private void ScreenCapture(string param, out string retValue)
        {
            string filename = param.Substring("snap".Length + 1);
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell screencap " + filename, out adbResult);
            retValue = "Res=Pass";
        }
Exemplo n.º 5
0
        /// <summary>
        /// execute adb shell input tap x y
        /// </summary>
        private void TouchScreen(string param, out string retValue)
        {
            string tapParam = param.Substring("touch".Length + 1);
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell input tap " + tapParam, out adbResult);
            retValue = "Res=Pass";
        }
Exemplo n.º 6
0
        /// <summary>
        /// execute adb shell input swipe x1 y1 x2 y2
        /// </summary>
        /// <param name="param"></param>
        /// <param name="retValue"></param>
        private void Swipe(string param, out string retValue)
        {
            string swipeParam = param.Substring("swipe".Length + 1);
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell input swipe " + swipeParam, out adbResult);
            retValue = "Res=Pass";
        }
Exemplo n.º 7
0
        /// <summary>
        /// start android.settings.LOCATION_SOURCE_SETTINGS activity, then touch gps switch button
        /// </summary>
        /// <param name="param"></param>
        /// <param name="retValue"></param>
        private void CtrlGps(string param, out string retValue)
        {
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell am start -a android.settings.LOCATION_SOURCE_SETTINGS", out adbResult);

            string locationXY = param.Substring("ctrlGPS".Length + 1);
            string command    = "shell input tap " + locationXY;

            AdbCommand.ExecuteAdbCommand(command);
            retValue = "Res=Pass";
        }
Exemplo n.º 8
0
        /// <summary>
        /// start android.settings.WIFI_SETTINGS activity, then touch wifi switch button
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="retValue"></param>
        private void OpenWifiSettings(string param, out string retValue)
        {
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell am start -a android.settings.WIFI_SETTINGS", out adbResult);

            string locationXY = param.Substring("openwifiset".Length + 1);
            string command    = "shell input tap " + locationXY;

            AdbCommand.ExecuteAdbCommand(command);
            retValue = "Res=Pass";
        }
Exemplo n.º 9
0
        private void GetProp(string name, int start, int length, out string retValue)
        {
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell getprop " + name, out adbResult);

            if (start >= adbResult.Length)
            {
                retValue = "Res=ArgumentException";
            }
            else
            {
                length   = Math.Min(length, adbResult.Length - start);
                retValue = "Res=" + adbResult.Substring(start, length);
            }
        }
Exemplo n.º 10
0
        private void GetFocusedActivity(out string retValue)
        {
            string adbResult;

            AdbCommand.ExecuteAdbCommand("shell dumpsys activity | grep mResumedActivity", out adbResult);

            int pos = adbResult.IndexOf("/.");

            if (pos != -1)
            {
                string firstHalf = adbResult.Substring(0, pos);
                string lastHalf  = adbResult.Substring(pos);

                int begin = firstHalf.LastIndexOf(' ') + 1;
                int end   = lastHalf.IndexOf(' ') + pos;

                retValue = "Res=" + adbResult.Substring(begin, end - begin);
            }
            else
            {
                retValue = "Res=ActivityNotFound";
            }
        }