Skip to content

Commit

Permalink
Fix process encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
13584452567 committed Oct 28, 2024
1 parent 3444dbb commit 6f78755
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
50 changes: 38 additions & 12 deletions UotanToolbox/Common/CallExternalProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public static async Task<string> ADB(string adbshell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process adb = new Process();
adb.StartInfo = adbexe;
Expand All @@ -38,7 +40,9 @@ public static async Task<string> HDC(string hdcshell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process hdc = new Process();
hdc.StartInfo = hdcexe;
Expand All @@ -60,7 +64,9 @@ public static async Task<string> Fastboot(string fbshell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process fb = new Process();
fb.StartInfo = fastboot;
Expand All @@ -82,7 +88,9 @@ public static async Task<string> Devcon(string shell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process devcon = new Process();
devcon.StartInfo = fastboot;
Expand All @@ -104,7 +112,9 @@ public static async Task<string> Sudo(string shell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process fb = new Process();
fb.StartInfo = fastboot;
Expand All @@ -126,7 +136,9 @@ public static async Task<string> QCNTool(string shell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process qcn = new Process();
qcn.StartInfo = qcntool;
Expand All @@ -148,7 +160,9 @@ public static async Task<string> Pnputil(string shell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process pnp = new Process();
pnp.StartInfo = pnputil;
Expand All @@ -169,7 +183,9 @@ public static async Task<string> LsUSB()
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process fb = new Process();
fb.StartInfo = fastboot;
Expand All @@ -191,7 +207,9 @@ public static async Task<string> LinuxLS(string shell)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process fb = new Process();
fb.StartInfo = fastboot;
Expand All @@ -215,6 +233,8 @@ public static async Task<string> Scrcpy(string arg)
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8,
WorkingDirectory = Path.Combine(Global.bin_path, "platform-tools")
};
using Process sc = new Process();
Expand All @@ -240,7 +260,9 @@ public static async Task<string> SevenZip(string args)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process SevenZip = new Process();
SevenZip.StartInfo = SevenZipexe;
Expand Down Expand Up @@ -273,7 +295,9 @@ public static async Task<string> SevenZip(string args)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
Process mb = new Process
{
Expand Down Expand Up @@ -308,7 +332,9 @@ public static async Task<string> File(string path)
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.UTF8
};
using Process process = new Process
{
Expand Down
6 changes: 1 addition & 5 deletions UotanToolbox/Features/Appmgr/AppmgrViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ await Task.Run(async () =>
{
await CallExternalProgram.ADB($"-s {Global.thisdevice} push \"{Path.Join(Global.runpath, "Push", "list_apps")}\" /data/local/tmp/");
await CallExternalProgram.ADB($"-s {Global.thisdevice} shell chmod 777 /data/local/tmp/list_apps");
await CallExternalProgram.ADB($"-s {Global.thisdevice} shell /data/local/tmp/list_apps > /data/local/tmp/apps.txt");
await CallExternalProgram.ADB($"-s {Global.thisdevice} pull /data/local/tmp/apps.txt {Global.tmp_path}");
string fulllists = File.ReadAllText(Path.Join(Global.tmp_path, "apps.txt"));
string fulllists = await CallExternalProgram.ADB($"-s {Global.thisdevice} shell /data/local/tmp/list_apps ");
List<ApplicationInfo> fullapplications = StringHelper.ParseApplicationInfo(fulllists);
string fullApplicationsList = !IsSystemAppDisplayed
? await CallExternalProgram.ADB($"-s {Global.thisdevice} shell pm list packages -3")
Expand Down Expand Up @@ -147,9 +145,7 @@ await Dispatcher.UIThread.InvokeAsync(() =>
.ThenBy(app => app.Name)
.ToList();
Applications = new ObservableCollection<ApplicationInfo>(applicationInfos);
await CallExternalProgram.ADB($"-s {Global.thisdevice} shell rm /data/local/tmp/apps.txt");
await CallExternalProgram.ADB($"-s {Global.thisdevice} shell rm /data/local/tmp/list_apps");
File.Delete(Path.Join(Global.tmp_path, "apps.txt"));
}
else if (sukiViewModel.Status == GetTranslation("Home_OpenHOS"))
{
Expand Down

0 comments on commit 6f78755

Please sign in to comment.