Skip to content

Commit

Permalink
fix different errors when ata is offline
Browse files Browse the repository at this point in the history
  • Loading branch information
msartore committed Oct 15, 2024
1 parent e714014 commit 8b1027f
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions ATA-GUI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private void ExtractDeviceData()
buttonSetRotation.Text = ATA.CurrentDeviceSelected.IsRotationFreeEnabled ? "Unset" : "Set";

LogWriteLine("device info extracted", LogType.OK);
disableEnableSystem(true);
disableSystem(false);
});
}
else
Expand Down Expand Up @@ -374,7 +374,7 @@ private void ExtractDeviceData()

Invoke(delegate
{
disableEnableSystem(false);
disableSystem(true);
buttonDisconnectIP.Enabled = false;
LogWriteLine("failed to extract device info!", LogType.ERROR);
MessageShowBox("Failed to extract device info\nError message: " + errorMessage, 0);
Expand Down Expand Up @@ -511,18 +511,6 @@ private void sortApks(string[] arrayApkTmp)
ATA.CurrentDeviceSelected.AppsString.Sort();
}

private void disableEnableSystem(bool enable)
{
textBoxPort.Enabled = !enable;
buttonMobileScreenShare.Enabled = enable;
groupBoxDeviceInfo.Enabled = enable;
groupBoxRebootMenu.Enabled = enable;
groupBoxAPKMenu.Enabled = enable;
buttonDeviceLogs.Enabled = enable;
buttonTaskManager.Enabled = enable;
tabPageTools.Enabled = enable;
}

private void textboxClick(object sender, EventArgs e)
{
if (textBoxSearch.Text == "Search" && !ata.TextboxClear)
Expand Down Expand Up @@ -712,7 +700,7 @@ private async Task<bool> DeviceListExtractor(bool isAdb)
switch (ata.Devices.Count)
{
case 0:
disableEnableSystem(false);
disableSystem(true);
panelFastboot.Enabled = false;
panelRecovery.Enabled = false;
LogWriteLine("no devices detected. If this problem continues, ensure that USB debugging is enabled on your device. Additionally, verify that the correct drivers are installed; you can find the necessary links under Help -> OEM Drivers. For detailed instructions on enabling USB debugging and more information, please refer to this video tutorial: https://www.youtube.com/watch?v=W7nkxS9LMXs.", LogType.ERROR);
Expand Down Expand Up @@ -744,6 +732,7 @@ public static bool pingCheck()
reply = myPing.Send(IPAddress.Parse("1.1.1.1"), 1000, new byte[32], new PingOptions());
if (reply.Status == IPStatus.Success)
{

return true;
}
}
Expand All @@ -754,6 +743,11 @@ public static bool pingCheck()
return false;
}

public void updateOnlineStatus()
{
ata.IsConnected = pingCheck();
}

private void MainForm_Shown(object sender, EventArgs e)
{
if (FeedbackForm.checkFeedbackFile())
Expand All @@ -777,7 +771,7 @@ private void MainForm_Shown(object sender, EventArgs e)

private void DataLoadingUI()
{
ata.IsConnected = pingCheck();
updateOnlineStatus();

if (ata.IsConnected)
{
Expand Down Expand Up @@ -972,6 +966,8 @@ private async Task<bool> AdbFastbootExist(bool isAdb)
}
else
{
updateOnlineStatus();

await ADBDownload(false);
ATA.ADBPath = ATA.FindExecutable(ata.FILEADB);
ATA.FASTBOOTPath = ATA.FindExecutable(ata.FILEFastboot);
Expand Down Expand Up @@ -1187,7 +1183,7 @@ private void comboBoxDevices_SelectedIndexChanged(object sender, EventArgs e)
{
ATA.CurrentDeviceSelected = ata.Devices[comboBoxDevices.SelectedIndex];

disableEnableSystem(false);
disableSystem(true);
panelFastboot.Enabled = false;
panelRecovery.Enabled = false;
}
Expand Down Expand Up @@ -1219,7 +1215,7 @@ private void tabControl1_Selected(object sender, TabControlEventArgs e)
buttonDeviceLogs.Enabled = false;
buttonTaskManager.Enabled = false;
buttonMobileScreenShare.Enabled = false;
disableEnableSystem(false);
disableSystem(true);
}

if (ata.CurrentTab != Tab.SYSTEM)
Expand All @@ -1240,7 +1236,7 @@ public async Task<bool> ADBDownload(bool isUpdate)
}
Invoke(delegate
{
disableEnableSystem(false);
disableSystem(true);
buttonDisconnectIP.Enabled = false;
});

Expand Down Expand Up @@ -1324,8 +1320,14 @@ private void disableSystem(bool a)
{
Invoke(delegate
{
tabPageSystem.Enabled = !a;
textBoxPort.Enabled = a;
buttonMobileScreenShare.Enabled = !a;
groupBoxDeviceInfo.Enabled = !a;
groupBoxRebootMenu.Enabled = !a;
groupBoxAPKMenu.Enabled = !a;
tabPageTools.Enabled = !a;
buttonDeviceLogs.Enabled = !a;
buttonTaskManager.Enabled = !a;
});
}

Expand Down Expand Up @@ -1380,6 +1382,8 @@ private void buttonMobileScreenShare_Click(object sender, EventArgs e)
}
else
{
updateOnlineStatus();

try
{
backgroundWorkerExeDownloader.RunWorkerAsync();
Expand Down Expand Up @@ -1473,6 +1477,8 @@ private async void labelSettings_Click(object sender, EventArgs e)

if (dialogResult == DialogResult.Yes)
{
updateOnlineStatus();

_ = await ADBDownload(true);
}
}
Expand Down

0 comments on commit 8b1027f

Please sign in to comment.