Пример #1
0
        private Adb(Adb adb, string command, params object[] parameters)
        {
            _adbExecutablePath = adb._adbExecutablePath;
            _processManager    = adb._processManager;

            AdbCommandBuilder = new StringBuilder(adb.AdbCommandBuilder.ToString());
            AdbCommandBuilder.Append(" ");
            AdbCommandBuilder.AppendFormat(command, parameters);
        }
Пример #2
0
        public async Task RemoveUser(string userId, CancellationToken cancellationToken = default(CancellationToken))
        {
            var adb   = new Adb(this, "remove-user {0}", userId);
            var lines = (await adb.RunAsync(cancellationToken: cancellationToken)).ToLines().ToList();

            if (lines.Count < 1 || lines[0].StartsWith("Error", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new AdbException("Error removing user", adb);
            }
        }
Пример #3
0
 public IObservable <string> Logcat(LogcatOptions options  = LogcatOptions.None,
                                    LogOutputFormat format = LogOutputFormat.Brief,
                                    CancellationToken cancellationToken = default(CancellationToken), params LogFilter[] filters)
 {
     using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
     {
         string formatString  = format == LogOutputFormat.Brief ? string.Empty : string.Format("-v {0}", format.ToString().ToLower());
         string filtersString = filters.Aggregate("", (acc, f) => acc + " " + f.ToString());
         var    process       = new Adb(this, "logcat {0} {1} {2}", options.GenerateString(), formatString, filtersString).CreateProcess(AdbExecutablePath, cts, 0, false);
         process.RunAsync(cts.Token);
         return(process.Output);
     }
 }
Пример #4
0
        public async Task Restore(string backupFile, Action <string> outputHandler, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
            {
                var         process      = new Adb(this, "restore {0}", backupFile.QuoteIfNeeded()).CreateProcess(AdbExecutablePath, cts, 0, false);
                IDisposable subscription = null;
                if (outputHandler != null)
                {
                    subscription = process.Output.Subscribe(outputHandler);
                }
                await process.RunAsync(cancellationToken);

                if (subscription != null)
                {
                    subscription.Dispose();
                }
            }
        }
Пример #5
0
        public async Task <int> GetMaxUsers(CancellationToken cancellationToken = default(CancellationToken))
        {
            var adb   = new Adb(this, "get-max-users");
            var lines = (await adb.RunAsync(cancellationToken: cancellationToken)).ToLines().ToList();

            if (lines.Count < 1)
            {
                throw new AdbException(adb);
            }

            string maxUsersString = lines[0].Replace("Maximum supported users:", "").Trim();
            int    maxUsers;

            if (!int.TryParse(maxUsersString, out maxUsers))
            {
                throw new AdbException("Invalid output format", adb);
            }

            return(maxUsers);
        }