Search in sources :

Example 21 with ContentResolver

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();
        }
    }
}
Also used : ContentResolver(android.content.ContentResolver)

Example 22 with ContentResolver

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);
}
Also used : ContentResolver(android.content.ContentResolver)

Example 23 with ContentResolver

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();
    }
}
Also used : Ringtone(android.media.Ringtone) Intent(android.content.Intent) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver)

Example 24 with ContentResolver

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;
        }
    }
}
Also used : ContentResolver(android.content.ContentResolver)

Example 25 with ContentResolver

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));
}
Also used : ContentResolver(android.content.ContentResolver)

Aggregations

ContentResolver (android.content.ContentResolver)1121 Uri (android.net.Uri)236 Cursor (android.database.Cursor)190 ContentValues (android.content.ContentValues)112 Intent (android.content.Intent)90 RemoteException (android.os.RemoteException)67 IOException (java.io.IOException)59 Context (android.content.Context)52 File (java.io.File)46 ArrayList (java.util.ArrayList)46 Resources (android.content.res.Resources)45 ComponentName (android.content.ComponentName)44 MediumTest (android.test.suitebuilder.annotation.MediumTest)37 PreferenceScreen (android.support.v7.preference.PreferenceScreen)33 Bitmap (android.graphics.Bitmap)31 ContentObserver (android.database.ContentObserver)28 FileNotFoundException (java.io.FileNotFoundException)28 PendingIntent (android.app.PendingIntent)25 MockContentResolver (android.test.mock.MockContentResolver)25 AssetFileDescriptor (android.content.res.AssetFileDescriptor)24