Search in sources :

Example 51 with ContentResolver

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

Example 52 with ContentResolver

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;
}
Also used : ContentValues(android.content.ContentValues) TelephonyManager(android.telephony.TelephonyManager) SQLException(android.database.SQLException) Cursor(android.database.Cursor) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver)

Example 53 with ContentResolver

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

Example 54 with ContentResolver

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);
}
Also used : TypeMappingFinder(com.pushtorefresh.storio.TypeMappingFinder) ContentResolver(android.content.ContentResolver) StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Example 55 with ContentResolver

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);
}
Also used : StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) ContentResolver(android.content.ContentResolver) StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Aggregations

ContentResolver (android.content.ContentResolver)1198 Uri (android.net.Uri)243 Cursor (android.database.Cursor)196 ContentValues (android.content.ContentValues)116 Intent (android.content.Intent)94 RemoteException (android.os.RemoteException)67 IOException (java.io.IOException)62 Context (android.content.Context)58 ArrayList (java.util.ArrayList)50 File (java.io.File)48 Resources (android.content.res.Resources)46 ComponentName (android.content.ComponentName)44 MediumTest (android.test.suitebuilder.annotation.MediumTest)37 PreferenceScreen (android.support.v7.preference.PreferenceScreen)35 Bitmap (android.graphics.Bitmap)33 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