Search in sources :

Example 16 with ContentResolver

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

the class EnableAccessibilityController method enableAccessibility.

private void enableAccessibility() {
    List<AccessibilityServiceInfo> services = getInstalledSpeakingAccessibilityServices(mContext);
    if (services.isEmpty()) {
        return;
    }
    boolean keyguardLocked = false;
    try {
        keyguardLocked = mWindowManager.isKeyguardLocked();
    } catch (RemoteException re) {
    /* ignore */
    }
    final boolean hasMoreThanOneUser = mUserManager.getUsers().size() > 1;
    AccessibilityServiceInfo service = services.get(0);
    boolean enableTouchExploration = (service.flags & AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE) != 0;
    // Try to find a service supporting explore by touch.
    if (!enableTouchExploration) {
        final int serviceCount = services.size();
        for (int i = 1; i < serviceCount; i++) {
            AccessibilityServiceInfo candidate = services.get(i);
            if ((candidate.flags & AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE) != 0) {
                enableTouchExploration = true;
                service = candidate;
                break;
            }
        }
    }
    ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo;
    ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
    if (!keyguardLocked || !hasMoreThanOneUser) {
        final int userId = ActivityManager.getCurrentUser();
        String enabledServiceString = componentName.flattenToString();
        ContentResolver resolver = mContext.getContentResolver();
        // Enable one speaking accessibility service.
        Settings.Secure.putStringForUser(resolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, enabledServiceString, userId);
        // Allow the services we just enabled to toggle touch exploration.
        Settings.Secure.putStringForUser(resolver, Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, enabledServiceString, userId);
        // Enable touch exploration.
        if (enableTouchExploration) {
            Settings.Secure.putIntForUser(resolver, Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1, userId);
        }
        // Enable accessibility script injection (AndroidVox) for web content.
        Settings.Secure.putIntForUser(resolver, Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, 1, userId);
        // Turn on accessibility mode last.
        Settings.Secure.putIntForUser(resolver, Settings.Secure.ACCESSIBILITY_ENABLED, 1, userId);
    } else if (keyguardLocked) {
        try {
            mAccessibilityManager.temporaryEnableAccessibilityStateUntilKeyguardRemoved(componentName, enableTouchExploration);
        } catch (RemoteException re) {
        /* ignore */
        }
    }
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) ContentResolver(android.content.ContentResolver)

Example 17 with ContentResolver

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

the class KeyguardViewMediator method playSounds.

private void playSounds(boolean locked) {
    if (mSuppressNextLockSound) {
        mSuppressNextLockSound = false;
        return;
    }
    final ContentResolver cr = mContext.getContentResolver();
    if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) {
        final int whichSound = locked ? mLockSoundId : mUnlockSoundId;
        mLockSounds.stop(mLockSoundStreamId);
        // Init mAudioManager
        if (mAudioManager == null) {
            mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
            if (mAudioManager == null)
                return;
            mMasterStreamType = mAudioManager.getMasterStreamType();
        }
        // If the stream is muted, don't play the sound
        if (mAudioManager.isStreamMute(mMasterStreamType))
            return;
        mLockSoundStreamId = mLockSounds.play(whichSound, mLockSoundVolume, mLockSoundVolume, 1, /*priortiy*/
        0, /*loop*/
        1.0f);
    }
}
Also used : ContentResolver(android.content.ContentResolver)

Example 18 with ContentResolver

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

the class PhoneWindowManager method setUserRotationMode.

// User rotation: to be used when all else fails in assigning an orientation to the device
public void setUserRotationMode(int mode, int rot) {
    ContentResolver res = mContext.getContentResolver();
    // mUserRotationMode and mUserRotation will be assigned by the content observer
    if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) {
        Settings.System.putIntForUser(res, Settings.System.USER_ROTATION, rot, UserHandle.USER_CURRENT);
        Settings.System.putIntForUser(res, Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT);
    } else {
        Settings.System.putIntForUser(res, Settings.System.ACCELEROMETER_ROTATION, 1, UserHandle.USER_CURRENT);
    }
}
Also used : ContentResolver(android.content.ContentResolver)

Example 19 with ContentResolver

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

the class ConnectivityService method setGlobalProxy.

public void setGlobalProxy(ProxyProperties proxyProperties) {
    enforceConnectivityInternalPermission();
    synchronized (mProxyLock) {
        if (proxyProperties == mGlobalProxy)
            return;
        if (proxyProperties != null && proxyProperties.equals(mGlobalProxy))
            return;
        if (mGlobalProxy != null && mGlobalProxy.equals(proxyProperties))
            return;
        String host = "";
        int port = 0;
        String exclList = "";
        if (proxyProperties != null && !TextUtils.isEmpty(proxyProperties.getHost())) {
            mGlobalProxy = new ProxyProperties(proxyProperties);
            host = mGlobalProxy.getHost();
            port = mGlobalProxy.getPort();
            exclList = mGlobalProxy.getExclusionList();
        } else {
            mGlobalProxy = null;
        }
        ContentResolver res = mContext.getContentResolver();
        final long token = Binder.clearCallingIdentity();
        try {
            Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, host);
            Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, port);
            Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST, exclList);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }
    if (mGlobalProxy == null) {
        proxyProperties = mDefaultProxy;
    }
    sendProxyBroadcast(proxyProperties);
}
Also used : ProxyProperties(android.net.ProxyProperties) ContentResolver(android.content.ContentResolver)

Example 20 with ContentResolver

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

the class ConnectivityService method getPersistedNetworkPreference.

private int getPersistedNetworkPreference() {
    final ContentResolver cr = mContext.getContentResolver();
    final int networkPrefSetting = Settings.Global.getInt(cr, Settings.Global.NETWORK_PREFERENCE, -1);
    return networkPrefSetting;
}
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