use of android.database.ContentObserver in project android_frameworks_base by ParanoidAndroid.
the class WifiWatchdogStateMachine method registerForSettingsChanges.
/**
* Observes watchdogs secure setting changes.
*/
private void registerForSettingsChanges() {
ContentObserver contentObserver = new ContentObserver(this.getHandler()) {
@Override
public void onChange(boolean selfChange) {
sendMessage(EVENT_WATCHDOG_SETTINGS_CHANGE);
}
};
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED), false, contentObserver);
}
use of android.database.ContentObserver in project platform_frameworks_base by android.
the class KeyguardUpdateMonitor method watchForDeviceProvisioning.
private void watchForDeviceProvisioning() {
mDeviceProvisionedObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
if (mDeviceProvisioned) {
mHandler.sendEmptyMessage(MSG_DEVICE_PROVISIONED);
}
if (DEBUG)
Log.d(TAG, "DEVICE_PROVISIONED state = " + mDeviceProvisioned);
}
};
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), false, mDeviceProvisionedObserver);
// prevent a race condition between where we check the flag and where we register the
// observer by grabbing the value once again...
boolean provisioned = isDeviceProvisionedInSettingsDb();
if (provisioned != mDeviceProvisioned) {
mDeviceProvisioned = provisioned;
if (mDeviceProvisioned) {
mHandler.sendEmptyMessage(MSG_DEVICE_PROVISIONED);
}
}
}
use of android.database.ContentObserver in project platform_frameworks_base by android.
the class ContentQueryMap method setKeepUpdated.
/**
* Change whether or not the ContentQueryMap will register with the cursor's ContentProvider
* for change notifications. If you use a ContentQueryMap in an activity you should call this
* with false in onPause(), which means you need to call it with true in onResume()
* if want it to be kept updated.
* @param keepUpdated if true the ContentQueryMap should be registered with the cursor's
* ContentProvider, false otherwise
*/
public void setKeepUpdated(boolean keepUpdated) {
if (keepUpdated == mKeepUpdated)
return;
mKeepUpdated = keepUpdated;
if (!mKeepUpdated) {
mCursor.unregisterContentObserver(mContentObserver);
mContentObserver = null;
} else {
if (mHandlerForUpdateNotifications == null) {
mHandlerForUpdateNotifications = new Handler();
}
if (mContentObserver == null) {
mContentObserver = new ContentObserver(mHandlerForUpdateNotifications) {
@Override
public void onChange(boolean selfChange) {
// let it query lazily when they ask for the values.
if (countObservers() != 0) {
requery();
} else {
mDirty = true;
}
}
};
}
mCursor.registerContentObserver(mContentObserver);
// mark dirty, since it is possible the cursor's backing data had changed before we
// registered for changes
mDirty = true;
}
}
use of android.database.ContentObserver in project platform_frameworks_base by android.
the class NightDisplayService method onUserChanged.
private void onUserChanged(int userHandle) {
final ContentResolver cr = getContext().getContentResolver();
if (mCurrentUser != UserHandle.USER_NULL) {
if (mUserSetupObserver != null) {
cr.unregisterContentObserver(mUserSetupObserver);
mUserSetupObserver = null;
} else if (mBootCompleted) {
tearDown();
}
}
mCurrentUser = userHandle;
if (mCurrentUser != UserHandle.USER_NULL) {
if (!isUserSetupCompleted(cr, mCurrentUser)) {
mUserSetupObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange, Uri uri) {
if (isUserSetupCompleted(cr, mCurrentUser)) {
cr.unregisterContentObserver(this);
mUserSetupObserver = null;
if (mBootCompleted) {
setUp();
}
}
}
};
cr.registerContentObserver(Secure.getUriFor(Secure.USER_SETUP_COMPLETE), false, /* notifyForDescendents */
mUserSetupObserver, mCurrentUser);
} else if (mBootCompleted) {
setUp();
}
}
}
use of android.database.ContentObserver in project platform_frameworks_base by android.
the class BatteryService method onBootPhase.
@Override
public void onBootPhase(int phase) {
if (phase == PHASE_ACTIVITY_MANAGER_READY) {
// check our power situation now that it is safe to display the shutdown dialog.
synchronized (mLock) {
ContentObserver obs = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
synchronized (mLock) {
updateBatteryWarningLevelLocked();
}
}
};
final ContentResolver resolver = mContext.getContentResolver();
resolver.registerContentObserver(Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL), false, obs, UserHandle.USER_ALL);
updateBatteryWarningLevelLocked();
}
}
}
Aggregations