Skip to content

Commit

Permalink
fastboot请求权限
Browse files Browse the repository at this point in the history
  • Loading branch information
mujianwu committed Oct 29, 2024
1 parent 0b00428 commit 4db72c8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
9 changes: 9 additions & 0 deletions UotanToolbox/Assets/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions UotanToolbox/Assets/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1485,4 +1485,7 @@ If you wish to replace Magisk, please first select your Magisk on the Basic Flas
<data name="Wiredflash_RepairBoot" xml:space="preserve">
<value>Repairing Boot image......</value>
</data>
<data name="Common_FBRoot" xml:space="preserve">
<value>Fastboot device detected, but it seems that the current system has not written relevant USB rules. Should you try to execute with root privileges?</value>
</data>
</root>
3 changes: 3 additions & 0 deletions UotanToolbox/Assets/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1482,4 +1482,7 @@
<data name="Wiredflash_RepairBoot" xml:space="preserve">
<value>正在修补Boot镜像......</value>
</data>
<data name="Common_FBRoot" xml:space="preserve">
<value>检测到Fastboot设备,但当前系统似乎存未写入相关USB规则,是否尝试以Root权限执行?</value>
</data>
</root>
19 changes: 18 additions & 1 deletion UotanToolbox/Common/GetDevicesInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public static async Task<string[]> DevicesList()
{
string devcon = Global.System == "Windows" ? await CallExternalProgram.Devcon("find usb*") : await CallExternalProgram.LsUSB();
string[] adbdevices = StringHelper.ADBDevices(await CallExternalProgram.ADB("devices"));
string[] fbdevices = StringHelper.FastbootDevices(await CallExternalProgram.Fastboot("devices"));
string fbdevice = await CallExternalProgram.Fastboot("devices");
string[] fbdevices = StringHelper.FastbootDevices(fbdevice);
string[] hdcdevice = StringHelper.HDCDevices(await CallExternalProgram.HDC("list targets"));
string[] comdevices = StringHelper.COMDevices(devcon);
if (Global.System.Contains("Linux") && Global.root)
Expand All @@ -41,6 +42,22 @@ public static async Task<string[]> DevicesList()
.TryShow();
Global.root = false;
}
if (fbdevice.Contains("no permissions"))
{
Global.MainDialogManager.CreateDialog()
.WithTitle(GetTranslation("Common_Warn"))
.WithContent(GetTranslation("Common_FBRoot"))
.OfType(NotificationType.Warning)
.WithActionButton(GetTranslation("ConnectionDialog_Confirm"), async _ =>
{
string cmd = Path.Combine(Global.bin_path, "platform-tools", "fastboot");
await CallExternalProgram.Sudo("chmod -R 777 /dev/bus/usb/");
fbdevices = StringHelper.FastbootDevices(await CallExternalProgram.Fastboot("devices"));
}, true)
.WithActionButton(GetTranslation("ConnectionDialog_Cancel"), _ => { }, true)
.TryShow();
Global.root = false;
}
if (devcon.Contains("HDC Device") && hdcdevice.Length == 0)
{
Global.MainDialogManager.CreateDialog()
Expand Down

0 comments on commit 4db72c8

Please sign in to comment.