mirror of https://github.com/M66B/FairEmail.git
Listen for suspend events
This commit is contained in:
parent
51a1728edb
commit
a96171665a
|
@ -199,6 +199,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
registerReceiver(dataSaverChanged, new IntentFilter(ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
IntentFilter suspend = new IntentFilter();
|
||||
suspend.addAction(Intent.ACTION_MY_PACKAGE_SUSPENDED);
|
||||
suspend.addAction(Intent.ACTION_MY_PACKAGE_UNSUSPENDED);
|
||||
registerReceiver(suspendChanged, suspend);
|
||||
}
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
DB db = DB.getInstance(this);
|
||||
|
@ -859,6 +866,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
prefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
unregisterReceiver(suspendChanged);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
unregisterReceiver(dataSaverChanged);
|
||||
|
||||
|
@ -2634,6 +2644,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
};
|
||||
|
||||
private final BroadcastReceiver suspendChanged = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
EntityLog.log(context, intent.getAction() + " " +
|
||||
TextUtils.join(", ", Log.getExtras(intent.getExtras())));
|
||||
}
|
||||
};
|
||||
|
||||
private void updateNetworkState(final Network network, final String reason) {
|
||||
getMainHandler().post(new Runnable() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue