コード例 #1
0
ファイル: BuildProp.cs プロジェクト: peter-way/XiaomiLib
        /// <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);
        }
コード例 #2
0
 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"));
 }
コード例 #3
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;
        }
コード例 #4
0
 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));
     }
 }
コード例 #5
0
ファイル: FileSystem.cs プロジェクト: peter-way/XiaomiLib
        //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);
        }
コード例 #6
0
 private void SwipeThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, false, "input", "swipe", swipecommand));
 }
コード例 #7
0
 private void TapThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, false, "input", "tap", tapcommand));
 }
コード例 #8
0
 private void InputTextThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, false, "input", "text", inputcommand));
 }
コード例 #9
0
 private void DataDisableThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "svc", "data disable"));
 }
コード例 #10
0
 private void PowerOffThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "su", "- c poweroff"));
 }
コード例 #11
0
 /// <summary>
 /// disable diagnostic mode
 /// </summary>
 public void DisableDiagMode()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, true, "setprop sys.usb.config adb,mtp"));
 }
コード例 #12
0
 private void RebootBootloaderThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "bootloader"));
 }
コード例 #13
0
 private void RebootRecoveryThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "recovery"));
 }
コード例 #14
0
 private void RebootSideloadThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "sideload"));
 }
コード例 #15
0
 private void AdbRebootEdlThread()
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbShellCommand(this, "reboot", "edl"));
 }
コード例 #16
0
ファイル: Monkey.cs プロジェクト: peter-way/XiaomiLib
 private void executeCommand(List <uint[]> cmds)
 {
     AdbCmd.ExecuteAdbCommandNoReturn(AdbCmd.FormAdbCommand(getCommand(cmds)));
     //AdbClient.Instance.ExecuteRemoteCommand(getCommand(cmds), device, receiver);
 }