use of android.content.ContentResolver in project platform_frameworks_base by android.
the class DisplayAdjustmentUtils method applyInversionSetting.
/**
* Applies the specified user's display color adjustments.
*/
public static void applyInversionSetting(Context context, int userId) {
final ContentResolver cr = context.getContentResolver();
final DisplayTransformManager dtm = LocalServices.getService(DisplayTransformManager.class);
final boolean invertColors = Secure.getIntForUser(cr, Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0, userId) != 0;
dtm.setColorMatrix(DisplayTransformManager.LEVEL_COLOR_MATRIX_INVERT_COLOR, invertColors ? MATRIX_INVERT_COLOR : null);
}
use of android.content.ContentResolver in project platform_frameworks_base by android.
the class ActivityManagerService method retrieveSettings.
private void retrieveSettings() {
final ContentResolver resolver = mContext.getContentResolver();
final boolean freeformWindowManagement = mContext.getPackageManager().hasSystemFeature(FEATURE_FREEFORM_WINDOW_MANAGEMENT) || Settings.Global.getInt(resolver, DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, 0) != 0;
final boolean supportsPictureInPicture = mContext.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE);
final boolean supportsMultiWindow = ActivityManager.supportsMultiWindow();
final String debugApp = Settings.Global.getString(resolver, DEBUG_APP);
final boolean waitForDebugger = Settings.Global.getInt(resolver, WAIT_FOR_DEBUGGER, 0) != 0;
final boolean alwaysFinishActivities = Settings.Global.getInt(resolver, ALWAYS_FINISH_ACTIVITIES, 0) != 0;
final boolean lenientBackgroundCheck = Settings.Global.getInt(resolver, LENIENT_BACKGROUND_CHECK, 0) != 0;
final boolean forceRtl = Settings.Global.getInt(resolver, DEVELOPMENT_FORCE_RTL, 0) != 0;
final boolean forceResizable = Settings.Global.getInt(resolver, DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, 0) != 0;
final boolean supportsLeanbackOnly = mContext.getPackageManager().hasSystemFeature(FEATURE_LEANBACK_ONLY);
// Transfer any global setting for forcing RTL layout, into a System Property
SystemProperties.set(DEVELOPMENT_FORCE_RTL, forceRtl ? "1" : "0");
final Configuration configuration = new Configuration();
Settings.System.getConfiguration(resolver, configuration);
if (forceRtl) {
// This will take care of setting the correct layout direction flags
configuration.setLayoutDirection(configuration.locale);
}
synchronized (this) {
mDebugApp = mOrigDebugApp = debugApp;
mWaitForDebugger = mOrigWaitForDebugger = waitForDebugger;
mAlwaysFinishActivities = alwaysFinishActivities;
mLenientBackgroundCheck = lenientBackgroundCheck;
mSupportsLeanbackOnly = supportsLeanbackOnly;
mForceResizableActivities = forceResizable;
mWindowManager.setForceResizableTasks(mForceResizableActivities);
if (supportsMultiWindow || forceResizable) {
mSupportsMultiWindow = true;
mSupportsFreeformWindowManagement = freeformWindowManagement || forceResizable;
mSupportsPictureInPicture = supportsPictureInPicture || forceResizable;
} else {
mSupportsMultiWindow = false;
mSupportsFreeformWindowManagement = false;
mSupportsPictureInPicture = false;
}
// This happens before any activities are started, so we can
// change mConfiguration in-place.
updateConfigurationLocked(configuration, null, true);
if (DEBUG_CONFIGURATION)
Slog.v(TAG_CONFIGURATION, "Initial config: " + mConfiguration);
// Load resources only after the current configuration has been set.
final Resources res = mContext.getResources();
mHasRecents = res.getBoolean(com.android.internal.R.bool.config_hasRecents);
mThumbnailWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
mThumbnailHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
mDefaultPinnedStackBounds = Rect.unflattenFromString(res.getString(com.android.internal.R.string.config_defaultPictureInPictureBounds));
mAppErrors.loadAppsNotReportingCrashesFromConfigLocked(res.getString(com.android.internal.R.string.config_appsNotReportingCrashes));
if ((mConfiguration.uiMode & UI_MODE_TYPE_TELEVISION) == UI_MODE_TYPE_TELEVISION) {
mFullscreenThumbnailScale = (float) res.getInteger(com.android.internal.R.integer.thumbnail_width_tv) / (float) mConfiguration.screenWidthDp;
} else {
mFullscreenThumbnailScale = res.getFraction(com.android.internal.R.fraction.thumbnail_fullscreen_scale, 1, 1);
}
}
}
use of android.content.ContentResolver in project platform_frameworks_base by android.
the class ActivityManagerService method registerReceiver.
public Intent registerReceiver(IApplicationThread caller, String callerPackage, IIntentReceiver receiver, IntentFilter filter, String permission, int userId) {
enforceNotIsolatedCaller("registerReceiver");
ArrayList<Intent> stickyIntents = null;
ProcessRecord callerApp = null;
int callingUid;
int callingPid;
synchronized (this) {
if (caller != null) {
callerApp = getRecordForAppLocked(caller);
if (callerApp == null) {
throw new SecurityException("Unable to find app for caller " + caller + " (pid=" + Binder.getCallingPid() + ") when registering receiver " + receiver);
}
if (callerApp.info.uid != Process.SYSTEM_UID && !callerApp.pkgList.containsKey(callerPackage) && !"android".equals(callerPackage)) {
throw new SecurityException("Given caller package " + callerPackage + " is not running in process " + callerApp);
}
callingUid = callerApp.info.uid;
callingPid = callerApp.pid;
} else {
callerPackage = null;
callingUid = Binder.getCallingUid();
callingPid = Binder.getCallingPid();
}
userId = mUserController.handleIncomingUser(callingPid, callingUid, userId, true, ALLOW_FULL_ONLY, "registerReceiver", callerPackage);
Iterator<String> actions = filter.actionsIterator();
if (actions == null) {
ArrayList<String> noAction = new ArrayList<String>(1);
noAction.add(null);
actions = noAction.iterator();
}
// Collect stickies of users
int[] userIds = { UserHandle.USER_ALL, UserHandle.getUserId(callingUid) };
while (actions.hasNext()) {
String action = actions.next();
for (int id : userIds) {
ArrayMap<String, ArrayList<Intent>> stickies = mStickyBroadcasts.get(id);
if (stickies != null) {
ArrayList<Intent> intents = stickies.get(action);
if (intents != null) {
if (stickyIntents == null) {
stickyIntents = new ArrayList<Intent>();
}
stickyIntents.addAll(intents);
}
}
}
}
}
ArrayList<Intent> allSticky = null;
if (stickyIntents != null) {
final ContentResolver resolver = mContext.getContentResolver();
// Look for any matching sticky broadcasts...
for (int i = 0, N = stickyIntents.size(); i < N; i++) {
Intent intent = stickyIntents.get(i);
// cannot lock ActivityManagerService here.
if (filter.match(resolver, intent, true, TAG) >= 0) {
if (allSticky == null) {
allSticky = new ArrayList<Intent>();
}
allSticky.add(intent);
}
}
}
// The first sticky in the list is returned directly back to the client.
Intent sticky = allSticky != null ? allSticky.get(0) : null;
if (DEBUG_BROADCAST)
Slog.v(TAG_BROADCAST, "Register receiver " + filter + ": " + sticky);
if (receiver == null) {
return sticky;
}
synchronized (this) {
if (callerApp != null && (callerApp.thread == null || callerApp.thread.asBinder() != caller.asBinder())) {
// Original caller already died
return null;
}
ReceiverList rl = mRegisteredReceivers.get(receiver.asBinder());
if (rl == null) {
rl = new ReceiverList(this, callerApp, callingPid, callingUid, userId, receiver);
if (rl.app != null) {
rl.app.receivers.add(rl);
} else {
try {
receiver.asBinder().linkToDeath(rl, 0);
} catch (RemoteException e) {
return sticky;
}
rl.linkedToDeath = true;
}
mRegisteredReceivers.put(receiver.asBinder(), rl);
} else if (rl.uid != callingUid) {
throw new IllegalArgumentException("Receiver requested to register for uid " + callingUid + " was previously registered for uid " + rl.uid);
} else if (rl.pid != callingPid) {
throw new IllegalArgumentException("Receiver requested to register for pid " + callingPid + " was previously registered for pid " + rl.pid);
} else if (rl.userId != userId) {
throw new IllegalArgumentException("Receiver requested to register for user " + userId + " was previously registered for user " + rl.userId);
}
BroadcastFilter bf = new BroadcastFilter(filter, rl, callerPackage, permission, callingUid, userId);
rl.add(bf);
if (!bf.debugCheck()) {
Slog.w(TAG, "==> For Dynamic broadcast");
}
mReceiverResolver.addFilter(bf);
// this filter.
if (allSticky != null) {
ArrayList receivers = new ArrayList();
receivers.add(bf);
final int stickyCount = allSticky.size();
for (int i = 0; i < stickyCount; i++) {
Intent intent = allSticky.get(i);
BroadcastQueue queue = broadcastQueueForIntent(intent);
BroadcastRecord r = new BroadcastRecord(queue, intent, null, null, -1, -1, null, null, AppOpsManager.OP_NONE, null, receivers, null, 0, null, null, false, true, true, -1);
queue.enqueueParallelBroadcastLocked(r);
queue.scheduleBroadcastsLocked();
}
}
return sticky;
}
}
use of android.content.ContentResolver in project platform_frameworks_base by android.
the class SearchRecentSuggestionsProviderTest method getQueryCursor.
/**
* Generate a query cursor in a manner like the search dialog would.
*
* @param queryString The search string, or, null for "all"
* @return Returns a cursor, or null if there was some problem. Be sure to close the cursor
* when done with it.
*/
private Cursor getQueryCursor(String queryString) {
ContentResolver cr = getMockContext().getContentResolver();
String uriStr = "content://" + TestProvider.AUTHORITY + '/' + SearchManager.SUGGEST_URI_PATH_QUERY;
Uri contentUri = Uri.parse(uriStr);
String[] selArgs = new String[] { queryString };
Cursor c = cr.query(contentUri, null, null, selArgs, null);
assertNotNull(c);
return c;
}
use of android.content.ContentResolver in project platform_frameworks_base by android.
the class SettingsProviderTest method testRowNameContentUri.
private void testRowNameContentUri(Uri table, String nameField, String valueField, String testKey, String testValue, String secondTestValue) {
ContentResolver r = getContext().getContentResolver();
ContentValues v = new ContentValues();
v.put(nameField, testKey);
v.put(valueField, testValue);
r.insert(table, v);
Uri uri = Uri.parse(table.toString() + "/" + testKey);
// Query with a specific URI and no WHERE clause succeeds.
Cursor c = r.query(uri, null, null, null, null);
try {
assertTrue(c.moveToNext());
assertEquals(testKey, c.getString(c.getColumnIndex(nameField)));
assertEquals(testValue, c.getString(c.getColumnIndex(valueField)));
assertFalse(c.moveToNext());
} finally {
c.close();
}
// Query with a specific URI and a WHERE clause fails.
try {
r.query(uri, null, "1", null, null);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
// expected
}
// Query with a tablewide URI and a WHERE clause succeeds.
c = r.query(table, null, "name='" + testKey + "'", null, null);
try {
assertTrue(c.moveToNext());
assertEquals(testKey, c.getString(c.getColumnIndex(nameField)));
assertEquals(testValue, c.getString(c.getColumnIndex(valueField)));
assertFalse(c.moveToNext());
} finally {
c.close();
}
v = new ContentValues();
// NAME is still needed, although the uri should be specific enough. Why?
v.put(nameField, testKey);
v.put(valueField, secondTestValue);
assertEquals(1, r.update(uri, v, null, null));
c = r.query(uri, null, null, null, null);
try {
assertTrue(c.moveToNext());
assertEquals(testKey, c.getString(c.getColumnIndex(nameField)));
assertEquals(secondTestValue, c.getString(c.getColumnIndex(valueField)));
assertFalse(c.moveToNext());
} finally {
c.close();
}
}
Aggregations