Search in sources :

Example 91 with ContentResolver

use of android.content.ContentResolver in project platform_frameworks_base by android.

the class PhoneWindowManager method updateSettings.

public void updateSettings() {
    ContentResolver resolver = mContext.getContentResolver();
    boolean updateRotation = false;
    synchronized (mLock) {
        mEndcallBehavior = Settings.System.getIntForUser(resolver, Settings.System.END_BUTTON_BEHAVIOR, Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, UserHandle.USER_CURRENT);
        mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, UserHandle.USER_CURRENT);
        mIncallBackBehavior = Settings.Secure.getIntForUser(resolver, Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR, Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT, UserHandle.USER_CURRENT);
        // Configure wake gesture.
        boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver, Settings.Secure.WAKE_GESTURE_ENABLED, 0, UserHandle.USER_CURRENT) != 0;
        if (mWakeGestureEnabledSetting != wakeGestureEnabledSetting) {
            mWakeGestureEnabledSetting = wakeGestureEnabledSetting;
            updateWakeGestureListenerLp();
        }
        // Configure rotation lock.
        int userRotation = Settings.System.getIntForUser(resolver, Settings.System.USER_ROTATION, Surface.ROTATION_0, UserHandle.USER_CURRENT);
        if (mUserRotation != userRotation) {
            mUserRotation = userRotation;
            updateRotation = true;
        }
        int userRotationMode = Settings.System.getIntForUser(resolver, Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? WindowManagerPolicy.USER_ROTATION_FREE : WindowManagerPolicy.USER_ROTATION_LOCKED;
        if (mUserRotationMode != userRotationMode) {
            mUserRotationMode = userRotationMode;
            updateRotation = true;
            updateOrientationListenerLp();
        }
        if (mSystemReady) {
            int pointerLocation = Settings.System.getIntForUser(resolver, Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT);
            if (mPointerLocationMode != pointerLocation) {
                mPointerLocationMode = pointerLocation;
                mHandler.sendEmptyMessage(pointerLocation != 0 ? MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION);
            }
        }
        // use screen off timeout setting as the timeout for the lockscreen
        mLockScreenTimeout = Settings.System.getIntForUser(resolver, Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT);
        String imId = Settings.Secure.getStringForUser(resolver, Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT);
        boolean hasSoftInput = imId != null && imId.length() > 0;
        if (mHasSoftInput != hasSoftInput) {
            mHasSoftInput = hasSoftInput;
            updateRotation = true;
        }
        if (mImmersiveModeConfirmation != null) {
            mImmersiveModeConfirmation.loadSetting(mCurrentUserId);
        }
    }
    synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
        PolicyControl.reloadFromSetting(mContext);
    }
    if (updateRotation) {
        updateRotation(true);
    }
}
Also used : ContentResolver(android.content.ContentResolver)

Example 92 with ContentResolver

use of android.content.ContentResolver in project platform_frameworks_base by android.

the class EnabledComponentsObserver method loadComponentNamesFromSetting.

private ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, int userId) {
    final ContentResolver cr = mContext.getContentResolver();
    String settingValue = Settings.Secure.getStringForUser(cr, settingName, userId);
    if (TextUtils.isEmpty(settingValue))
        return new ArraySet<>();
    String[] restored = settingValue.split(ENABLED_SERVICES_SEPARATOR);
    ArraySet<ComponentName> result = new ArraySet<>(restored.length);
    for (int i = 0; i < restored.length; i++) {
        ComponentName value = ComponentName.unflattenFromString(restored[i]);
        if (null != value) {
            result.add(value);
        }
    }
    return result;
}
Also used : ArraySet(android.util.ArraySet) ComponentName(android.content.ComponentName) ContentResolver(android.content.ContentResolver)

Example 93 with ContentResolver

use of android.content.ContentResolver in project platform_frameworks_base by android.

the class VrManagerService method revokeNotificationListenerAccess.

private void revokeNotificationListenerAccess(String pkg, int userId) {
    ContentResolver resolver = mContext.getContentResolver();
    ArraySet<String> current = getNotificationListeners(resolver, userId);
    ArrayList<String> toRemove = new ArrayList<>();
    for (String c : current) {
        ComponentName component = ComponentName.unflattenFromString(c);
        if (component != null && component.getPackageName().equals(pkg)) {
            toRemove.add(c);
        }
    }
    current.removeAll(toRemove);
    String flatSettings = formatSettings(current);
    Settings.Secure.putStringForUser(resolver, Settings.Secure.ENABLED_NOTIFICATION_LISTENERS, flatSettings, userId);
}
Also used : ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) ContentResolver(android.content.ContentResolver)

Example 94 with ContentResolver

use of android.content.ContentResolver in project platform_frameworks_base by android.

the class ApnDbInstallReceiver method postInstall.

@Override
protected void postInstall(Context context, Intent intent) {
    ContentResolver resolver = context.getContentResolver();
    resolver.delete(UPDATE_APN_DB, null, null);
}
Also used : ContentResolver(android.content.ContentResolver)

Example 95 with ContentResolver

use of android.content.ContentResolver in project platform_frameworks_base by android.

the class DropBoxTest method testAgeLimits.

public void testAgeLimits() throws Exception {
    File dir = getEmptyDir("testAgeLimits");
    int blockSize = new StatFs(dir.getPath()).getBlockSize();
    // Limit storage to 10 blocks with an expiration of 1 second
    int kb = blockSize * 10 / 1024;
    ContentResolver cr = getContext().getContentResolver();
    Settings.Global.putString(cr, Settings.Global.DROPBOX_AGE_SECONDS, "1");
    Settings.Global.putString(cr, Settings.Global.DROPBOX_QUOTA_KB, Integer.toString(kb));
    // Write one normal entry and another so big that it is instantly tombstoned
    long before = System.currentTimeMillis();
    DropBoxManagerService service = new DropBoxManagerService(getContext(), dir);
    DropBoxManager dropbox = new DropBoxManager(getContext(), service.getServiceStub());
    dropbox.addText("DropBoxTest", "TEST");
    addRandomEntry(dropbox, "DropBoxTest", blockSize * 20);
    // Verify that things are as expected
    DropBoxManager.Entry e0 = dropbox.getNextEntry(null, before);
    DropBoxManager.Entry e1 = dropbox.getNextEntry(null, e0.getTimeMillis());
    assertTrue(null == dropbox.getNextEntry(null, e1.getTimeMillis()));
    assertEquals("TEST", e0.getText(80));
    assertEquals(null, e1.getText(80));
    assertEquals(-1, getEntrySize(e1));
    e0.close();
    e1.close();
    // Wait a second and write another entry -- old ones should be expunged
    Thread.sleep(2000);
    dropbox.addText("DropBoxTest", "TEST1");
    e0 = dropbox.getNextEntry(null, before);
    assertTrue(null == dropbox.getNextEntry(null, e0.getTimeMillis()));
    assertEquals("TEST1", e0.getText(80));
    e0.close();
}
Also used : DropBoxManager(android.os.DropBoxManager) StatFs(android.os.StatFs) DropBoxManagerService(com.android.server.DropBoxManagerService) File(java.io.File) ContentResolver(android.content.ContentResolver)

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