Exemplo n.º 1
0
        /// <summary>
        /// Install apk to default Android device.
        /// Installation is performed in the background thread.
        /// ProgressBar is displayed while the installation is in progress.
        /// </summary>
        /// <param name="path">Path to apk</param>
        /// <param name="deviceId">Id of device on which will be installed.
        ///  To get ids of all devices use <see cref="GetDevices"/></param>
        /// <param name="OnDone">Callback thats invoked after request is done.
        /// Bool argument means success or not.</param>
        /// <seealso cref="InstallToDevice(string,System.Action{bool})"/>
        public static void InstallToDevice(string path, string deviceId, Action <bool> OnDone)
        {
            var request = CreateRequestAdb(string.Format("{0} install -r \"{1}\"", ForDevicePart(deviceId), path));

            request.ExecuteAsync(
                OnExited: success => {
                ProcessingWindow.Close();
                if (OnDone != null)
                {
                    OnDone(success);
                }
            },
                OnOutput: status => {
                if (IsWasError(status))
                {
                    request.Abort();
                    ProcessingWindow.Close();
                }
                else
                {
                    ProcessingWindow.Update(status, _INSTALLING_PROGRESS_MATCH);
                }
            },
                OnError: error => !error.StartsWith("success", true, CultureInfo.InvariantCulture));
            ProcessingWindow.Show(_TITLE_INSTALLING, request.Abort);
        }
Exemplo n.º 2
0
        public static void ClearCache(string packageName, string deviceId, Action <bool> OnDone)
        {
            var request = CreateRequestAdb(string.Format("{0} shell pm clear {1}", ForDevicePart(deviceId), packageName));

            request.ExecuteAsync(
                OnExited: success => {
                ProcessingWindow.Close();
                if (OnDone != null)
                {
                    OnDone(success);
                }
            },
                OnOutput: status => {
                if (IsWasError(status))
                {
                    request.Abort();
                    ProcessingWindow.Close();
                }
                else
                {
                    ProcessingWindow.Update(status, _INSTALLING_PROGRESS_MATCH);
                }
            },
                OnError: error => !error.StartsWith("success", true, CultureInfo.InvariantCulture));
            ProcessingWindow.Show("App clear cache", request.Abort);
        }