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:
@@ -21,6 +21,9 @@ import android.os.PersistableBundle;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
|
||||
import com.android.settings.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settings.core.lifecycle.events.OnPause;
|
||||
import com.android.settings.core.lifecycle.events.OnResume;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
@@ -34,7 +37,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ConditionManager {
|
||||
public class ConditionManager implements LifecycleObserver, OnResume, OnPause {
|
||||
|
||||
private static final String TAG = "ConditionManager";
|
||||
|
||||
@@ -228,6 +231,20 @@ public class ConditionManager {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
for (int i = 0, size = mConditions.size(); i < size; i++) {
|
||||
mConditions.get(i).onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
for (int i = 0, size = mConditions.size(); i < size; i++) {
|
||||
mConditions.get(i).onPause();
|
||||
}
|
||||
}
|
||||
|
||||
private class ConditionLoader extends AsyncTask<Void, Void, ArrayList<Condition>> {
|
||||
@Override
|
||||
protected ArrayList<Condition> doInBackground(Void... params) {
|
||||
|
Reference in New Issue
Block a user