Skip to content

Commit

Permalink
基本完成网络调试断开器
Browse files Browse the repository at this point in the history
  • Loading branch information
zsh2401 committed May 19, 2020
1 parent d0fcc6f commit 7d4846e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/AutumnBox.Basic.Shared/Device/NetDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** date: 2018/8/30 4:53:29 (UTC +8:00)
** desc: ...
*************************************************/
using AutumnBox.Basic.Calling;
using AutumnBox.Basic.Util;
using System;
using System.Net;
Expand Down Expand Up @@ -63,12 +64,12 @@ public void Disconnect(bool closeNetDebugging = true)
{
if (closeNetDebugging)
{
using var cmd = BasicBooter.CommandProcedureManager.OpenCommand("adb.exe", $"usb");
using var cmd = BasicBooter.CommandProcedureManager.OpenADBCommand(this, $"usb");
cmd.Execute().ThrowIfExitCodeNotEqualsZero();
}
else
{
using var cmd = BasicBooter.CommandProcedureManager.OpenCommand("adb.exe", $"disconnect {SerialNumber}");
using var cmd = BasicBooter.CommandProcedureManager.OpenADBCommand(null, $"disconnect {SerialNumber}");
cmd.Execute().ThrowIfExitCodeNotEqualsZero();
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/AutumnBox.Essentials/AutumnBox.Essentials.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\Icons\devpanelswitcher.png" />
<None Remove="Resources\Icons\disconnect-netdebbugging.png" />
<None Remove="Resources\Icons\enable-dev-netdebugging.png" />
<None Remove="Resources\Icons\reboot.png" />
<None Remove="Resources\Icons\wireless.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Icons\disconnect-netdebbugging.png" />
<EmbeddedResource Include="Resources\Icons\enable-dev-netdebugging.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Icons\devpanelswitcher.png" />
<EmbeddedResource Include="Resources\Icons\reboot.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace AutumnBox.Essentials.Extensions
[ClassText("can_not_read_ip", "Net-debugging is enabled,but can't read device's ip address. please connect the device manually.", "zh-CN:网络调试开启成功,但无法获取设备IP地址,因此无法进行自动连接")]
[ClassText("yn_try_to_connect", "It's seems like success.Do you want to try to connect this net device?", "zh-CN:似乎成功了,你想要连接到这个设备吗?")]
[DeviceNetDebuggingPolicy]
[ExtIcon("Resources.Icons.enable-dev-netdebugging.png")]
class EEnableCurrentDeviceNetDebugging : LeafExtensionBase
{
class DeviceNetDebuggingPolicy : ExtNormalRunnablePolicyAttribute
Expand Down
36 changes: 35 additions & 1 deletion src/AutumnBox.Essentials/Extensions/ENetDeviceDisconnecter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,48 @@
*
* ==============================================================================
*/
using AutumnBox.Basic.Device;
using AutumnBox.Leafx.Enhancement.ClassTextKit;
using AutumnBox.OpenFramework.Extension;
using AutumnBox.OpenFramework.Extension.Leaf;
using AutumnBox.OpenFramework.Open.LKit;

namespace AutumnBox.Essentials.Extensions
{
[ExtHidden]
[ExtName("Disconnect net-debugging", "zh-CN:断开当前设备")]
[ExtPriority(ExtPriority.HIGH)]
[ExtIcon("Resources.Icons.disconnect-netdebbugging.png")]
[IsNetDevicePolicy]
[ClassText("option_disconnect", "Only disconnect", "zh-cn:仅断开")]
[ClassText("option_close", "Disable net debug", "zh-cn:关闭")]
[ClassText("option_title", "Close net debugging of the device after disconnected?", "zh-cn:断开网络连接后,是否关闭设备的USB网络调试?")]
class ENetDeviceDisconnecter : LeafExtensionBase
{
private class IsNetDevicePolicy : ExtNormalRunnablePolicyAttribute
{
public override bool IsRunnable(RunnableCheckArgs args)
{
return args.TargetDevice is NetDevice;
}
}
[LMain]
public void EntryPoint(ILeafUI ui, IDevice device)
{
using (ui)
{
ui.Show();
bool? choice = ui.DoChoice(this.RxGetClassText("option_title"), this.RxGetClassText("option_close"), this.RxGetClassText("option_disconnect"));
if (choice == null)
{
ui.Shutdown();
return;
}
else
{
((NetDevice)device).Disconnect((bool)choice);
ui.Finish(StatusMessages.Success);
}
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/AutumnBox.GUI/Model/ExtensionDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ public ExtensionDock(IExtensionInfo extInf)
Execute = new FlexiableCommand(p =>
{
ExecuteImpl();
});
})
{
CanExecuteProp = ExtensionInfo.IsRunnableCheck(devicesManager.SelectedDevice)
};
devicesManager.DeviceSelectionChanged += DeviceSelectionChanged;
}

Expand Down

0 comments on commit 7d4846e

Please sign in to comment.