Repository navigation
Test: WG keepalive off on relay POC #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import android.os.Handler; | ||
| import android.os.IBinder; | ||
| import android.os.Parcel; | ||
| import android.os.PowerManager; | ||
| import android.util.Log; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
|
|
@@ -61,6 +62,7 @@ public class VPNService extends android.net.VpnService { | |
| private NetworkSwitchNotifier networkSwitchNotifier; | ||
| private android.content.BroadcastReceiver stopEngineReceiver; | ||
| private android.content.BroadcastReceiver mdmPolicyReceiver; | ||
| private android.content.BroadcastReceiver devicePowerReceiver; | ||
|
|
||
| @Override | ||
| public void onCreate() { | ||
|
|
@@ -163,6 +165,23 @@ public void onReceive(Context context, Intent intent) { | |
| new android.content.IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED), | ||
| Context.RECEIVER_NOT_EXPORTED | ||
| ); | ||
|
|
||
| devicePowerReceiver = new android.content.BroadcastReceiver() { | ||
| @Override | ||
| public void onReceive(Context context, Intent intent) { | ||
| onDevicePowerEvent(intent.getAction()); | ||
| } | ||
| }; | ||
| android.content.IntentFilter powerFilter = new android.content.IntentFilter(); | ||
| powerFilter.addAction(Intent.ACTION_SCREEN_OFF); | ||
| powerFilter.addAction(Intent.ACTION_SCREEN_ON); | ||
| powerFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED); | ||
| androidx.core.content.ContextCompat.registerReceiver( | ||
| this, | ||
| devicePowerReceiver, | ||
| powerFilter, | ||
| Context.RECEIVER_NOT_EXPORTED | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -199,6 +218,18 @@ private void onManagedConfigurationChanged() { | |
| engineRunner.restart(); | ||
| } | ||
|
|
||
| private void onDevicePowerEvent(String action) { | ||
| if (Intent.ACTION_SCREEN_OFF.equals(action)) { | ||
| Log.d(LOGTAG, "Device sleep: screen off"); | ||
| } else if (Intent.ACTION_SCREEN_ON.equals(action)) { | ||
| Log.d(LOGTAG, "Device wake: screen on"); | ||
| } else if (PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED.equals(action)) { | ||
| PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); | ||
| boolean idle = powerManager != null && powerManager.isDeviceIdleMode(); | ||
| Log.d(LOGTAG, idle ? "Device sleep: doze entered" : "Device wake: doze exited"); | ||
|
Comment on lines
+226
to
+229
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public int onStartCommand(@Nullable final Intent intent, final int flags, final int startId) { | ||
| Log.d(LOGTAG, "onStartCommand"); | ||
|
|
@@ -266,6 +297,14 @@ public void onDestroy() { | |
| } | ||
| } | ||
|
|
||
| if (devicePowerReceiver != null) { | ||
| try { | ||
| unregisterReceiver(devicePowerReceiver); | ||
| } catch (IllegalArgumentException e) { | ||
| Log.w(LOGTAG, "Device power receiver not registered", e); | ||
| } | ||
| } | ||
|
|
||
| networkAvailabilityListener.unsubscribe(); | ||
| networkChangeDetector.unsubscribe(); | ||
| networkChangeDetector.unregisterNetworkCallback(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: netbirdio/android-client
Length of output: 2186
Script executed:
Repository: netbirdio/android-client
Length of output: 24210
Web query:
Android Intent ACTION_SCREEN_OFF ACTION_SCREEN_ON PowerManager ACTION_DEVICE_IDLE_MODE_CHANGED sticky broadcasts registerReceiver initial state documentationResult:
Script executed:
Repository: netbirdio/android-client
Length of output: 45472
Web query:
Android AOSP DeviceIdleController ACTION_DEVICE_IDLE_MODE_CHANGED sendBroadcastAsUser not sticky PowerManagerService ACTION_SCREEN_OFF sendOrderedBroadcast non sticky sourceResult:
Script executed:
Repository: netbirdio/android-client
Length of output: 5666
Web query:
site:android.googlesource.com platform frameworks base Notifier.java sendOrderedBroadcastAsUser mScreenOffIntent ACTION_SCREEN_OFF non sticky AndroidResult:
Script executed:
Repository: netbirdio/android-client
Length of output: 9478
Web query:
netbird Android debug bundle logcat logs collected Go debug bundle client AndroidResult:
Script executed:
Repository: netbirdio/android-client
Length of output: 6606
Record the initial power state.
If the service starts while already non-interactive and idle, the trace may contain neither state before diagnostics are collected. Log both states at registration, and include the
servicetag when collecting the relay trace.