Beispiel #1
0
        protected override int VisualMain()
        {
            WriteInitInfo();
            IDevice device         = DeviceSelectedOnCreating;
            Version androidVersion = new DeviceBuildPropGetter(device).GetAndroidVersion();

            CommandExecutor.Result result;
            using (var executor = new CommandExecutor())
            {
                executor.To(OutputPrinter);
                WriteLine("Accessibility service run-on-demand || Aggressive Doze on Android 7.0+ (non-root)");
                result = executor.AdbShell(device, GRANT_PRE, WRITE_SECURE_SETTINGS);
                Count(result);

                WriteLine("Doze on the Go || Aggressive Doze");
                result = executor.AdbShell(device, GRANT_PRE, DUMP);
                Count(result);

                WriteLine("Wake-up Tracker");
                result = executor.AdbShell(device, GRANT_PRE, READ_LOGS);
                Count(result);

                WriteLine("Background-free enforcement on Android 8+ (non-root)");
                if (androidVersion != null && androidVersion >= new Version("8.0"))
                {
                    result = executor.AdbShell(device, GRANT_PRE, GET_APP_OPS_STATS);
                    Count(result);
                }
                result = executor.AdbShell(device, "am force-stop", PKG_NAME);
                Count(result);
                WriteLine($"successed: {successed} failed:{error}");
                return(OK);
            }
        }
        public void EntryPoint(IDevice device, ILeafUI ui, TextAttrManager text, IEmbeddedFileManager emb, ITemporaryFloder tmp)
        {
            using (ui)
            {
                ui.Title = this.GetName();
                ui.Icon  = this.GetIconBytes();
                ui.Show();

                ui.Tip = text[EXTRACTING];
                tmp.Create();
                var filePath = Path.Combine(tmp.DirInfo.ToString(), "daemon");
                var tgtFile  = new FileInfo(filePath);
                var file     = emb.Get("daemon");

                ui.Tip = text[PUSHING];
                file.ExtractTo(tgtFile);

                ui.Tip = text[PUSHING];
                ICommandResult result = null;
                using (var executor = new CommandExecutor())
                {
                    executor.To(e => ui.WriteOutput(e.Text));
                    executor.Adb(device, $"push {tgtFile.FullName} /data/local/tmp/daemon");
                    executor.AdbShell(device, "chmod 777 /data/local/tmp/daemon");
                    result = executor.AdbShell(device, "./data/local/tmp/daemon &");
                }
                ui.Finish(result.ExitCode);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 是否安装快否
        /// </summary>
        /// <param name="devices"></param>
        /// <returns></returns>
        public bool IsInstallKF(IDevice devices)
        {
            var KFPath = _executer.AdbShell(devices, "pm path com.af.benchaf").Output;

            if (string.IsNullOrWhiteSpace(KFPath))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #4
0
 public void VisualMain(ILeafUI ui, IDevice device)
 {
     using (ui)
     {
         ui.Title = this.GetName();
         ui.Icon  = this.GetIconBytes();
         ui.Show();
         ui.EAgree("本模块将玉石俱焚,并且效果不一定完美,你真的需要这么做吗?如果你只是想要移除某个冻结软件,请前往该软件设置进行卸载");
         CommandExecutor executor = new CommandExecutor();
         executor.OutputReceived += (s, e) => ui.WriteLine(e.Text);
         executor.AdbShell(device, "su -c rm - rf / data / system / device_policies.xml");
         executor.AdbShell(device, "su -c rm -rf /data/system/device_owner_2.xml");
         device.Reboot2System();
         ui.Finish();
     }
 }
Beispiel #5
0
 public void EntryPoint(IDevice device, ILeafUI ui)
 {
     using (ui)
     {
         ui.Title = this.GetName();
         ui.Icon  = this.GetIconBytes();
         ui.Show();
         var executor = new CommandExecutor();
         executor.OutputReceived += (s, e) => ui.WriteOutput(e.Text);
         var tmpPath   = GenerateTmpPath();
         var capResult = executor.AdbShell(device, $"screencap -p {tmpPath}");
         if (capResult.ExitCode == 0)
         {
             executor.Adb(device, $"pull {tmpPath} \"{GetSaveTarget(ui)}\"");
             executor.AdbShell(device, $"rm -f {tmpPath}");
         }
         ui.Finish(capResult.ExitCode);
     }
 }
Beispiel #6
0
 public void EntryPoint(ILeafUI ui, IDevice device, IClassTextManager text)
 {
     using (ui)
     {
         ui.Title = this.GetName();
         ui.Icon  = this.GetIconBytes();
         ui.Show();
         ui.AppPropertyCheck(device, "me.piebridge.brevent");
         CommandExecutor executor = new CommandExecutor();
         executor.OutputReceived += (s, e) => ui.WriteLine(e.Text);
         if (executor.AdbShell(device, $"cat {SH_PATH}").ExitCode != 0)
         {
             ui.ShowMessage(text["firstMsg"]);
             Thread.Sleep(2000);
         }
         var result = executor.AdbShell(device, $"sh {SH_PATH}");
         ui.Finish(result.ExitCode);
     }
 }
 public void EntryPoint(ILeafUI ui, IDevice device, IClassTextManager text)
 {
     using (ui)
     {
         ui.Title = this.GetName();
         ui.Icon  = this.GetIconBytes();
         ui.Show();
         ui.AppPropertyCheck(device, PKG_NAME);
         ui.ShowMessage(text["launchFirst"]);
         CommandExecutor executor = new CommandExecutor();
         var             result   = executor.AdbShell(device, $"sh {SH_PATH}");
         ui.Finish(result.ExitCode);
     }
 }
Beispiel #8
0
        public void EntryPoint(IDevice device, ILeafUI ui, TextAttrManager texts)
        {
            using (ui)
            {
                ui.Title = this.GetName();
                ui.Icon  = this.GetIconBytes();
                ui.Show();
                if (!ui.DoYN(texts[ISINSTALL]))
                {
                    ui.EShutdown();
                }

                using (var executor = new CommandExecutor())
                {
                    executor.To(e => ui.WriteOutput(e.Text));
                    ui.WriteLine("启动AppOpsX主界面");
                    executor.AdbShell(device, "am start -n com.zzzmode.appopsx/com.zzzmode.appopsx.ui.main.MainActivity");
                    Thread.Sleep(1500);
                    var result = executor.AdbShell(device, "sh /sdcard/Android/data/com.zzzmode.appopsx/opsx.sh ");
                    ui.Finish(result.ExitCode);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// 用所有可能的方法设置设备管理员,并返回结果
        /// </summary>
        /// <param name="device"></param>
        /// <param name="executor"></param>
        /// <param name="dpmpro"></param>
        /// <returns></returns>
        private ICommandResult SetDeviceOwner(CommandExecutor executor, DpmPro dpmpro)
        {
            ICommandResult result = null;

            //先用自带dpm进行设置
            result = executor.AdbShell(Device, "dpm set-device-owner", ComponentName);
            //如果返回值为127,也就是说这设备连dpm都阉割了,就询问用户是否用dpmpro来设置设备管理员
            if (result.ExitCode == 127 && UI.DoYN(TextManager["UseDpmPro"]))
            {
                //用dpmpro设置设备管理员,并记录结果(覆盖普通dpm设置器的记录)
                result = dpmpro.SetDeviceOwner(ComponentName);
            }
            return(result);
        }
Beispiel #10
0
        public void EntryPoint(ILeafUI ui, IDevice device, IClassTextDictionary text)
        {
            using (ui)
            {
                ui.Title = this.GetName();
                ui.Icon  = this.GetIconBytes();
                ui.Show();
                ui.EAgree(text["notice"]);
                using (var executor = new CommandExecutor())
                {
                    Version androidVersion = new DeviceBuildPropGetter(device).GetAndroidVersion();
                    executor.OutputReceived += (s, e) => ui.WriteOutput(e.Text);
                    ui.WriteLine("Accessibility service run-on-demand || Aggressive Doze on Android 7.0+ (non-root)");
                    var result = executor.AdbShell(device, GRANT_PRE, WRITE_SECURE_SETTINGS);
                    Count(result);

                    ui.WriteLine("Doze on the Go || Aggressive Doze");
                    result = executor.AdbShell(device, GRANT_PRE, DUMP);
                    Count(result);

                    ui.WriteLine("Wake-up Tracker");
                    result = executor.AdbShell(device, GRANT_PRE, READ_LOGS);
                    Count(result);

                    ui.WriteLine("Background-free enforcement on Android 8+ (non-root)");
                    if (androidVersion != null && androidVersion >= new Version("8.0"))
                    {
                        result = executor.AdbShell(device, GRANT_PRE, GET_APP_OPS_STATS);
                        Count(result);
                    }
                    result = executor.AdbShell(device, "am force-stop", PKG_NAME);
                    Count(result);
                    ui.WriteLine($"successed: {successed} failed:{error}");
                    ui.Finish(text["tip"]);
                }
            }
        }
Beispiel #11
0
        public void EntryPoint()
        {
            using (UI)
            {
                UI.Show();  //显示ui
                InitUI();   //初始化ui


                ////执行前的一些检查与提示
                //SetProgress("Checking", 10);
                //if (!DoAppCheck()) return;//进行APP安装检查
                //if (!DoWarn()) return;//进行一系列提示与警告

                //做出一系列警告与提示,只要一个不被同意,立刻再见
                if (!(DoAppCheck() && DoWarn()))
                {
                    UI.Shutdown(); //直接关闭UI
                    return;        //退出函数
                }

                /* 正式开始流程 */

                //构造一个命令执行器
                using (CommandExecutor executor = new CommandExecutor())
                {
                    //创建一个OutputBuilder
                    OutputBuilder outputBuilder = new OutputBuilder();

                    //接收并记录所有executor的输出
                    outputBuilder.Register(executor);

                    //将命令执行器输出定向到界面
                    executor.To(e => UI.WriteOutput(e.Text));

                    //构造一个dpmpro的控制器
                    var dpmpro = new DpmPro(executor, CoreLib.Current, Device);

                    //将dpmpro提取到临时目录
                    SetProgress("Extract", 0);
                    dpmpro.Extract();

                    //推送dpmpro到设备
                    SetProgress("Push", 20);
                    dpmpro.PushToDevice();

                    //移除账户
                    SetProgress("RMAcc", 40);
                    dpmpro.RemoveAccounts();

                    //移除用户
                    SetProgress("RMUser", 60);
                    dpmpro.RemoveUsers();

                    //使用可能的方式设置管理员,并记录结果
                    SetProgress("SettingDpm", 80);
                    var codeOfSetDeviceOwner = SetDeviceOwner(executor, dpmpro).ExitCode;

                    if (codeOfSetDeviceOwner == 0 &&      //如果设置成功并且
                        (PackageName == "com.catchingnow.icebox" || //目标包名是冰箱
                         PackageName == "web1n.stopapp")) //小黑屋
                    {
                        //给予APPOPS权限
                        executor.AdbShell(Device, $"pm grant {PackageName} android.permission.GET_APP_OPS_STATS");
                    }

                    //使用输出解析器,对记录的输出进行解析
                    DpmFailedMessageParser.Parse(codeOfSetDeviceOwner, outputBuilder.ToString(), out string tip, out string message);



                    //在输出框写下简要信息与建议
                    UI.WriteLine(message);
                    UI.ShowMessage(message);

                    //去除输出信息事件注册
                    outputBuilder.Unregister(executor);

                    //ui流程结束
                    UI.Finish(tip);
                }
            }
        }
Beispiel #12
0
        public int RemoveUsers()
        {
            string command = string.Format(CMD_FORMAT, CMD_REMOVE_USER);

            return(executor.AdbShell(device, command).ExitCode);
        }
        private string Com1(IDevice deviceInfo)
        {
            _executer.AdbShell(deviceInfo,
                               $"settings put global captive_portal_server {_url}");
            var output1 = _executer.AdbShell(deviceInfo, @"settings get global captive_portal_server").Output;

            return("当前设置检测服务器为:" + output1);
        }