use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class ConnectivityService method handleSetNetworkPreference.
private void handleSetNetworkPreference(int preference) {
if (ConnectivityManager.isNetworkTypeValid(preference) && mNetConfigs[preference] != null && mNetConfigs[preference].isDefault()) {
if (mNetworkPreference != preference) {
final ContentResolver cr = mContext.getContentResolver();
Settings.Global.putInt(cr, Settings.Global.NETWORK_PREFERENCE, preference);
synchronized (this) {
mNetworkPreference = preference;
}
enforcePreference();
}
}
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class ConnectivityService method getConnectivityChangeDelay.
private int getConnectivityChangeDelay() {
final ContentResolver cr = mContext.getContentResolver();
/** Check system properties for the default value then use secure settings value, if any. */
int defaultDelay = SystemProperties.getInt("conn." + Settings.Global.CONNECTIVITY_CHANGE_DELAY, ConnectivityManager.CONNECTIVITY_CHANGE_DELAY_DEFAULT);
return Settings.Global.getInt(cr, Settings.Global.CONNECTIVITY_CHANGE_DELAY, defaultDelay);
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class DockObserver method handleDockStateChange.
private void handleDockStateChange() {
synchronized (mLock) {
Slog.i(TAG, "Dock state changed: " + mDockState);
// Skip the dock intent if not yet provisioned.
final ContentResolver cr = mContext.getContentResolver();
if (Settings.Global.getInt(cr, Settings.Global.DEVICE_PROVISIONED, 0) == 0) {
Slog.i(TAG, "Device not provisioned, skipping dock broadcast");
return;
}
// Pack up the values and broadcast them to everyone
Intent intent = new Intent(Intent.ACTION_DOCK_EVENT);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Intent.EXTRA_DOCK_STATE, mDockState);
// Particularly useful for flaky contact pins...
if (Settings.Global.getInt(cr, Settings.Global.DOCK_SOUNDS_ENABLED, 1) == 1) {
String whichSound = null;
if (mDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
if ((mPreviousDockState == Intent.EXTRA_DOCK_STATE_DESK) || (mPreviousDockState == Intent.EXTRA_DOCK_STATE_LE_DESK) || (mPreviousDockState == Intent.EXTRA_DOCK_STATE_HE_DESK)) {
whichSound = Settings.Global.DESK_UNDOCK_SOUND;
} else if (mPreviousDockState == Intent.EXTRA_DOCK_STATE_CAR) {
whichSound = Settings.Global.CAR_UNDOCK_SOUND;
}
} else {
if ((mDockState == Intent.EXTRA_DOCK_STATE_DESK) || (mDockState == Intent.EXTRA_DOCK_STATE_LE_DESK) || (mDockState == Intent.EXTRA_DOCK_STATE_HE_DESK)) {
whichSound = Settings.Global.DESK_DOCK_SOUND;
} else if (mDockState == Intent.EXTRA_DOCK_STATE_CAR) {
whichSound = Settings.Global.CAR_DOCK_SOUND;
}
}
if (whichSound != null) {
final String soundPath = Settings.Global.getString(cr, whichSound);
if (soundPath != null) {
final Uri soundUri = Uri.parse("file://" + soundPath);
if (soundUri != null) {
final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
if (sfx != null) {
sfx.setStreamType(AudioManager.STREAM_SYSTEM);
sfx.play();
}
}
}
}
}
// Send the dock event intent.
// There are many components in the system watching for this so as to
// adjust audio routing, screen orientation, etc.
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
// Release the wake lock that was acquired when the message was posted.
mWakeLock.release();
}
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class BatteryService method logOutlierLocked.
private void logOutlierLocked(long duration) {
ContentResolver cr = mContext.getContentResolver();
String dischargeThresholdString = Settings.Global.getString(cr, Settings.Global.BATTERY_DISCHARGE_THRESHOLD);
String durationThresholdString = Settings.Global.getString(cr, Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD);
if (dischargeThresholdString != null && durationThresholdString != null) {
try {
long durationThreshold = Long.parseLong(durationThresholdString);
int dischargeThreshold = Integer.parseInt(dischargeThresholdString);
if (duration <= durationThreshold && mDischargeStartLevel - mBatteryLevel >= dischargeThreshold) {
// If the discharge cycle is bad enough we want to know about it.
logBatteryStatsLocked();
}
if (DEBUG)
Slog.v(TAG, "duration threshold: " + durationThreshold + " discharge threshold: " + dischargeThreshold);
if (DEBUG)
Slog.v(TAG, "duration: " + duration + " discharge: " + (mDischargeStartLevel - mBatteryLevel));
} catch (NumberFormatException e) {
Slog.e(TAG, "Invalid DischargeThresholds GService string: " + durationThresholdString + " or " + dischargeThresholdString);
return;
}
}
}
use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.
the class SamplingProfilerService method registerSettingObserver.
private void registerSettingObserver(Context context) {
ContentResolver contentResolver = context.getContentResolver();
contentResolver.registerContentObserver(Settings.Global.getUriFor(Settings.Global.SAMPLING_PROFILER_MS), false, new SamplingProfilerSettingsObserver(contentResolver));
}
Aggregations