Only register conditions receiver when needed.
1. Update the dnd receiver to listen when dashboard summary running. - remove the dnd receiver from Android manifest, and create it inside the dnd condition. - add lifecycle implementation to condition manager, so that the dnd condition can know when to register and unregister the receiver. - remove getReceiverClass() from dnd condition so that its receiver will not be disabled by the default condition handling when condition is silenced. 2. Remove all other conditions receiver from Android manifest. - the broadcast receivers for HotspotCondition, AirplaneModeCondition, CellularDataCondition from the manifest and create them inside the condition classes. - update Condition.onSilenceChanged() to register/unregister the receivers instead of enable/disable the receiver class. Change-Id: Iea6288382680df2b02884d1934b8db85daae404c Fix: 35968517 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.dashboard.conditional;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.util.Log;
|
||||
@@ -29,8 +30,14 @@ import com.android.settingslib.WirelessUtils;
|
||||
public class AirplaneModeCondition extends Condition {
|
||||
public static String TAG = "APM_Condition";
|
||||
|
||||
private final Receiver mReceiver;
|
||||
|
||||
private static final IntentFilter AIRPLANE_MODE_FILTER =
|
||||
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
|
||||
public AirplaneModeCondition(ConditionManager conditionManager) {
|
||||
super(conditionManager);
|
||||
mReceiver = new Receiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,8 +47,13 @@ public class AirplaneModeCondition extends Condition {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> getReceiverClass() {
|
||||
return Receiver.class;
|
||||
protected BroadcastReceiver getReceiver() {
|
||||
return mReceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IntentFilter getIntentFilter() {
|
||||
return AIRPLANE_MODE_FILTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user