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);
}
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) {
}
}
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);
}
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);
}
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;
}
}
}
Aggregations