/// <summary> /// Sets a build property value /// </summary> /// <remarks>If <paramref name="key"/> does not exist or device does not have root, returns false, and does not set any values</remarks> /// <param name="key">Build property key to set</param> /// <param name="newValue">Value you wish to set <paramref name="key"/> to</param> /// <returns>True if new value set, false if not</returns> public bool SetProp(string key, string newValue) { string before; if (!prop.TryGetValue(key, out before)) { return(false); } if (!device.HasRoot) { return(false); } AdbCommand adbCmd = AdbCmd.FormAdbShellCommand(device, true, "setprop", key, newValue); AdbCmd.ExecuteAdbCommandNoReturn(adbCmd); Update(); string after; if (!prop.TryGetValue(key, out after)) { return(false); } return(newValue == after); }
private void StartMinicapServerThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbCommand("forward--remove -all")); AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbCommand("forward --no-rebind tcp:1313 localabstract:minicap")); AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbCommand("shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1080x1920@1080x1920/0")); //AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1080x1920@1080x1920/0")); }
/// <summary> /// Releases all resources used by <see cref="XiaomiController"/> /// </summary> /// <remarks>Needs to be called when application has finished using <see cref="XiaomiController"/></remarks> public void Dispose() { if (AdbCmd.ServerRunning) { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbCommand("forward--remove - all")); AdbCmd.KillServer(); Thread.Sleep(1000); } AdbCmd.KillServer(); ResourceFolderManager.Unregister(ANDROID_CONTROLLER_TMP_FOLDER); instance = null; }
private void RemoveScreenLockThread() { if (state == DeviceState.ONLINE) { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "su", "- c rm / data / system/*.key")); AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "su", "- c rm /data/system/*.db")); AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "su", "- c rm /data/system/*.db-shm")); AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "su", "- c rm /data/system/*.db-wal")); } else if (state == DeviceState.SIDELOAD) { var unlock = "adb sideload " + XiaomiController.Instance.ResourceDirectory + "Key.zip"; AdbCmd.ExecuteAdbCommand(AdbCmd.FormAdbCommand(unlock)); } }
//void PushFile(); //void PullFile(); /// <summary> /// Mounts connected Android device's file system as specified /// </summary> /// <param name="type">The desired <see cref="MountType"/> (RW or RO)</param> /// <returns>True if remount is successful, False if remount is unsuccessful</returns> /// <example>The following example shows how you can mount the file system as Read-Writable or Read-Only /// <code> /// // This example demonstrates mounting the Android device's file system as Read-Writable /// using System; /// using Mrivai.Pelitabangsa; /// /// class Program /// { /// static void Main(string[] args) /// { /// AndroidController android = AndroidController.Instance; /// Device device; /// /// Console.WriteLine("Waiting For Device..."); /// android.WaitForDevice(); //This will wait until a device is connected to the computer /// device = android.ConnectedDevices[0]; //Sets device to the first Device in the collection /// /// Console.WriteLine("Connected Device - {0}", device.SerialNumber); /// /// Console.WriteLine("Mounting System as RW..."); /// Console.WriteLine("Mount success? - {0}", device.RemountSystem(MountType.RW)); /// } /// } /// /// // The example displays the following output (if mounting is successful): /// // Waiting For Device... /// // Connected Device - {serial # here} /// // Mounting System as RW... /// // Mount success? - true /// </code> /// </example> public bool RemountSystem(MountType type) { if (!device.HasRoot) { return(false); } AdbCommand adbCmd = AdbCmd.FormAdbShellCommand(device, true, "mount", string.Format("-o remount,{0} -t yaffs2 {1} /system", type.ToString().ToLower(), systemMount.Block)); AdbCmd.ExecuteAdbCommandNoReturn(adbCmd); UpdateMountPoints(); if (systemMount.MountType == type) { return(true); } return(false); }
private void SwipeThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, false, "input", "swipe", swipecommand)); }
private void TapThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, false, "input", "tap", tapcommand)); }
private void InputTextThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, false, "input", "text", inputcommand)); }
private void DataDisableThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "svc", "data disable")); }
private void PowerOffThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "su", "- c poweroff")); }
/// <summary> /// disable diagnostic mode /// </summary> public void DisableDiagMode() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, true, "setprop sys.usb.config adb,mtp")); }
private void RebootBootloaderThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "bootloader")); }
private void RebootRecoveryThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "recovery")); }
private void RebootSideloadThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "sideload")); }
private void AdbRebootEdlThread() { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "edl")); }
private void executeCommand(List <uint[]> cmds) { AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbCommand(getCommand(cmds))); //AdbClient.Instance.ExecuteRemoteCommand(getCommand(cmds), device, receiver); }