public static string ReadFile(string remote) { var cmd = CliCommand.Create(CliScope.AdbShell, "cat {0}", remote); var res = CliResult.Run(cmd, CliDataType.String); return(res.String); }
private static CCRecord ReadRecord(CCArguments args) { string ddCmdStr = args.Compile(); ddCmdStr = String.Format("\"{0}\"", ddCmdStr); var ddCmd = CliCommand.Create(CliScope.AdbExecOut, ddCmdStr); var ddRes = CliResult.Run(ddCmd, CliDataType.ByteArray); var ccRec = new CCRecord(); lock (ccRec) { ccRec.BinaryRaw = ddRes.ByteArray; //ccRec.StatsRaw = Android.Value.ReadFile(args.StatsRedirect); } //ddRes.CommandProcess.Close(); //ddRes.CommandProcess.WaitForExit(); //ddRes.CommandProcess.Kill(); return(ccRec); }
public static void Reset() { // adb shell "rm /data/local/tmp/busybox" CliCommand rmCmd = CliCommand.Create(CliScope.AdbShell, "rm {0}", REMOTE_BUSYBOX_EXE); var rmResult = CliResult.Run(rmCmd); }
public static string GetFileSha1Hash(string remote) { var cmd = CliCommand.Create(CliScope.AdbShell, "sha1sum \"{0}\"", remote); var res = CliResult.Run(cmd, CliDataType.String); var hash = res.String.Split(" ")[0]; return(hash.ToUpper()); }
public static long GetFileSize(string s) { // sprintf(buf, "wc -c < \"%s\"", remoteFile); var cmd = CliCommand.Create(CliScope.AdbShell, "\"wc -c < \"{0}\"\"", s); var res = CliResult.Run(cmd, CliDataType.String); //Console.WriteLine(res.Data); var n = long.Parse((string)res.Data); return(n); }
private static string?GetSerial() { var devices = CliCommand.Create(CliScope.Adb, "devices"); var devicesResult = CliResult.Run(devices, CliDataType.StringArray); var resultLines = devicesResult.StringArray; var hasDevice = resultLines?.Length >= 2 && resultLines[1] != null; Debug.Assert(resultLines != null); var device = hasDevice ? resultLines[1].SubstringBefore("device").Trim() : null; return(device); }
public static void Setup() { if (!HasDevice) { throw new CliException("No device"); } // // adb push busybox /data/local/tmp/busybox // var pushCmd = CliCommand.Create(CliScope.Adb, "push {0} {1}", BUSYBOX_EXE, REMOTE_BUSYBOX_EXE); var pushResult = CliResult.Run(pushCmd, CliDataType.StringArray); bool pushOk = pushResult.SuccessfulIfLineContains("busybox: 1 file pushed"); if (!pushOk) { throw new CliException("Could not push busybox to device"); } // // chmod +x /data/local/tmp/busybox // var chmodCmd = CliCommand.Create(CliScope.AdbShell, "chmod +x {0}", REMOTE_BUSYBOX_EXE); var chmodResult = CliResult.Run(chmodCmd, CliDataType.StringArray); if (!HasBusybox) { throw new CliException("Busybox failure to device"); } }