Broadcasting a message for mode changing

- Fix b/10974059

Change-Id: I219ea35e65a36af9f041a487dd8039bb5e2f048b
This commit is contained in:
Lifu Tang
2013-10-08 02:24:17 -07:00
parent 1955bf1bb3
commit 1673fbc029
2 changed files with 18 additions and 7 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings.location;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
@@ -35,8 +36,14 @@ import com.android.settings.SettingsPreferenceFragment;
public abstract class LocationSettingsBase extends SettingsPreferenceFragment
implements LoaderCallbacks<Cursor> {
private static final String TAG = "LocationSettingsBase";
/** Broadcast intent action when the location mode is about to change. */
private static final String MODE_CHANGING_ACTION =
"com.android.settings.location.MODE_CHANGING";
private static final String CURRENT_MODE_KEY = "CURRENT_MODE";
private static final String NEW_MODE_KEY = "NEW_MODE";
private static final int LOADER_ID_LOCATION_MODE = 1;
private int mCurrentMode;
/**
* Whether the fragment is actively running.
@@ -83,6 +90,10 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment
}
return;
}
Intent intent = new Intent(MODE_CHANGING_ACTION);
intent.putExtra(CURRENT_MODE_KEY, mCurrentMode);
intent.putExtra(NEW_MODE_KEY, mode);
getActivity().sendBroadcast(intent);
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCATION_MODE, mode);
refreshLocationMode();
}
@@ -91,6 +102,7 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment
if (mActive) {
int mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF);
mCurrentMode = mode;
onModeChanged(mode, isRestricted());
}
}