Example #1
0
        public bool IsAppInstalled() //TODO - should take Device in constructor and check it for specific device
        {
            string       command = "adb shell cmd package list packages";
            StreamReader sr      = CommandLineExecutor.ExecuteCommandGetOutput(command);

            string tempLine = "";

            while (sr.Peek() != -1)
            {
                tempLine = sr.ReadLine();
                if (tempLine.Contains(Settings.chosenApp))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        public List <Device> GetConnectedDevices()
        {
            List <Device> ConnectedDevices = new List <Device>();
            StreamReader  sr       = CommandLineExecutor.ExecuteCommandGetOutput("adb devices");
            string        tempLine = "";

            while (sr.Peek() != -1)
            {
                tempLine = sr.ReadLine();
                //if there is a device connected with correct status
                if (tempLine.Contains("device") && !tempLine.Contains("devices"))
                {
                    Device device = new Device();
                    device.status = Device.Status.Ready;
                    device.serial = tempLine.Remove(tempLine.Length - 7);
                    ConnectedDevices.Add(device);
                }
                // if there is a device but with incorrect status
                else if (tempLine.Contains("offline"))
                {
                    Device device = new Device();
                    device.status = Device.Status.Offline;
                    device.serial = tempLine.Remove(tempLine.Length - 8);
                    ConnectedDevices.Add(device);
                }
                else if (tempLine.Contains("unauthorized"))
                {
                    Device device = new Device();
                    device.status = Device.Status.Unauthorized;
                    device.serial = tempLine.Remove(tempLine.Length - 13);
                    ConnectedDevices.Add(device);
                }
            }

            return(ConnectedDevices);
        }