Exemplo n.º 1
0
        public void WatchDirectory(string dir)
        {
            var adb = new AdbClient(AdbServer.Instance.EndPoint);

            try
            {
                adb.ExecuteRemoteCommand("mkdir /data/local/tmp/img", slave.Device, null);
            }
            catch { }
            Dispatcher.BackgroundThread(() =>
            {
                while (true)
                {
                    Thread.Sleep(500);
                    var o = AdbClient.Instance.ExecuteRemoteCommandSync(slave.Device, $"test -e {dir}/* && echo '1';");
                    if (o.Contains("1"))
                    {
                        o         = adb.ExecuteRemoteCommandSync(slave.Device, $"ls -l {dir}/*");
                        var lines = Regex.Split(o, "\r\n");
                        foreach (var l in lines)
                        {
                            if (string.IsNullOrWhiteSpace(l))
                            {
                                continue;
                            }

                            var idx      = l.LastIndexOf(" ") + 1;
                            var fileName = l.Substring(idx, l.Length - idx);
                            DirFileDetected?.Invoke(slave, dir + "/" + fileName);
                            adb.ExecuteRemoteCommandSync(slave.Device, $"su -c 'rm -f {dir}/{fileName}'");
                        }
                    }
                }
            });
        }
Exemplo n.º 2
0
        private void Overseer_DirFileDetected(Slave arg1, string arg2)
        {
            var sync = new SyncService(arg1.Device);
            var info = new FileInfo(arg2);
            var adb  = new AdbClient(AdbServer.Instance.EndPoint);

            adb.ExecuteRemoteCommandSync(arg1.Device, $"su -c 'chmod 777 {arg2}'");
            sync.Pull(arg2, File.Create(Program.varDir + @"\snapshot\" + info.Name), CancellationToken.None);
        }