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