use of android.database.ContentObserver in project android_frameworks_base by ParanoidAndroid.
the class LocationManagerService method systemReady.
public void systemReady() {
synchronized (mLock) {
if (D)
Log.d(TAG, "systemReady()");
// fetch package manager
mPackageManager = mContext.getPackageManager();
// fetch power manager
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
// prepare worker thread
mHandlerThread = new HandlerThread(THREAD_NAME, Process.THREAD_PRIORITY_BACKGROUND);
mHandlerThread.start();
mLocationHandler = new LocationWorkerHandler(mHandlerThread.getLooper());
// prepare mLocationHandler's dependents
mLocationFudger = new LocationFudger(mContext, mLocationHandler);
mBlacklist = new LocationBlacklist(mContext, mLocationHandler);
mBlacklist.init();
mGeofenceManager = new GeofenceManager(mContext, mBlacklist);
// Monitor for app ops mode changes.
AppOpsManager.Callback callback = new AppOpsManager.Callback() {
public void opChanged(int op, String packageName) {
synchronized (mLock) {
applyAllProviderRequirementsLocked();
}
}
};
mAppOps.startWatchingMode(AppOpsManager.OP_COARSE_LOCATION, null, callback);
// prepare providers
loadProvidersLocked();
updateProvidersLocked();
}
// listen for settings changes
mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCATION_PROVIDERS_ALLOWED), true, new ContentObserver(mLocationHandler) {
@Override
public void onChange(boolean selfChange) {
synchronized (mLock) {
updateProvidersLocked();
}
}
}, UserHandle.USER_ALL);
mPackageMonitor.register(mContext, mLocationHandler.getLooper(), true);
// listen for user change
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
mContext.registerReceiverAsUser(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
switchUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
}
}
}, UserHandle.ALL, intentFilter, null, mLocationHandler);
}
use of android.database.ContentObserver in project android_frameworks_base by ParanoidAndroid.
the class WifiService method registerForScanModeChange.
/**
* Observes settings changes to scan always mode.
*/
private void registerForScanModeChange() {
ContentObserver contentObserver = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
mSettingsStore.handleWifiScanAlwaysAvailableToggled();
mWifiController.sendMessage(CMD_SCAN_ALWAYS_MODE_CHANGED);
}
};
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE), false, contentObserver);
}
use of android.database.ContentObserver in project android_frameworks_base by ParanoidAndroid.
the class WifiController method registerForStayAwakeModeChange.
/**
* Observes settings changes to scan always mode.
*/
private void registerForStayAwakeModeChange(Handler handler) {
ContentObserver contentObserver = new ContentObserver(handler) {
@Override
public void onChange(boolean selfChange) {
readStayAwakeConditions();
}
};
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.STAY_ON_WHILE_PLUGGED_IN), false, contentObserver);
}
use of android.database.ContentObserver in project android_frameworks_base by ParanoidAndroid.
the class WifiController method registerForWifiSleepPolicyChange.
/**
* Observes changes to wifi sleep policy
*/
private void registerForWifiSleepPolicyChange(Handler handler) {
ContentObserver contentObserver = new ContentObserver(handler) {
@Override
public void onChange(boolean selfChange) {
readWifiSleepPolicy();
}
};
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.WIFI_SLEEP_POLICY), false, contentObserver);
}
use of android.database.ContentObserver in project android_frameworks_base by ParanoidAndroid.
the class WifiWatchdogStateMachine method registerForWatchdogToggle.
/**
* Observes the watchdog on/off setting, and takes action when changed.
*/
private void registerForWatchdogToggle() {
ContentObserver contentObserver = new ContentObserver(this.getHandler()) {
@Override
public void onChange(boolean selfChange) {
sendMessage(EVENT_WATCHDOG_TOGGLED);
}
};
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.WIFI_WATCHDOG_ON), false, contentObserver);
}
Aggregations