Make sure we've finished loading settings before processing any reloads

- Effectively throttles case where many reloads are sent in rapid
succession.

- Simplify Handler state machine by making the state explicit instead
of implicit in the sequence of messages.

- To guard against cascading timeouts due to RAM pressure or other
systemic issues, only start additional services if there is at most one
timed out setting at a time.

- Add some log messages

- Fix b/10487253

Change-Id: Ibe21533f7b644bbadf5b56b61ca0e28b49192470
This commit is contained in:
Tom O'Neill
2013-08-29 10:48:13 -07:00
parent 6760f92321
commit f06dc32163
2 changed files with 91 additions and 41 deletions

View File

@@ -22,6 +22,7 @@ import android.database.Cursor;
import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
import com.android.settings.SettingsPreferenceFragment;
import java.util.Observable;
@@ -32,6 +33,7 @@ import java.util.Observer;
* settings.
*/
public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
private static final String TAG = "LocationSettingsBase";
private ContentQueryMap mContentQueryMap;
private Observer mSettingsObserver;
@@ -82,6 +84,9 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
if (isRestricted()) {
// Location toggling disabled by user restriction. Read the current location mode to
// update the location master switch.
if (Log.isLoggable(TAG, Log.INFO)) {
Log.i(TAG, "Restricted user, not setting location mode");
}
mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF);
onModeChanged(mode, true);