Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 /// <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);
 }
Exemplo n.º 3
0
 /// <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);
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
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());
        }