Example #1
0
        public override TaskResult Run(Managed.Adb.Device adbDevice)
        {
            TaskResult result = new TaskResult();

            //un install
            var apkInfo = APKInfo.ParseAPK(mPackgeLocation);

            try {
                if (adbDevice.PackageManager.Exists(apkInfo.PackgeName))
                {
                    adbDevice.UninstallPackage(apkInfo.PackgeName);
                }
            } catch {
            }

            LogWrapper.LogInfo("CanuSU:" + adbDevice.SerialNumber + ":" + adbDevice.CanSU());
            string          remoteFilePath = adbDevice.SyncPackageToDevice(mPackgeLocation);
            InstallReceiver receiver       = new InstallReceiver();
            String          cmd            = String.Format("pm install {1}{0}", remoteFilePath, true ? "-r " : String.Empty);

            if (adbDevice.CanSU())
            {
                adbDevice.ExecuteRootShellCommand(cmd, receiver);
            }
            else
            {
                adbDevice.ExecuteShellCommand(cmd, receiver);
            }

            if (!String.IsNullOrEmpty(receiver.ErrorMessage))
            {
                result.ok  = false;
                result.Msg = receiver.ErrorMessage;
            }
            return(result);
        }