Example #1
0
        public void EntryPoint(ILeafUI _ui, IDevice device, ICommandExecutor _executor)
        {
            using var ui       = _ui;
            using var executor = _executor;
            var text = ClassTextReaderCache.Acquire(this.GetType());

            ui.Show();
            ui.EAgree(text["notice"]);
            Version androidVersion = new DeviceBuildPropGetter(device).GetAndroidVersion();

            executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
            ui.WriteLineToDetails("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.WriteLineToDetails("Doze on the Go || Aggressive Doze");
            result = executor.AdbShell(device, GRANT_PRE, DUMP);
            Count(result);

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

            ui.WriteLineToDetails("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.WriteLineToDetails($"successed: {successed} failed:{error}");
            ui.Finish(text["tip"]);
        }
Example #2
0
 public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
 {
     using (ui)
     {
         using (executor)
         {
             var text = ClassTextReaderCache.Acquire <EFlashRecovery>();
             ui.Show();
             OpenFileDialog fileDialog = new OpenFileDialog();
             fileDialog.Reset();
             fileDialog.Title       = text["Title"];
             fileDialog.Filter      = text["Filter"];
             fileDialog.Multiselect = false;
             if (fileDialog.ShowDialog() == true)
             {
                 executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
                 executor.Fastboot(device, $"flash recovery \"{fileDialog.FileName}\"");
                 var result = executor.Fastboot(device, $"boot \"{fileDialog.FileName}\"");
                 ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
             }
             else
             {
                 ui.Shutdown();
             }
         }
     }
 }
Example #3
0
 public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
 {
     using (ui)
     {
         using (executor)
         {
             executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
             var text = ClassTextReaderCache.Acquire <EGCM>();
             ui.Show();
             if (device is NetDevice)
             {
                 ui.ShowMessage(text["isNet"]);
                 ui.EFinish();
             }
             else if (device is UsbDevice usbDevice)
             {
                 var endPoint = usbDevice.OpenNetDebugging(5555);
                 if (endPoint != null)
                 {
                     executor.Adb($"connect {endPoint}");
                 }
                 ui.Finish();
             }
             else
             {
                 ui.Finish(text["notsupport"]);
             }
         }
     }
 }
Example #4
0
        public void EntryPoint(ILeafUI _ui, IDevice device, ICommandExecutor _executor, IStorage storage, IEmbeddedFileManager emb)
        {
            using var ui       = _ui;
            using var executor = _executor;
            var text = ClassTextReaderCache.Acquire <EClearAccounts>();

            ui.Show();
            ui.EAgree(text["warn"]);
            ui.EAgree(text["warn"]);
            ui.EAgree(text["warn"]);
            executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
            var dpm = new DpmPro(executor, emb, storage, device);

            ui.WriteLineToDetails(text["extracting"]);
            dpm.Extract();
            ui.WriteLineToDetails(text["pushing"]);
            dpm.PushToDevice();
            ui.WriteLineToDetails(text["removing"]);
            int exitCode = dpm.RemoveAccounts();

            if (exitCode == 0 && ui.DoYN(text["reboot"]))
            {
                device.Reboot2System();
            }
            ui.Finish(exitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
        }
        private SunsetLake GetSepLake(Dictionary <string, object> args)
        {
            SunsetLake s_lake = new SunsetLake();

            s_lake.RegisterSingleton <ILogger>(LoggerFactory.Auto(this.GetType().Name));
            s_lake.RegisterSingleton <ClassTextReader>(() =>
            {
                return(ClassTextReaderCache.Acquire(this.GetType()));
            });
            s_lake.RegisterSingleton <IExtensionInfo>(() =>
            {
                return(this.GetExtensionInfo());
            });
            s_lake.RegisterSingleton <ILeafUI>(() =>
            {
                ILeafUI leafUI     = this.lake !.Get <ILeafUI>();
                IExtensionInfo inf = this.GetExtensionInfo();
                leafUI.Title       = inf.Name();
                leafUI.Icon        = inf.Icon();
                return(leafUI);
            });
            s_lake.RegisterSingleton <Dictionary <string, object> >(() =>
            {
                return(args ?? new Dictionary <string, object>());
            });
            return(s_lake);
        }
Example #6
0
        public void EntryPoint(ILeafUI _ui, IDevice device, ICommandExecutor _executor)
        {
            using var ui       = _ui;
            using var executor = _executor;
            var text = ClassTextReaderCache.Acquire <EFilePusher>();

            ui.Show();
            bool?  dialogResult = null;
            string selectedFile = null;

            ui.RunOnUIThread(() =>
            {
                Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();
                fileDialog.Reset();
                fileDialog.Title       = text["title"];
                fileDialog.Filter      = text["filter"];
                fileDialog.Multiselect = false;
                dialogResult           = fileDialog.ShowDialog();
                selectedFile           = fileDialog.FileName;
            });

            if (dialogResult != true)
            {
                ui.EShutdown();
            }
            FileInfo fileInfo = new FileInfo(selectedFile);

            executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
            var result = executor.Adb(device, $"push \"{fileInfo.FullName}\" \"/sdcard/{fileInfo.Name}\"");

            ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
        }
Example #7
0
        public void StaticClassText()
        {
            var text = ClassTextReaderCache.Acquire(typeof(F));

            Assert.AreEqual("A", text.Get("error_title_fmt", "en-us"));
            Assert.AreEqual("A", text.Get("error_title_fmt", "zh-tw"));
            Assert.AreEqual("a", text.Get("error_title_fmt", "zh-cn"));
        }
Example #8
0
        public void DefaultTextTest()
        {
            var reader = ClassTextReaderCache.Acquire <ClassTextTest>();

            Assert.IsTrue(reader[TEST_1_KEY] == TEST_1_DFT_VALUE);
            Assert.IsTrue(reader[TEST_1_KEY, "zh-CN"] == "你好!我的梦!");

            Assert.IsTrue(reader.Get(TEST_1_KEY) == TEST_1_DFT_VALUE);
            Assert.IsTrue(reader.Get(TEST_1_KEY, "zh-CN") == "你好!我的梦!");

            Assert.IsTrue(reader.Get(TEST_1_KEY, "zh-cn") == "你好!我的梦!");
        }
Example #9
0
 public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
 {
     using (ui)
     {
         using (executor)
         {
             var text = ClassTextReaderCache.Acquire <EShizukuActivator>();
             ui.Show();
             ui.AppPropertyCheck(device, PKG_NAME);
             ui.ShowMessage(text["launchFirst"]);
             var result = executor.AdbShell(device, $"sh {SH_PATH}");
             ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
         }
     }
 }
Example #10
0
#pragma warning disable CA1822 // 将成员标记为 static
        public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
#pragma warning restore CA1822 // 将成员标记为 static
        {
            using (ui)
            {
                using (executor)
                {
                    executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
                    var text = ClassTextReaderCache.Acquire <EShizukuActivator>();
                    ui.Show();
                    ui.AppPropertyCheck(device, PKG_NAME);
                    ui.ShowMessage(text["launchFirst"]);

                    var result = executor.AdbShell(device, $"sh {SH_PATH}");
                    ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
                }
            }
        }
Example #11
0
 public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
 {
     using (ui)
     {
         using (executor)
         {
             var text = ClassTextReaderCache.Acquire <EUnlockSystemParation>();
             ui.Show();
             executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
             executor.Adb(device, "root");
             var result = executor.Adb(device, "disable-verity");
             if (result.ExitCode == 0 && ui.DoYN(text["reboot"]))
             {
                 device.Reboot2System();
             }
             ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
         }
     }
 }
Example #12
0
        public void Main(IDevice device, ILeafUI ui, ICommandExecutor executor)
        {
            using (ui)
            {
                using (executor)
                {
                    var text = ClassTextReaderCache.Acquire <EDpiModifier>();
                    ui.Show();
                    var choiceResult = ui.DoChoice(text["msg"], text["modify"], text["reset"]);
                    var wm           = new WindowManager(device, executor);
                    switch (choiceResult)
                    {
                    case null:
                        ui.EShutdown();
                        break;

                    case true:
                        if (int.TryParse(ui.InputString(text["hint"]), out int target))
                        {
                            wm.Density = target;
                            device.Reboot2System();
                            ui.EFinish();
                        }
                        else
                        {
                            ui.Finish(StatusMessages.CancelledByUser);
                        }

                        break;

                    case false:
                        wm.ResetDensity();
                        device.Reboot2System();
                        ui.EFinish();
                        break;
                    }
                }
            }
        }
Example #13
0
        internal static Task <object?> CreateTask(IExtensionInfo info,
                                                  Dictionary <string, object> args,
                                                  Action <Thread> threadReceiver,
                                                  ILake source)
        {
            return(new Task <object?>(() =>
            {
                try
                {
                    Thread.CurrentThread.Name = $"Extension Task {info.Id}";
                    using var procedure = info.OpenProcedure();
                    threadReceiver(Thread.CurrentThread);
                    procedure.Source = source;
                    procedure.Args = args;

                    TrackRunExtension(info);

                    return procedure.Run();
                }
                catch (Exception e)
                {
                    SLogger.Warn("ExtensionTask", "Uncaught error", e);

                    Microsoft.AppCenter.Analytics.Analytics.TrackEvent("Extension Error", new Dictionary <string, string>()
                    {
                        { "Name", info.Name() },
                        { "Id", info.Id },
                        { "Exception", e.ToString() }
                    });

                    var text = ClassTextReaderCache.Acquire(typeof(ExtensionTaskFactory));
                    var extFullName = info.Name();
                    var extName = extFullName.Length > 7 ? extFullName.Substring(0, 6) + "..." : extFullName;
                    var title = string.Format(text.RxGet("error_title_fmt"), extName);
                    LakeProvider.Lake.Get <IAppManager>().ShowException(title, e.GetType().Name, e);
                    return default;
                }
            }));
        }
Example #14
0
 public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
 {
     using (ui)
     {
         using (executor)
         {
             var text = ClassTextReaderCache.Acquire <EOemLock>();
             ui.Show();
             if (!ui.DoYN(text["warn"]))
             {
                 return;
             }
             if (!ui.DoYN(text["warn2"]))
             {
                 return;
             }
             executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
             var exitCode = executor.Fastboot(device, "oem lock").ExitCode;
             ui.Finish(exitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
         }
     }
 }
Example #15
0
        public void EntryPoint(ILeafUI _ui, ICommandExecutor _executor, IDevice device)
        {
            using var ui       = _ui;
            using var executor = _executor;
            var text = ClassTextReaderCache.Acquire <EFlashBoot>();

            ui.Show();
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Reset();
            fileDialog.Title  = text["EFlashBootSelectingTitle"];
            fileDialog.Filter = text["EFlashBootSelectingFilter"];

            fileDialog.Multiselect = false;
            if (fileDialog.ShowDialog() != true)
            {
                ui.EFinish();
            }
            executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
            var result = executor.Fastboot(device, $"flash boot \"{fileDialog.FileName}\"");

            ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
        }
Example #16
0
        public void MixGetClassText()
        {
            var text = ClassTextReaderCache.Acquire(typeof(F));

            Assert.ThrowsException <InvalidOperationException>(() => text.RxGetClassText("error_title_fmt"));
        }
Example #17
0
 static StatusMessages()
 {
     //加载缓存,避免线程问题
     ClassTextReaderCache.Acquire(typeof(TextCarrier));
 }
Example #18
0
 static TextCarrier()
 {
     Reader = ClassTextReaderCache.Acquire <TextCarrier>();
 }