private void apk_Click(object sender, RoutedEventArgs e) { AndroidController a = AndroidController.Instance; string caminho = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SGEA\\SGEA.SGEA.apk"; if (a.HasConnectedDevices) { caminho = "\"" + caminho + "\""; Device d = a.GetConnectedDevice(a.ConnectedDevices[0]); for (int i = 0; i < a.ConnectedDevices.Count; i++) { d = a.GetConnectedDevice(a.ConnectedDevices[i]); if (!d.SerialNumber.Contains("emulator")) { break; } } var ad = Adb.FormAdbShellCommand(d, false, "pm list packages SGEA.SGEA"); string x = Adb.ExecuteAdbCommand(ad); if (x != "package:SGEA.SGEA") { var ade = Adb.FormAdbCommand(d, "install " + caminho); Adb.ExecuteAdbCommand(ade); Xceed.Wpf.Toolkit.MessageBox.Show("O aplicativo foi instalado com sucesso"); } else { Xceed.Wpf.Toolkit.MessageBox.Show("O aplicativo já está instalado"); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Não há um celular Android conectado por USB"); } }
public void Update() { if (_device.State == DeviceState.ONLINE) { _root = Adb.ExecuteAdbCommand(Adb.FormAdbShellCommand(_device, false, "su", "-v")); _busybox = Adb.ExecuteAdbCommand(Adb.FormAdbShellCommand(_device, false, "busybox")); _getprop = Adb.ExecuteAdbCommand(Adb.FormAdbShellCommand(_device, false, "getprop")); } }
private void buttonRebootRecovery_Click(object sender, EventArgs e) { if (isConnected()) { cAppend("Rebooting into recovery..."); Adb.ExecuteAdbCommand(Adb.FormAdbCommand(" reboot recovery")); cAppend("Rebooting into recovery... {OK}"); } else { cAppend("{RebootRecovery} Please connect your device..."); return; } }
private void bd_Click(object sender, RoutedEventArgs e) { AndroidController a = AndroidController.Instance; string c = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SGEA\\sgea.db"; string imagens = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SGEA\\Imagens"; if (File.Exists(c)) { if (a.HasConnectedDevices) { c = "\"" + c + "\""; imagens = "\"" + imagens + "\""; Device d = a.GetConnectedDevice(a.ConnectedDevices[0]); for (int i = 0; i < a.ConnectedDevices.Count; i++) { d = a.GetConnectedDevice(a.ConnectedDevices[i]); if (!d.SerialNumber.Contains("emulator")) { break; } } var ad = Adb.FormAdbShellCommand(d, false, "rmdir -r sdcard/SGEA"); Adb.ExecuteAdbCommand(ad); ad = Adb.FormAdbShellCommand(d, false, "mkdir sdcard/SGEA"); Adb.ExecuteAdbCommand(ad); ad = Adb.FormAdbShellCommand(d, false, "mkdir sdcard/SGEA/Imagens"); Adb.ExecuteAdbCommand(ad); bool b = d.PushFile(c, "sdcard/SGEA", 100000); bool f = d.PushFile(imagens, "sdcard/SGEA/Imagens/", 100000); if (b && f) { Xceed.Wpf.Toolkit.MessageBox.Show("Banco de Dados foi transferido com sucesso"); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Banco de Dados não foi transferido"); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Não há um celular Android conectado por USB"); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("O banco de dados não existe. \nPor favor, entre em contato conosco"); } }
private void applyShowZen() { if (loading) { return; } AdbCommand command; if (showZenCheck.Checked) { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "put", "secure", "sysui_show_full_zen", "1"); } else { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "delete", "secure", "sysui_show_full_zen"); } Adb.ExecuteAdbCommand(command); }
private void applyImportance() { if (loading) { return; } AdbCommand command; if (importanceCheck.Checked) { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "put", "secure", "show_importance_slider", "1"); } else { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "delete", "secure", "show_importance_slider"); } Adb.ExecuteAdbCommand(command); }
private void applyClockSeconds() { if (loading) { return; } AdbCommand command; if (clockCombo.SelectedIndex == 0) { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "put", "secure", "clock_seconds", "1"); } else { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "delete", "secure", "clock_seconds"); } Adb.ExecuteAdbCommand(command); }
private void applyBatteryPercentage() { if (loading) { return; } AdbCommand command; if (clockCombo.SelectedIndex == 0) { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "put", "system", "status_bar_show_battery_percent", "1"); } else { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "delete", "system", "status_bar_show_battery_percent"); } Adb.ExecuteAdbCommand(command); }
private void applyVolumeShortcut() { if (loading) { return; } AdbCommand command1, command2; if (showZenCheck.Checked) { command1 = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "put", "secure", "sysui_volume_down_silent", "1"); command2 = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "put", "secure", "sysui_volume_up_silent", "1"); } else { command1 = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "delete", "secure", "sysui_volume_down_silent"); command2 = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "delete", "secure", "sysui_volume_up_silent"); } Adb.ExecuteAdbCommand(command1); Adb.ExecuteAdbCommand(command2); }
private static async Task DoCommand(string command) { // Clean the input command = command.Trim(); // Don't do anything if we have empty input if (command == "") { return; } // Split and handle command var args = SplitCommandLine(command).ToList(); switch (args[0].ToLower()) { case "help": PrintHelp(); break; case "register": { var service = ServiceManager.GetByName(args[1]); ServiceManager.Register(service); ServiceManager.RegisteredServicesDatabase.SaveAllRegistered(); Console.WriteLine(service + " registered"); } break; case "startall": { foreach (var service in ServiceManager.Registered) { var unifiedService = service as UnifiedService; if (unifiedService != null) { ServiceManager.StartUnified(unifiedService, null); } else { await ServiceManager.Start(service, true); } Console.WriteLine(service + " started"); } } break; case "stop": { var service = ServiceManager.GetByName(args[1]); await ServiceManager.Abort(service); Console.WriteLine(service + " stopped"); } break; case "start": { var service = ServiceManager.GetByName(args[1]); await ServiceManager.Start(service, true); Console.WriteLine(service + " started"); } break; case "send": { var service = ServiceManager.GetByName(args[1]); var address = args[2]; var message = args[3]; var textBubble = new TextBubble(Time.GetNowUnixTimestamp(), Bubble.BubbleDirection.Outgoing, address, null, false, service, message); await BubbleManager.Send(textBubble); Console.WriteLine(textBubble + " sent"); } break; case "deploy-unregister": { var pluginName = args[1]; var deployment = Settings.PluginDeployments.FirstOrDefault(x => x.Name.ToLower() == pluginName.ToLower()); if (deployment != null) { Settings.PluginDeployments.Remove(deployment); } MutableSettingsManager.Save(Settings); Console.WriteLine("Removed."); } break; case "deploy-register": { var pluginName = args[1]; var path = args[2].ToLower(); if (Settings.PluginDeployments != null) { var hasDeployment = Settings.PluginDeployments.FirstOrDefault(x => x.Name.ToLower() == pluginName.ToLower()) != null; if (hasDeployment) { Console.WriteLine("Plugin has already been registered in deployment system."); break; } } if (Settings.PluginDeployments == null) { Settings.PluginDeployments = new List <TerminalSettings.PluginDeployment>(); } Settings.PluginDeployments.Add(new TerminalSettings.PluginDeployment { Name = pluginName, Path = path, }); MutableSettingsManager.Save(Settings); Console.WriteLine("Plugin registered!"); } break; case "deploy-clean": { var pluginName = args[1]; var deployment = Settings.PluginDeployments.FirstOrDefault(x => x.Name.ToLower() == pluginName.ToLower()); if (deployment != null) { deployment.Assemblies = null; MutableSettingsManager.Save(Settings); Console.WriteLine("Cleaned assemblies."); } else { Console.WriteLine("Could not find plugin deployment: " + pluginName); } } break; case "deploy": { var pluginName = args[1]; var deployment = Settings.PluginDeployments.FirstOrDefault(x => x.Name.ToLower() == pluginName.ToLower()); var oldAssemblies = deployment.Assemblies ?? new List <TerminalSettings.PluginDeployment.Assembly>(); var assembliesToDeploy = new List <TerminalSettings.PluginDeployment.Assembly>(); var newAssemblies = new List <TerminalSettings.PluginDeployment.Assembly>(); var pluginManifest = Path.Combine(deployment.Path, "PluginManifest.xml"); if (!File.Exists(pluginManifest)) { Console.WriteLine("A plugin manifest file is needed!"); break; } foreach (var assemblyFile in Directory.EnumerateFiles(deployment.Path, "*.dll") .Concat(new [] { pluginManifest })) { var assemblyFileName = Path.GetFileName(assemblyFile); if (PlatformManager.AndroidLinkedAssemblies.Contains(assemblyFileName)) { continue; } var lastModified = File.GetLastWriteTime(assemblyFile); var newAssembly = new TerminalSettings.PluginDeployment.Assembly { Name = assemblyFileName, Modified = lastModified }; newAssemblies.Add(newAssembly); var oldAssembly = oldAssemblies.FirstOrDefault(x => x.Name == assemblyFileName); if (oldAssembly == null) { assembliesToDeploy.Add(newAssembly); } else if (oldAssembly.Modified != lastModified) { assembliesToDeploy.Add(newAssembly); } } deployment.Assemblies = newAssemblies; MutableSettingsManager.Save(Settings); var instance = AndroidController.Instance; var devices = instance.ConnectedDevices; Device selectedDevice; if (devices.Count > 1) { Console.WriteLine("Please pick a device:"); var counter = 0; foreach (var device in devices) { Console.WriteLine(counter++ + ") " + device); } Console.Write("Selection: "); var selection = int.Parse(Console.ReadLine().Trim()); selectedDevice = instance.GetConnectedDevice(devices[selection]); } else { selectedDevice = instance.GetConnectedDevice(); } var remotePath = "/sdcard/Disa/plugins/" + deployment.Name; if (selectedDevice.FileSystem.FileOrDirectory(remotePath) == ListingType.NONE) { selectedDevice.FileSystem.MakeDirectory(remotePath); } foreach (var assemblyToDeploy in assembliesToDeploy) { Console.WriteLine("Transferring " + assemblyToDeploy.Name + "..."); var remoteAssembly = remotePath + "/" + assemblyToDeploy.Name; if (selectedDevice.FileSystem.FileOrDirectory(remoteAssembly) != ListingType.NONE) { selectedDevice.FileSystem.Delete(remoteAssembly); } selectedDevice.PushFile(Path.Combine(deployment.Path, assemblyToDeploy.Name), remoteAssembly); } Console.WriteLine("Plugin deployed! Restarting Disa..."); var cmd = Adb.FormAdbShellCommand(selectedDevice, false, "am", "force-stop", "com.disa"); Adb.ExecuteAdbCommand(cmd); Task.Delay(250).Wait(); cmd = Adb.FormAdbShellCommand(selectedDevice, false, "monkey", "-p com.disa", "-c android.intent.category.LAUNCHER 1"); Adb.ExecuteAdbCommand(cmd); Console.WriteLine("Disa restarted!"); } break; case "conversation-export": BubbleGroupExport.ExportConversation(args[1], args[2]); Console.WriteLine("Done"); break; case "deploy-print-dependencies": { var pluginName = args[1]; var deployment = Settings.PluginDeployments.FirstOrDefault(x => x.Name.ToLower() == pluginName.ToLower()); foreach (var assemblyFile in Directory.EnumerateFiles(deployment.Path, "*.dll")) { var assemblyFileName = Path.GetFileName(assemblyFile); if (PlatformManager.AndroidLinkedAssemblies.Contains(assemblyFileName)) { continue; } var module = ModuleDefinition.ReadModule(assemblyFile); Console.WriteLine(assemblyFileName + ": "); foreach (var referenceAssembly in module.AssemblyReferences) { Console.WriteLine("> " + referenceAssembly.FullName); } } } break; default: { var service = ServiceManager.GetByName(args[0]); if (service != null) { var terminal = service as ITerminal; if (terminal != null) { try { terminal.DoCommand(args.GetRange(1, args.Count - 1).ToArray()); } catch (Exception ex) { Console.WriteLine("Error in processing a service terminal command: " + ex); } } } } break; } }
private void applyIconBlacklist() { if (loading) { return; } String value = ""; if (!rotateCheck.Checked) { value += "rotate,"; } if (!headsetCheck.Checked) { value += "headset,"; } if (!managedCheck.Checked) { value += "managed_profile,"; } if (!castCheck.Checked) { value += "cast,"; } if (!hotspotCheck.Checked) { value += "hotspot,"; } if (!bluetoothCheck.Checked) { value += "bluetooth,"; } if (!zenCheck.Checked) { value += "zen,"; } if (!volumeCheck.Checked) { value += "volume,"; } if (!wifiCheck.Checked) { value += "wifi,"; } if (!ethernetCheck.Checked) { value += "ethernet,"; } if (!mobileCheck.Checked) { value += "mobile,"; } if (!airplaneCheck.Checked) { value += "airplane,"; } if (batteryCombo.SelectedIndex == 2) { value += "battery,"; } if (!alarmCheck.Checked) { value += "alarm_clock,"; } if (clockCombo.SelectedIndex == 2) { value += "clock,"; } if (!nfcCheck.Checked) { value += "nfc_on,"; } AdbCommand command; if (value.Length != 0) { value = value.Substring(0, value.Length - 1); command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "put", "secure", "icon_blacklist", value); } else { command = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "delete", "secure", "icon_blacklist"); } Adb.ExecuteAdbCommand(command); }
private void getCurrentSettings() { StringReader reader; String line = null; // Set to defaults rotateCheck.Checked = true; headsetCheck.Checked = true; managedCheck.Checked = true; castCheck.Checked = true; hotspotCheck.Checked = true; bluetoothCheck.Checked = true; zenCheck.Checked = true; volumeCheck.Checked = true; wifiCheck.Checked = true; ethernetCheck.Checked = true; mobileCheck.Checked = true; airplaneCheck.Checked = true; batteryCombo.SelectedIndex = 1; alarmCheck.Checked = true; clockCombo.SelectedIndex = 1; nfcCheck.Checked = true; showZenCheck.Checked = false; volumeSilentCheck.Checked = false; importanceCheck.Checked = false; // Get secure settings AdbCommand secureCommand = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "list", "secure"); String secResults = Adb.ExecuteAdbCommand(secureCommand); line = null; reader = new StringReader(secResults); do { line = reader.ReadLine(); if (line != null) { if (line.Contains("icon_blacklist")) { rotateCheck.Checked = !line.Contains("rotate"); headsetCheck.Checked = !line.Contains("headset"); managedCheck.Checked = !line.Contains("managed_profile"); castCheck.Checked = !line.Contains("cast"); hotspotCheck.Checked = !line.Contains("hotspot"); bluetoothCheck.Checked = !line.Contains("bluetooth"); zenCheck.Checked = !line.Contains("zen"); volumeCheck.Checked = !line.Contains("volume"); wifiCheck.Checked = !line.Contains("wifi"); ethernetCheck.Checked = !line.Contains("ethernet"); mobileCheck.Checked = !line.Contains("mobile"); airplaneCheck.Checked = !line.Contains("airplane"); if (line.Contains("battery")) { batteryCombo.SelectedIndex = 2; } else { batteryCombo.SelectedIndex = 1; } alarmCheck.Checked = !line.Contains("alarm_clock"); if (line.Contains(",clock") || line.Contains("clock,") || line.Contains(" clock")) { clockCombo.SelectedIndex = 2; } else { clockCombo.SelectedIndex = 1; } nfcCheck.Checked = !line.Contains("nfc_on"); } else if (line.Contains("clock_seconds")) { if (line.Contains("1")) { clockCombo.SelectedIndex = 0; } } else if (line.Contains("sysui_show_full_zen")) { showZenCheck.Checked = line.Contains("1"); } else if (line.Contains("sysui_volume_up_silent") || line.Contains("sysui_volume_down_silent")) { volumeSilentCheck.Checked = line.Contains("1"); } else if (line.Contains("show_importance_slider")) { importanceCheck.Checked = line.Contains("1"); } } }while (line != null); // Get system settings AdbCommand systemCommand = Adb.FormAdbShellCommand(device, false, "settings", "--user", "current", "list", "system"); String sysResults = Adb.ExecuteAdbCommand(systemCommand); line = null; reader = new StringReader(sysResults); do { line = reader.ReadLine(); if (line != null) { if (line.Contains("status_bar_show_battery_percent")) { if (line.Contains("1")) { batteryCombo.SelectedIndex = 0; } } } }while (line != null); }