示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public String uninstallPackage(String packageName) throws InstallException
        public string uninstallPackage(string packageName)
        {
            try
            {
                InstallReceiver receiver = new InstallReceiver();
                executeShellCommand("pm uninstall " + packageName, receiver, INSTALL_TIMEOUT);
                return(receiver.errorMessage);
            }
            catch (TimeoutException e)
            {
                throw new InstallException(e);
            }
            catch (AdbCommandRejectedException e)
            {
                throw new InstallException(e);
            }
            catch (ShellCommandUnresponsiveException e)
            {
                throw new InstallException(e);
            }
            catch (IOException e)
            {
                throw new InstallException(e);
            }
        }
示例#2
0
        public void ProcessSuccessTest()
        {
            InstallReceiver receiver = new InstallReceiver();

            receiver.AddOutput("Success");
            receiver.Flush();

            Assert.True(receiver.Success);
        }
示例#3
0
        public void ProcessFailureNoMessageTest()
        {
            InstallReceiver receiver = new InstallReceiver();

            receiver.AddOutput("Failure");
            receiver.Flush();

            Assert.False(receiver.Success);
            Assert.Equal(InstallReceiver.UnknownError, receiver.ErrorMessage);
        }
示例#4
0
        public void ProcessFailureTest()
        {
            InstallReceiver receiver = new InstallReceiver();

            receiver.AddOutput("Failure [message]");
            receiver.Flush();

            Assert.False(receiver.Success);
            Assert.Equal("message", receiver.ErrorMessage);
        }
示例#5
0
    public void InstallPackge(string apkLocation, bool forceInstall)
    {
        WriteLog("sync packge to device '" + apkLocation + "'");
        string remoteFilePath = ADBDevice.SyncPackageToDevice(apkLocation);

        WriteLog("install packge " + remoteFilePath);
        InstallReceiver receiver = new InstallReceiver();
        String          cmd      = String.Format("pm install {1}{0}", remoteFilePath, forceInstall ? "-r " : String.Empty);

        ADBDevice.ExecuteShellCommand(cmd, receiver);
        if (!String.IsNullOrEmpty(receiver.ErrorMessage))
        {
            WriteLog("install packge failed " + remoteFilePath + ",ErrorMessage:" + receiver.ErrorMessage);
            throw new PackageInstallationException(receiver.ErrorMessage);
        }
        else
        {
            WriteLog("install packge successed " + remoteFilePath);
        }
    }
示例#6
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);
        }
示例#7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public String installRemotePackage(String remoteFilePath, boolean reinstall, String... extraArgs) throws InstallException
        public string installRemotePackage(string remoteFilePath, bool reinstall, params string[] extraArgs)
        {
            try
            {
                InstallReceiver receiver     = new InstallReceiver();
                StringBuilder   optionString = new StringBuilder();
                if (reinstall)
                {
                    optionString.Append("-r ");
                }
                foreach (string arg in extraArgs)
                {
                    optionString.Append(arg);
                    optionString.Append(' ');
                }
                string cmd = string.Format("pm install {0} \"{1}\"", optionString.ToString(), remoteFilePath);
                executeShellCommand(cmd, receiver, INSTALL_TIMEOUT);
                return(receiver.errorMessage);
            }
            catch (TimeoutException e)
            {
                throw new InstallException(e);
            }
            catch (AdbCommandRejectedException e)
            {
                throw new InstallException(e);
            }
            catch (ShellCommandUnresponsiveException e)
            {
                throw new InstallException(e);
            }
            catch (IOException e)
            {
                throw new InstallException(e);
            }
        }
示例#8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public String uninstallPackage(String packageName) throws InstallException
		public string uninstallPackage(string packageName)
		{
			try
			{
				InstallReceiver receiver = new InstallReceiver();
				executeShellCommand("pm uninstall " + packageName, receiver, INSTALL_TIMEOUT);
				return receiver.errorMessage;
			}
			catch (TimeoutException e)
			{
				throw new InstallException(e);
			}
			catch (AdbCommandRejectedException e)
			{
				throw new InstallException(e);
			}
			catch (ShellCommandUnresponsiveException e)
			{
				throw new InstallException(e);
			}
			catch (IOException e)
			{
				throw new InstallException(e);
			}
		}
示例#9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public String installRemotePackage(String remoteFilePath, boolean reinstall, String... extraArgs) throws InstallException
		public string installRemotePackage(string remoteFilePath, bool reinstall, params string[] extraArgs)
		{
			try
			{
				InstallReceiver receiver = new InstallReceiver();
				StringBuilder optionString = new StringBuilder();
				if (reinstall)
				{
					optionString.Append("-r ");
				}
				foreach (string arg in extraArgs)
				{
					optionString.Append(arg);
					optionString.Append(' ');
				}
				string cmd = string.Format("pm install {0} \"{1}\"", optionString.ToString(), remoteFilePath);
				executeShellCommand(cmd, receiver, INSTALL_TIMEOUT);
				return receiver.errorMessage;
			}
			catch (TimeoutException e)
			{
				throw new InstallException(e);
			}
			catch (AdbCommandRejectedException e)
			{
				throw new InstallException(e);
			}
			catch (ShellCommandUnresponsiveException e)
			{
				throw new InstallException(e);
			}
			catch (IOException e)
			{
				throw new InstallException(e);
			}
		}