Skip to content

Commit c66c01c

Browse files
Merge pull request #137 from appdevforall/feat/ADFA-4553-remove-tunnel-ui
ADFA-4553 (slice 2): remove the dead tunnel/enable/SOCKS Java
2 parents e2bbe0e + 2c1d59c commit c66c01c

5 files changed

Lines changed: 23 additions & 279 deletions

File tree

Lines changed: 12 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,41 @@
11
/*
22
* ============================================================================
33
* Name : DashboardManager.java
4-
* Author : IIAB Project
5-
* Copyright : Copyright (c) 2026 IIAB Project
6-
* Description : Initial dasboard status helper
4+
* Author : AppDevForAll
5+
* Copyright : Copyright (c) 2026 AppDevForAll
6+
* Description : Home dashboard status helper: binds the Wi-Fi and Hotspot tiles
7+
* and reflects their OS connectivity state on the LEDs. The legacy
8+
* "tunnel"/ESPW toggle was removed with the dead SOCKS-proxy
9+
* mechanism (ADFA-4553); content is served from the native local
10+
* server, so there is no tunnel state to display.
711
* ============================================================================
812
*/
913
package org.iiab.controller;
1014

1115
import android.app.Activity;
1216
import android.content.Intent;
1317
import android.provider.Settings;
14-
import android.transition.AutoTransition;
15-
import android.transition.TransitionManager;
1618
import android.view.View;
17-
import android.view.ViewGroup;
18-
import android.widget.LinearLayout;
1919

2020
public class DashboardManager {
2121

2222
private final Activity activity;
23-
private final LinearLayout dashboardContainer;
2423

25-
private final View dashWifi, dashHotspot, dashTunnel;
26-
private final View ledWifi, ledHotspot, ledTunnel;
27-
private final View standaloneEspwButton;
28-
private final View standaloneEspwDescription;
24+
private final View dashWifi, dashHotspot;
25+
private final View ledWifi, ledHotspot;
2926

30-
// Memory variables to avoid freezing the screen
31-
private boolean lastTunnelState = false;
32-
private boolean lastDegradedState = false;
33-
private boolean isFirstRun = true;
34-
35-
public interface DashboardActionCallback {
36-
void onToggleEspwRequested();
37-
}
38-
39-
public DashboardManager(Activity activity, View rootView, DashboardActionCallback callback) {
27+
public DashboardManager(Activity activity, View rootView) {
4028
this.activity = activity;
4129

42-
// Bind all the views
43-
dashboardContainer = (LinearLayout) rootView.findViewById(R.id.dashboard_container);
4430
dashWifi = rootView.findViewById(R.id.dash_wifi);
4531
dashHotspot = rootView.findViewById(R.id.dash_hotspot);
46-
dashTunnel = rootView.findViewById(R.id.dash_tunnel);
47-
4832
ledWifi = rootView.findViewById(R.id.led_wifi);
4933
ledHotspot = rootView.findViewById(R.id.led_hotspot);
50-
ledTunnel = rootView.findViewById(R.id.led_tunnel);
51-
52-
standaloneEspwButton = rootView.findViewById(R.id.control);
53-
standaloneEspwDescription = rootView.findViewById(R.id.control_description);
5434

55-
setupListeners(callback);
35+
setupListeners();
5636
}
5737

58-
private void setupListeners(DashboardActionCallback callback) {
38+
private void setupListeners() {
5939
// Single tap opens Settings directly
6040
dashWifi.setOnClickListener(v -> activity.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)));
6141

@@ -68,54 +48,11 @@ private void setupListeners(DashboardActionCallback callback) {
6848
activity.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
6949
}
7050
});
71-
72-
// The Tunnel/ESPW toggle logic
73-
View.OnClickListener toggleEspw = v -> callback.onToggleEspwRequested();
74-
standaloneEspwButton.setOnClickListener(toggleEspw);
75-
dashTunnel.setOnClickListener(toggleEspw);
7651
}
7752

7853
// Updates the LED graphics based on actual OS connectivity states
7954
public void updateConnectivityLeds(boolean isWifiOn, boolean isHotspotOn) {
8055
ledWifi.setBackgroundResource(isWifiOn ? R.drawable.led_on_green : R.drawable.led_off);
8156
ledHotspot.setBackgroundResource(isHotspotOn ? R.drawable.led_on_green : R.drawable.led_off);
8257
}
83-
84-
// The Magic Morphing Animation!
85-
public void setTunnelState(boolean isTunnelActive, boolean isDegraded) {
86-
// ANTI-FREEZE SHIELD!
87-
// If the state is exactly the same as 3 seconds ago, abort to avoid blocking the UI
88-
if (!isFirstRun && lastTunnelState == isTunnelActive && lastDegradedState == isDegraded) {
89-
return;
90-
}
91-
isFirstRun = false;
92-
lastTunnelState = isTunnelActive;
93-
lastDegradedState = isDegraded;
94-
95-
// Tells Android to smoothly animate any layout changes we make next
96-
TransitionManager.beginDelayedTransition((ViewGroup) dashboardContainer.getParent(), new AutoTransition().setDuration(300));
97-
98-
if (isTunnelActive) {
99-
// Morph into 33% / 33% / 33% Dashboard mode
100-
standaloneEspwButton.setVisibility(View.GONE);
101-
standaloneEspwDescription.setVisibility(View.GONE);
102-
dashTunnel.setVisibility(View.VISIBLE);
103-
ledTunnel.setBackgroundResource(isDegraded ? R.drawable.led_on_orange : R.drawable.led_on_green);
104-
105-
// Force recalculate
106-
dashboardContainer.setWeightSum(3f);
107-
} else {
108-
// Morph back into 50% / 50% mode
109-
dashTunnel.setVisibility(View.GONE);
110-
// TODO: [RESTORE] Uncomment to show ESPW button again
111-
// standaloneEspwButton.setVisibility(View.VISIBLE);
112-
// standaloneEspwDescription.setVisibility(View.VISIBLE);
113-
// The LED turns off implicitly since the whole dash_tunnel hides, but we can enforce it:
114-
ledTunnel.setBackgroundResource(R.drawable.led_off);
115-
// Force recalculate
116-
dashboardContainer.setWeightSum(2f);
117-
}
118-
// Force recalculate
119-
dashboardContainer.requestLayout();
120-
}
12158
}

‎controller/app/src/main/java/org/iiab/controller/MainActivity.java‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
8080
private long serverUpSinceMs = 0L; // ADFA-4466: for server_stopped uptime bucket
8181
public boolean isNegotiating = false;
8282
public DashboardFragment.SystemState currentSystemState = DashboardFragment.SystemState.NONE;
83-
public boolean isProxyDegraded = false;
8483
public Boolean targetServerState = null;
8584
public String serverTransitionText = "";
8685
public UsageFragment usageFragment;
@@ -653,25 +652,6 @@ private boolean pingUrl(String urlStr) {
653652
}
654653
}
655654

656-
private void runNegotiationSequence() {
657-
isNegotiating = true;
658-
runOnUiThread(() -> {
659-
updateUIColorsAndVisibility(); // We forced an immediate visual update
660-
});
661-
662-
AppExecutors.get().io().execute(() -> {
663-
// Native architecture: content is served locally at localhost:8085.
664-
boolean localAlive = pingUrl("http://localhost:8085/home");
665-
666-
isNegotiating = false;
667-
updateServerAlive(localAlive);
668-
isProxyDegraded = false;
669-
currentTargetUrl = localAlive ? "http://localhost:8085/home" : null;
670-
671-
runOnUiThread(this::updateUIColorsAndVisibility);
672-
});
673-
}
674-
675655
private void prepareVpn() {
676656
BatteryUtils.checkAndPromptOptimizations(MainActivity.this, batteryOptLauncher);
677657
}
@@ -760,7 +740,6 @@ else if (mode == AppCompatDelegate.MODE_NIGHT_YES)
760740
else themeToggle.setImageResource(R.drawable.ic_theme_system);
761741
}
762742

763-
764743
@Override
765744
protected void onStart() {
766745
super.onStart();
@@ -800,29 +779,6 @@ public void onClick(View view) {
800779
// Delegated
801780
}
802781

803-
public void handleControlClick() {
804-
if (!isServerAlive) {
805-
Snackbar.make(findViewById(android.R.id.content), R.string.qr_error_no_server, Snackbar.LENGTH_LONG).show();
806-
return;
807-
}
808-
if (prefs.getEnable()) {
809-
BiometricHelper.prompt(this,
810-
getString(R.string.auth_required_title),
811-
getString(R.string.auth_required_subtitle),
812-
() -> {
813-
addToLog(getString(R.string.auth_success_disconnect));
814-
toggleService(true);
815-
});
816-
} else {
817-
if (BiometricHelper.isDeviceSecure(this)) {
818-
addToLog(getString(R.string.user_initiated_conn));
819-
toggleService(false);
820-
} else {
821-
BiometricHelper.showEnrollmentDialog(this);
822-
}
823-
}
824-
}
825-
826782
public void handleBrowseContentClick(View v) {
827783
if (!isServerAlive) {
828784
Snackbar.make(v, R.string.qr_error_no_server, Snackbar.LENGTH_LONG).show();
@@ -986,18 +942,6 @@ public void onError(String error) {
986942
}
987943
}
988944

989-
private void toggleService(boolean stop) {
990-
prefs.setEnable(!stop);
991-
savePrefs();
992-
addToLog(getString(stop ? R.string.vpn_stopping : R.string.vpn_starting));
993-
994-
if (!stop) {
995-
runNegotiationSequence();
996-
} else {
997-
updateUIColorsAndVisibility();
998-
}
999-
}
1000-
1001945
public void updateUI() {
1002946
if (usageFragment != null) {
1003947
usageFragment.updateUI();
@@ -1009,7 +953,6 @@ private void checkServerStatus() {
1009953

1010954
AppExecutors.get().io().execute(() -> {
1011955
boolean localAlive = pingUrl("http://localhost:8085/home");
1012-
isProxyDegraded = false;
1013956

1014957
updateServerAlive(localAlive);
1015958

@@ -1977,7 +1920,6 @@ public void logStackTrace(String tag, Exception e) {
19771920
"PATH=/sbin:/system/sbin:/system/bin:/system/xbin:" + workingDirectory.getAbsolutePath() + "/usr/bin"
19781921
};
19791922

1980-
19811923
// Launch the native Android shell!
19821924
terminalSession = new com.termux.terminal.TerminalSession(
19831925
hostShell,

‎controller/app/src/main/java/org/iiab/controller/Preferences.java‎

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@
1919

2020
public class Preferences {
2121
public static final String PREFS_NAME = "SocksPrefs";
22-
public static final String SOCKS_ADDR = "SocksAddr";
23-
public static final String SOCKS_UDP_ADDR = "SocksUdpAddr";
24-
public static final String SOCKS_PORT = "SocksPort";
25-
public static final String SOCKS_USER = "SocksUser";
26-
public static final String SOCKS_PASS = "SocksPass";
2722
public static final String IPV4 = "Ipv4";
2823
public static final String IPV6 = "Ipv6";
2924
public static final String GLOBAL = "Global";
3025
public static final String UDP_IN_TCP = "UdpInTcp";
3126
public static final String REMOTE_DNS = "RemoteDNS";
3227
public static final String APPS = "Apps";
33-
public static final String ENABLE = "Enable";
3428
public static final String WATCHDOG_ENABLE = "WatchdogEnable";
3529
public static final String MAINTENANCE_MODE = "MaintenanceMode";
3630

@@ -40,56 +34,6 @@ public Preferences(Context context) {
4034
prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_MULTI_PROCESS);
4135
}
4236

43-
public String getSocksAddress() {
44-
return prefs.getString(SOCKS_ADDR, "127.0.0.1");
45-
}
46-
47-
public void setSocksAddress(String addr) {
48-
SharedPreferences.Editor editor = prefs.edit();
49-
editor.putString(SOCKS_ADDR, addr);
50-
editor.commit();
51-
}
52-
53-
public String getSocksUdpAddress() {
54-
return prefs.getString(SOCKS_UDP_ADDR, "");
55-
}
56-
57-
public void setSocksUdpAddress(String addr) {
58-
SharedPreferences.Editor editor = prefs.edit();
59-
editor.putString(SOCKS_UDP_ADDR, addr);
60-
editor.commit();
61-
}
62-
63-
public int getSocksPort() {
64-
return prefs.getInt(SOCKS_PORT, 1080);
65-
}
66-
67-
public void setSocksPort(int port) {
68-
SharedPreferences.Editor editor = prefs.edit();
69-
editor.putInt(SOCKS_PORT, port);
70-
editor.commit();
71-
}
72-
73-
public String getSocksUsername() {
74-
return prefs.getString(SOCKS_USER, "");
75-
}
76-
77-
public void setSocksUsername(String user) {
78-
SharedPreferences.Editor editor = prefs.edit();
79-
editor.putString(SOCKS_USER, user);
80-
editor.commit();
81-
}
82-
83-
public String getSocksPassword() {
84-
return prefs.getString(SOCKS_PASS, "");
85-
}
86-
87-
public void setSocksPassword(String pass) {
88-
SharedPreferences.Editor editor = prefs.edit();
89-
editor.putString(SOCKS_PASS, pass);
90-
editor.commit();
91-
}
92-
9337
public String getMappedDns() {
9438
return "198.18.0.2";
9539
}
@@ -154,16 +98,6 @@ public void setApps(Set<String> apps) {
15498
editor.commit();
15599
}
156100

157-
public boolean getEnable() {
158-
return prefs.getBoolean(ENABLE, false);
159-
}
160-
161-
public void setEnable(boolean enable) {
162-
SharedPreferences.Editor editor = prefs.edit();
163-
editor.putBoolean(ENABLE, enable);
164-
editor.commit();
165-
}
166-
167101
public boolean getWatchdogEnable() {
168102
return prefs.getBoolean(WATCHDOG_ENABLE, false);
169103
}

‎controller/app/src/main/java/org/iiab/controller/ServiceReceiver.java‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ public void onReceive(Context context, Intent intent) {
2323
return;
2424
}
2525
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
26-
Preferences prefs = new Preferences(context);
27-
if (prefs.getEnable()) {
28-
// TODO(ADFA-3340): auto-start K2Go on boot. The previous
29-
// VpnService/TProxyService implementation was removed (ADFA-4552,
30-
// dead tunnel); the replacement start path will hook in here.
31-
}
26+
// TODO(ADFA-3340): auto-start K2Go on boot. The previous
27+
// VpnService/TProxyService implementation was removed (ADFA-4552) and
28+
// the "enable" pref was removed with the dead proxy (ADFA-4553); the
29+
// replacement start path will hook in here.
3230
}
3331
}
3432
}

0 commit comments

Comments
 (0)