mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-28 10:51:14 +00:00
Prevent lingering wake locks
This commit is contained in:
parent
549c9ad0dc
commit
1b8ca1cdc6
2 changed files with 13 additions and 2 deletions
|
@ -85,7 +85,7 @@
|
||||||
android:host="www.netguard.me"
|
android:host="www.netguard.me"
|
||||||
android:pathPrefix="/"
|
android:pathPrefix="/"
|
||||||
android:scheme="https" />
|
android:scheme="https" />
|
||||||
</intent-filter>
|
</intent-filter>`
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.shortcuts"
|
android:name="android.app.shortcuts"
|
||||||
|
|
|
@ -237,6 +237,14 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
return wlInstance;
|
return wlInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized private static void releaseLock(Context context) {
|
||||||
|
if (wlInstance != null) {
|
||||||
|
while (wlInstance.isHeld())
|
||||||
|
wlInstance.release();
|
||||||
|
wlInstance = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final class CommandHandler extends Handler {
|
private final class CommandHandler extends Handler {
|
||||||
public int queue = 0;
|
public int queue = 0;
|
||||||
|
|
||||||
|
@ -433,7 +441,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
|
|
||||||
// Stop service if needed
|
// Stop service if needed
|
||||||
if (!prefs.getBoolean("enabled", false) && !prefs.getBoolean("show_stats", false))
|
if (!prefs.getBoolean("enabled", false) && !prefs.getBoolean("show_stats", false))
|
||||||
stopSelf();
|
stopForeground(true);
|
||||||
|
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||||
|
@ -2402,6 +2410,9 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
logLooper.quit();
|
logLooper.quit();
|
||||||
statsLooper.quit();
|
statsLooper.quit();
|
||||||
|
|
||||||
|
commandHandler.removeMessages(MSG_SERVICE_INTENT);
|
||||||
|
releaseLock(this);
|
||||||
|
|
||||||
// Registered in command loop
|
// Registered in command loop
|
||||||
if (registeredInteractiveState) {
|
if (registeredInteractiveState) {
|
||||||
unregisterReceiver(interactiveStateReceiver);
|
unregisterReceiver(interactiveStateReceiver);
|
||||||
|
|
Loading…
Reference in a new issue