Handle screen off in sync service

pull/157/head
M66B 6 years ago
parent 6f268c1b56
commit c842392f67

@ -1897,7 +1897,7 @@ for a list of privacy friendly email providers with advantages and disadvantages
**(113) How does biometric authentication work?**
If your device has a biometric sensor, for example a fingerprint sensor, you can enable/disable biometric authentication in the navigation (hamburger) menu of the setup screen.
When enabled FairEmail will require biometric authentication after a period of inactivity or after the screen has been turned off while FairEmail was visible.
When enabled FairEmail will require biometric authentication after a period of inactivity or after the screen has been turned off while FairEmail was running.
Activity is navigation within FairEmail, for example opening a conversation thread.
When biometric authentication is enabled only a summary notification with the number of new messages will be shown, so all message content is hidden.

@ -127,7 +127,9 @@ public class ServiceSynchronize extends LifecycleService {
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
// Removed because of Android VPN service
// builder.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
cm.registerNetworkCallback(builder.build(), networkCallback);
cm.registerNetworkCallback(builder.build(), onNetworkCallback);
registerReceiver(onScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF));
DB db = DB.getInstance(this);
@ -183,6 +185,8 @@ public class ServiceSynchronize extends LifecycleService {
});
WorkerCleanup.queue(this);
}
@Override
@ -190,8 +194,10 @@ public class ServiceSynchronize extends LifecycleService {
Log.i("Service destroy");
EntityLog.log(this, "Service destroy");
unregisterReceiver(onScreenOff);
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.unregisterNetworkCallback(networkCallback);
cm.unregisterNetworkCallback(onNetworkCallback);
Core.notifyReset(this);
@ -1265,7 +1271,7 @@ public class ServiceSynchronize extends LifecycleService {
}
}
ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
private ConnectivityManager.NetworkCallback onNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
networkState.update(ConnectionHelper.getNetworkState(ServiceSynchronize.this));
@ -1357,6 +1363,15 @@ public class ServiceSynchronize extends LifecycleService {
}
};
private BroadcastReceiver onScreenOff = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("Received " + intent);
Log.logExtras(intent);
Helper.clearAuthentication(ServiceSynchronize.this);
}
};
static void boot(final Context context) {
if (!booted) {
booted = true;

Loading…
Cancel
Save