use of android.content.ContentResolver in project platform_frameworks_base by android.
the class HdmiControlService method registerContentObserver.
private void registerContentObserver() {
ContentResolver resolver = getContext().getContentResolver();
String[] settings = new String[] { Global.HDMI_CONTROL_ENABLED, Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, Global.MHL_INPUT_SWITCHING_ENABLED, Global.MHL_POWER_CHARGE_ENABLED };
for (String s : settings) {
resolver.registerContentObserver(Global.getUriFor(s), false, mSettingsObserver, UserHandle.USER_ALL);
}
}
use of android.content.ContentResolver in project android-sms-relay by nyaruka.
the class RelayService method createAPN.
public int createAPN(String name, String apnAddr) {
int id = -1;
TelephonyManager tele = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String mcc = tele.getSimOperator().substring(0, 3);
String mnc = tele.getSimOperator().substring(3);
ContentResolver resolver = this.getContentResolver();
ContentValues values = new ContentValues();
values.put("name", name);
values.put("apn", apnAddr);
values.put("mcc", mcc);
values.put("mnc", mnc);
values.put("numeric", tele.getSimOperator());
Cursor cursor = null;
try {
Uri newAPN = resolver.insert(APN_TABLE_URI, values);
if (newAPN != null) {
cursor = resolver.query(newAPN, null, null, null, null);
Log.d(TAG, "New APN added! Yeee.");
// Obtain the apn id
int idindex = cursor.getColumnIndex("_id");
cursor.moveToFirst();
id = cursor.getShort(idindex);
}
} catch (SQLException e) {
Log.d(TAG, e.getMessage());
} finally {
if (cursor != null)
cursor.close();
}
return id;
}
use of android.content.ContentResolver in project android-sms-relay by nyaruka.
the class RelayService method setDefaultAPN.
public boolean setDefaultAPN(int id) {
boolean res = false;
ContentResolver resolver = this.getContentResolver();
ContentValues values = new ContentValues();
values.put("apn_id", id);
try {
resolver.update(PREFERRED_APN_URI, values, null, null);
Cursor cursor = resolver.query(PREFERRED_APN_URI, new String[] { "name", "apn" }, "_id=" + id, null, null);
if (cursor != null) {
res = true;
cursor.close();
}
} catch (SQLException e) {
Log.d(TAG, e.getMessage());
}
return res;
}
use of android.content.ContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method shouldUseSpecifiedTypeMappingFinder.
@Test
public void shouldUseSpecifiedTypeMappingFinder() throws NoSuchFieldException, IllegalAccessException {
TypeMappingFinder typeMappingFinder = mock(TypeMappingFinder.class);
DefaultStorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).typeMappingFinder(typeMappingFinder).build();
assertThat(getTypeMappingFinder(storIOContentResolver)).isEqualTo(typeMappingFinder);
}
use of android.content.ContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method shouldReturnSameContentResolver.
@Test
public void shouldReturnSameContentResolver() {
ContentResolver contentResolver = mock(ContentResolver.class);
StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(contentResolver).build();
assertThat(storIOContentResolver.lowLevel().contentResolver()).isSameAs(contentResolver);
}
Aggregations