0
我正在使用一個使用AndroidLib.dll的HTC One Max實用程序。在使用AndroidLib.dll調用之後,進程無法退出
AndroidLib Git的樞紐位置:https://github.com/regaw-leinad/AndroidLib
下面的類是我的代碼用來執行ADB介面根命令。
public static void ExecuteAdbShellCommandInputString(Device device, params string[] inputLines)
{
lock (_lock)
{
Command.RunProcessWriteInput(AndroidController.Instance.ResourceDirectory + ADB_EXE, "shell", inputLines);
}
}
internal static void RunProcessWriteInput(string executable, string arguments, params string[] input)
{
using (Process p = new Process())
{
p.StartInfo.FileName = executable;
p.StartInfo.Arguments = arguments;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.Start();
using (StreamWriter w = p.StandardInput)
for (int i = 0; i < input.Length; i++)
w.WriteLine(input[i]);
p.WaitForExit();
}
}
我在下面的代碼中的命令執行,但從來沒有退出,我的表單程序鎖定。
private void unlockboot_Click(object sender, EventArgs e)
{
button1.Enabled = false; // to prevent user from spamming the unlock button
button2.Enabled = false;
string serial;
// Setting up the Android ADB Daemon and getting the device serial.
android = AndroidController.Instance;
serial = android.ConnectedDevices[0];
device = android.GetConnectedDevice(serial);
// Send message to Console Output RichTextBox and executing commands.
richTextBox1.Clear();
richTextBox1.Text = "Begin Bootloader Flag Unlock Process.\n";
Adb.ExecuteAdbShellCommandInputString(device, "su", @"echo -ne 'HTCU' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796", "exit", "exit");
richTextBox1.Text += "Completed... Exiting ADB Root.\n";
button1.Enabled = true;
button2.Enabled = true;
button3.Enabled = true;
// Killing the ADB Daemon and closing out resources.
android.Dispose();
richTextBox1.Text += "Your Bootloader has been Unlocked.\n";
richTextBox1.ScrollToCaret();
}
這讓我難住我添加了退出命令從退出根外殼和另一個退出adb外殼。
感謝您的幫助。
DLL是Windows庫,不能輕易用於基於Linux的環境(如Android)。 – CommonsWare