protected override int VisualMain() { IProcessBasedCommandResult step1Result = null, step2Result = null; step1Result = CmdStation.GetSuCommand(TargetDevice, "rm -rf /data/system/device_policies.xml") .To(OutputPrinter) .Execute(); WriteExitCode(step1Result.ExitCode); step2Result = CmdStation.GetSuCommand(TargetDevice, "rm -rf /data/system/device_owner_2.xml") .To(OutputPrinter) .Execute(); WriteExitCode(step2Result.ExitCode); if (step1Result.ExitCode == 0 && step2Result.ExitCode == 0) { bool rebootToSystem = Ux.DoYN(Res("EDeviceOwnerRemoverYNReboot")); if (rebootToSystem) { TargetDevice.Reboot2System(); } return(0); } else { return(1); } }
/// <summary> /// 放返回码不为0时抛出异常 /// </summary> /// <param name="result"></param> public static IProcessBasedCommandResult ThrowIfExitCodeNotEqualsZero(this IProcessBasedCommandResult result) { if (result.ExitCode != 0) { throw new AdbCommandFailedException(result.Output, result.ExitCode); } return(result); }
/// <summary> /// 放返回码不为0时抛出异常 /// </summary> /// <param name="result"></param> public static IProcessBasedCommandResult ThrowIfShellExitCodeNotEqualsZero(this IProcessBasedCommandResult result) { if (result.ExitCode != 0) { throw new AdbShellCommandFailedException(result.ExitCode, result.Output.ToString()); } return(result); }
protected override int VisualMain() { WriteInitInfo(); Version androidVersion = new DeviceBuildPropGetter(TargetDevice).GetAndroidVersion(); IProcessBasedCommandResult result = null; result = CmdStation.GetShellCommand(TargetDevice, $"pm grant {PKG_NAME} android.permission.WRITE_SECURE_SETTINGS") .To(OutputPrinter) .Execute(); WriteExitCode(result.ExitCode); ThrowIfCanceled(); result = CmdStation.GetShellCommand(TargetDevice, $"pm grant {PKG_NAME} android.permission.DUMP") .To(OutputPrinter) .Execute(); WriteExitCode(result.ExitCode); ThrowIfCanceled(); result = CmdStation.GetShellCommand(TargetDevice, $"pm grant {PKG_NAME} android.permission.READ_LOGS") .To(OutputPrinter) .Execute(); WriteExitCode(result.ExitCode); ThrowIfCanceled(); if (androidVersion.Major >= 8) { result = CmdStation.GetShellCommand(TargetDevice, $"pm grant {PKG_NAME} android.permission.READ_APP_OPS_STATS") .To(OutputPrinter) .Execute(); WriteExitCode(result.ExitCode); ThrowIfCanceled(); } result = CmdStation.GetShellCommand(TargetDevice, $"am force-stop " + PKG_NAME) .To(OutputPrinter) .Execute(); WriteExitCode(result.ExitCode); ThrowIfCanceled(); return(0); }
protected sealed override int VisualMain() { WriteWaitingForUser(); if (!OnWarnUser()) { return(ERR_CANCELED_BY_USER); } ProcessBasedCommand command = null; IProcessBasedCommandResult result = null; WriteInitInfo(); GodPower = new GodPower(this, TargetDevice); WriteLineAndSetTip(Res("EGodPowerExtractingApk")); GodPower.Extract(); ThrowIfCanceled(); WriteLineAndSetTip(Res("EGodPowerPushingApk")); command = GodPower.GetPushCommand(); CmdStation.Register(command); result = command .To(OutputPrinter) .Execute(); WriteLineAndSetTip(Res("EGodPowerRmUser")); command = GodPower.GetRemoveUserCommand(); CmdStation.Register(command); result = command .To(OutputPrinter) .Execute(); ThrowIfCanceled(); WriteLineAndSetTip(Res("EGodPowerRmAcc")); command = GodPower.GetRemoveAccountCommnad(); CmdStation.Register(command); result = command .To(OutputPrinter) .Execute(); ThrowIfCanceled(); return(SetReciverAsDpm()); }