Search in sources :

Example 11 with ContentResolver

use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.

the class MediaExtractor method setDataSource.

/**
     * Sets the data source as a content Uri.
     *
     * @param context the Context to use when resolving the Uri
     * @param uri the Content URI of the data you want to extract from.
     * @param headers the headers to be sent together with the request for the data
     */
public final void setDataSource(Context context, Uri uri, Map<String, String> headers) throws IOException {
    String scheme = uri.getScheme();
    if (scheme == null || scheme.equals("file")) {
        setDataSource(uri.getPath());
        return;
    }
    AssetFileDescriptor fd = null;
    try {
        ContentResolver resolver = context.getContentResolver();
        fd = resolver.openAssetFileDescriptor(uri, "r");
        if (fd == null) {
            return;
        }
        // a full file.
        if (fd.getDeclaredLength() < 0) {
            setDataSource(fd.getFileDescriptor());
        } else {
            setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getDeclaredLength());
        }
        return;
    } catch (SecurityException ex) {
    } catch (IOException ex) {
    } finally {
        if (fd != null) {
            fd.close();
        }
    }
    setDataSource(uri.toString(), headers);
}
Also used : AssetFileDescriptor(android.content.res.AssetFileDescriptor) IOException(java.io.IOException) ContentResolver(android.content.ContentResolver)

Example 12 with ContentResolver

use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.

the class BugReportTile method updateTile.

private synchronized void updateTile() {
    mLabel = mContext.getString(R.string.quick_settings_report_bug);
    mDrawable = com.android.internal.R.drawable.stat_sys_adb;
    final ContentResolver cr = mContext.getContentResolver();
    try {
        enabled = (Settings.Secure.getInt(cr, Settings.Secure.BUGREPORT_IN_POWER_MENU) != 0);
    } catch (SettingNotFoundException e) {
    }
}
Also used : SettingNotFoundException(android.provider.Settings.SettingNotFoundException) ContentResolver(android.content.ContentResolver)

Example 13 with ContentResolver

use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.

the class QuickSettingsModel method onBugreportChanged.

// SettingsObserver callback
public void onBugreportChanged() {
    final ContentResolver cr = mContext.getContentResolver();
    boolean enabled = false;
    try {
        enabled = (Settings.Global.getInt(cr, Settings.Global.BUGREPORT_IN_POWER_MENU) != 0);
    } catch (SettingNotFoundException e) {
    }
    mBugreportState.enabled = enabled;
    mBugreportCallback.refreshView(mBugreportTile, mBugreportState);
}
Also used : SettingNotFoundException(android.provider.Settings.SettingNotFoundException) ContentResolver(android.content.ContentResolver)

Example 14 with ContentResolver

use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.

the class GPSButton method toggleState.

@Override
protected void toggleState(Context context) {
    ContentResolver resolver = context.getContentResolver();
    boolean enabled = getGpsState(context);
    Settings.Secure.setLocationProviderEnabled(resolver, LocationManager.GPS_PROVIDER, !enabled);
}
Also used : ContentResolver(android.content.ContentResolver)

Example 15 with ContentResolver

use of android.content.ContentResolver in project android_frameworks_base by ParanoidAndroid.

the class SoundButton method findCurrentState.

private void findCurrentState(Context context) {
    ensureAudioManager(context);
    ContentResolver resolver = context.getContentResolver();
    boolean vibrateWhenRinging = Settings.System.getInt(resolver, Settings.System.VIBRATE_WHEN_RINGING, 0) == 1;
    int ringerMode = mAudioManager.getRingerMode();
    Ringer ringer = new Ringer(ringerMode, vibrateWhenRinging);
    for (int i = 0; i < mRingers.length; i++) {
        if (mRingers[i].equals(ringer)) {
            mRingersIndex = i;
            break;
        }
    }
}
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