mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-27 18:30:09 +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:pathPrefix="/"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</intent-filter>`
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
|
|
|
@ -237,6 +237,14 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
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 {
|
||||
public int queue = 0;
|
||||
|
||||
|
@ -433,7 +441,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
|
||||
// Stop service if needed
|
||||
if (!prefs.getBoolean("enabled", false) && !prefs.getBoolean("show_stats", false))
|
||||
stopSelf();
|
||||
stopForeground(true);
|
||||
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
|
@ -2402,6 +2410,9 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
logLooper.quit();
|
||||
statsLooper.quit();
|
||||
|
||||
commandHandler.removeMessages(MSG_SERVICE_INTENT);
|
||||
releaseLock(this);
|
||||
|
||||
// Registered in command loop
|
||||
if (registeredInteractiveState) {
|
||||
unregisterReceiver(interactiveStateReceiver);
|
||||
|
|
Loading…
Reference in a new issue