コード例 #1
0
ファイル: AAPT.cs プロジェクト: ylyking/WinDroid_Toolkit
        /// <summary>
        /// Initializes a new instance of the <c>AAPT</c> class
        /// </summary>
        public AAPT()
        {
            ResourceFolderManager.Register("AAPT");
            this.resDir = ResourceFolderManager.GetRegisteredFolderPath("AAPT");

            ExtractResources(this.resDir);
        }
コード例 #2
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;
        }
コード例 #3
0
 /// <summary>
 /// Creates the resource directories.
 /// </summary>
 private void CreateResourceDirectories()
 {
     try {
         if (!Adb.ExecuteAdbCommand(new AdbCommand("version")).Contains(Adb.ADB_VERSION))
         {
             Adb.KillServer();
             Thread.Sleep(1000);
             ResourceFolderManager.Unregister(ANDROID_CONTROLLER_TMP_FOLDER);
             Extract_Resources = true;
         }
     } catch (Exception) {
         Extract_Resources = true;
     }
     ResourceFolderManager.Register(ANDROID_CONTROLLER_TMP_FOLDER);
 }
コード例 #4
0
 private void CreateResourceDirectories()
 {
     try
     {
         if (!Adb.ExecuteAdbCommand(new AdbCommand("version")).Contains(Adb.AdbVersion))
         {
             Adb.KillServer();
             Thread.Sleep(1000);
             ResourceFolderManager.Unregister(AndroidControllerTmpFolder);
             _extractResources = true;
         }
     }
     catch (Exception)
     {
         _extractResources = true;
     }
     ResourceFolderManager.Register(AndroidControllerTmpFolder);
 }
コード例 #5
0
ファイル: Signer.cs プロジェクト: zarocks/AndroidLib
        /// <summary>
        /// Signs an Update.zip with test keys to flash on an Android device
        /// </summary>
        /// <param name="unsigned">Full path to unsigned update.zip</param>
        /// <returns>True if successful, false if file <paramref name="unsigned"/> does not exist or if file <paramref name="unsigned"/> is not a zip</returns>
        /// <remarks><para>Outputs signed zip in same directory as unsigned zip</para></remarks>
        public static bool SignUpdateZip(string unsigned)
        {
            if (!File.Exists(unsigned) || Path.GetExtension(unsigned).ToLower() != ".zip")
            {
                return(false);
            }

            bool   result;
            string resDir;

            ResourceFolderManager.Register("Signer");

            resDir = ResourceFolderManager.GetRegisteredFolderPath("Signer");

            ExtractResources(resDir);

            result = Java.RunJar(resDir + "signapk.jar", "\"" + resDir + "testkey.x509.pem\"", "\"" + resDir + "testkey.pk8\"", "\"" + unsigned + "\"", "\"" + unsigned.Replace(".zip", "_signed.zip\""));

            ResourceFolderManager.Unregister("Signer");

            return(result);
        }
コード例 #6
0
 private AndroidController()
 {
     this.connectedDevices = new List <string>();
     ResourceFolderManager.Register(ANDROID_CONTROLLER_FOLDER);
     this.resourceDirectory = ResourceFolderManager.GetRegisteredFolderPath(ANDROID_CONTROLLER_FOLDER);
 }
コード例 #7
0
ファイル: AAPT.cs プロジェクト: ylyking/WinDroid_Toolkit
 /// <summary>
 /// Call to free up resources after use of <c>AAPT</c>
 /// </summary>
 public void Dispose()
 {
     ResourceFolderManager.Unregister("AAPT");
 }
コード例 #8
0
        /// <summary>
        /// Prevents a default instance of the <see cref="AndroidController"/> class from being created.
        /// </summary>
        private AndroidController()
        {
            this.connectedDevices = new List <string>();
            ResourceFolderManager.Register(ANDROID_CONTROLLER_TMP_FOLDER);
            this.resourceDirectory = ResourceFolderManager.GetRegisteredFolderPath(ANDROID_CONTROLLER_TMP_FOLDER);
            //CreateResourceDirectories();
            //ExtractResources();
            this.m_eventWatcher = new ManagementEventWatcher(
                new WqlEventQuery("SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 2")
                );
            this.m_eventWatcher.EventArrived += (s, evt) => {
                var m_oldConnectedDevices = connectedDevices;
                var m_newConnectedDevices = ConnectedDevices;

                if (m_oldConnectedDevices.Count != m_newConnectedDevices.Count)
                {
                    // List sizes do not match.
                    // Depending on whether the new list is longer or short, fire the corresponding event.
                    if (m_newConnectedDevices.Count > m_oldConnectedDevices.Count)
                    {
                        // A new device was added.
                        // Find out which device it was.
                        foreach (string m_device in m_newConnectedDevices)
                        {
                            if (!m_oldConnectedDevices.Contains(m_device))
                            {
                                // We've found the device that was added.
                                // We know this because the old list doesn't contain this device's serial.
                                // Now fire OnDeviceAdded event(s).
                                foreach (DeviceAddedEventHandler m_handler in OnDeviceAdded.GetInvocationList())
                                {
                                    m_handler(
                                        this,
                                        new OnDeviceAddedEventArgs(
                                            "A new device was added to the local machine.",
                                            GetConnectedDevice(m_device)
                                            )
                                        );
                                }
                            }
                        }
                    }
                    else
                    {
                        // A device was removed.
                        // Find out which one it was.
                        foreach (string m_device in m_oldConnectedDevices)
                        {
                            if (!m_newConnectedDevices.Contains(m_device))
                            {
                                // We've found the device that was removed.
                                // We know this because the new list doesn't contain the device's serial.
                                // Now fire OnDeviceRemoved event(s).
                                foreach (DeviceRemovedEventHandler m_handler in OnDeviceRemoved.GetInvocationList())
                                {
                                    m_handler(
                                        this,
                                        new OnDeviceRemovedEventArgs(
                                            "A device was removed from the local machine.",
                                            m_device
                                            )
                                        );
                                }
                            }
                        }
                    }
                }
                else
                {
                    return;    // Nothing to do here, so don't bother.
                }
            };
            if (m_monitorUSB)
            {
                m_eventWatcher.Start();
            }
        }
コード例 #9
0
 private AndroidController()
 {
     this._connectedDevices = new List <string>();
     ResourceFolderManager.Register(AndroidControllerTmpFolder);
     this._resourceDirectory = ResourceFolderManager.GetRegisteredFolderPath(AndroidControllerTmpFolder);
 }
コード例 #10
0
 private XiaomiController()
 {
     connectedDevices = new List <string>();
     ResourceFolderManager.Register(ANDROID_CONTROLLER_TMP_FOLDER);
     resourceDirectory = ResourceFolderManager.GetRegisteredFolderPath(ANDROID_CONTROLLER_TMP_FOLDER);
 }