use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class ActivityManagerService method getStickiesLocked.
// =========================================================
// BROADCASTS
// =========================================================
private final List getStickiesLocked(String action, IntentFilter filter, List cur, int userId) {
final ContentResolver resolver = mContext.getContentResolver();
HashMap<String, ArrayList<Intent>> stickies = mStickyBroadcasts.get(userId);
if (stickies == null) {
return cur;
}
final ArrayList<Intent> list = stickies.get(action);
if (list == null) {
return cur;
}
int N = list.size();
for (int i = 0; i < N; i++) {
Intent intent = list.get(i);
if (filter.match(resolver, intent, true, TAG) >= 0) {
if (cur == null) {
cur = new ArrayList<Intent>();
}
cur.add(intent);
}
}
return cur;
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class WifiSettingsStore method testAndClearWifiSavedState.
/* After a reboot, we restore wi-fi to be on if it was turned off temporarily for tethering.
* The settings app tracks the saved state, but the framework has to check it at boot to
* make sure the wi-fi is turned on in case it was turned off for the purpose of tethering.
*
* Note that this is not part of the regular WIFI_ON setting because this only needs to
* be controlled through the settings app and not the Wi-Fi public API.
*/
private boolean testAndClearWifiSavedState() {
final ContentResolver cr = mContext.getContentResolver();
int wifiSavedState = 0;
try {
wifiSavedState = Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE);
if (wifiSavedState == 1)
Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0);
} catch (Settings.SettingNotFoundException e) {
;
}
return (wifiSavedState == 1);
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class PowerManagerService method systemReady.
public void systemReady(TwilightService twilight, DreamManagerService dreamManager) {
synchronized (mLock) {
mSystemReady = true;
mDreamManager = dreamManager;
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mScreenBrightnessSettingMinimum = pm.getMinimumScreenBrightnessSetting();
mScreenBrightnessSettingMaximum = pm.getMaximumScreenBrightnessSetting();
mScreenBrightnessSettingDefault = pm.getDefaultScreenBrightnessSetting();
SensorManager sensorManager = new SystemSensorManager(mContext, mHandler.getLooper());
// The notifier runs on the system server's main looper so as not to interfere
// with the animations and other critical functions of the power manager.
mNotifier = new Notifier(Looper.getMainLooper(), mContext, mBatteryStats, createSuspendBlockerLocked("PowerManagerService.Broadcasts"), mScreenOnBlocker, mPolicy);
// The display power controller runs on the power manager service's
// own handler thread to ensure timely operation.
mDisplayPowerController = new DisplayPowerController(mHandler.getLooper(), mContext, mNotifier, mLightsService, twilight, sensorManager, mDisplayManagerService, mDisplayBlanker, mDisplayPowerControllerCallbacks, mHandler);
mWirelessChargerDetector = new WirelessChargerDetector(sensorManager, createSuspendBlockerLocked("PowerManagerService.WirelessChargerDetector"));
mSettingsObserver = new SettingsObserver(mHandler);
mAttentionLight = mLightsService.getLight(LightsService.LIGHT_ID_ATTENTION);
// Register for broadcasts from other components of the system.
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
mContext.registerReceiver(new BatteryReceiver(), filter, null, mHandler);
filter = new IntentFilter();
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
mContext.registerReceiver(new BootCompletedReceiver(), filter, null, mHandler);
filter = new IntentFilter();
filter.addAction(Intent.ACTION_DREAMING_STARTED);
filter.addAction(Intent.ACTION_DREAMING_STOPPED);
mContext.registerReceiver(new DreamReceiver(), filter, null, mHandler);
filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
mContext.registerReceiver(new UserSwitchedReceiver(), filter, null, mHandler);
filter = new IntentFilter();
filter.addAction(Intent.ACTION_DOCK_EVENT);
mContext.registerReceiver(new DockReceiver(), filter, null, mHandler);
// Register for settings changes.
final ContentResolver resolver = mContext.getContentResolver();
resolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.SCREENSAVER_ENABLED), false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP), false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK), false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.SCREEN_OFF_TIMEOUT), false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.Global.getUriFor(Settings.Global.STAY_ON_WHILE_PLUGGED_IN), false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS), false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE), false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.AUTO_BRIGHTNESS_RESPONSIVENESS), false, mSettingsObserver, UserHandle.USER_ALL);
// Go.
readConfigurationLocked();
updateSettingsLocked();
mDirty |= DIRTY_BATTERY_STATE;
updatePowerStateLocked();
}
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class DropBoxTest method tearDown.
public void tearDown() throws Exception {
ContentResolver cr = getContext().getContentResolver();
Settings.Global.putString(cr, Settings.Global.DROPBOX_AGE_SECONDS, "");
Settings.Global.putString(cr, Settings.Global.DROPBOX_MAX_FILES, "");
Settings.Global.putString(cr, Settings.Global.DROPBOX_QUOTA_KB, "");
Settings.Global.putString(cr, Settings.Global.DROPBOX_TAG_PREFIX + "DropBoxTest", "");
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class DropBoxTest method testFileCountLimits.
public void testFileCountLimits() throws Exception {
File dir = getEmptyDir("testFileCountLimits");
DropBoxManagerService service = new DropBoxManagerService(getContext(), dir);
DropBoxManager dropbox = new DropBoxManager(service);
dropbox.addText("DropBoxTest", "TEST0");
dropbox.addText("DropBoxTest", "TEST1");
dropbox.addText("DropBoxTest", "TEST2");
dropbox.addText("DropBoxTest", "TEST3");
dropbox.addText("DropBoxTest", "TEST4");
dropbox.addText("DropBoxTest", "TEST5");
// Verify 6 files added
DropBoxManager.Entry e0 = dropbox.getNextEntry(null, 0);
DropBoxManager.Entry e1 = dropbox.getNextEntry(null, e0.getTimeMillis());
DropBoxManager.Entry e2 = dropbox.getNextEntry(null, e1.getTimeMillis());
DropBoxManager.Entry e3 = dropbox.getNextEntry(null, e2.getTimeMillis());
DropBoxManager.Entry e4 = dropbox.getNextEntry(null, e3.getTimeMillis());
DropBoxManager.Entry e5 = dropbox.getNextEntry(null, e4.getTimeMillis());
assertTrue(null == dropbox.getNextEntry(null, e5.getTimeMillis()));
assertEquals("TEST0", e0.getText(80));
assertEquals("TEST5", e5.getText(80));
e0.close();
e1.close();
e2.close();
e3.close();
e4.close();
e5.close();
// Limit to 3 files and add one more entry
ContentResolver cr = getContext().getContentResolver();
Settings.Global.putString(cr, Settings.Global.DROPBOX_MAX_FILES, "3");
dropbox.addText("DropBoxTest", "TEST6");
// Verify only 3 files left
DropBoxManager.Entry f0 = dropbox.getNextEntry(null, 0);
DropBoxManager.Entry f1 = dropbox.getNextEntry(null, f0.getTimeMillis());
DropBoxManager.Entry f2 = dropbox.getNextEntry(null, f1.getTimeMillis());
assertTrue(null == dropbox.getNextEntry(null, f2.getTimeMillis()));
assertEquals("TEST4", f0.getText(80));
assertEquals("TEST5", f1.getText(80));
assertEquals("TEST6", f2.getText(80));
f0.close();
f1.close();
f2.close();
}
Aggregations