Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05075305 authored by Maxim Bogatov's avatar Maxim Bogatov
Browse files

Limit large font accessibility setting to user profile.

There were 2 problems:
1) When Settings application updated font size it called
ActivityManagerNative.updatePersistentConfiguration() that makes IPC
call to system_process. Then font size was persisted in system_process.
But, the user id we save with the font size if calculated based on the
current process, which is UserHandle.USER_OWNER for the system_process.

2) When user was changed font size was not read from database. Font size
from current configuration was always used.

b/18305168

Change-Id: Id847935a1ab1da3ef133e28ed6928c99c5fe0f16
parent f6431d84
Loading
Loading
Loading
Loading
+32 −10
Original line number Diff line number Diff line
@@ -1580,7 +1580,8 @@ public final class ActivityManagerService extends ActivityManagerNative
            switch (msg.what) {
            case UPDATE_CONFIGURATION_MSG: {
                final ContentResolver resolver = mContext.getContentResolver();
                Settings.System.putConfiguration(resolver, (Configuration) msg.obj);
                Settings.System.putConfigurationForUser(resolver, (Configuration) msg.obj,
                        msg.arg1);
            } break;
            case GC_BACKGROUND_PROCESSES_MSG: {
                synchronized (ActivityManagerService.this) {
@@ -4090,7 +4091,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                    mConfiguration, r.mayFreezeScreenLocked(r.app) ? r.appToken : null);
            if (config != null) {
                r.frozenBeforeDestroy = true;
                if (!updateConfigurationLocked(config, r, false, false)) {
                if (!updateConfigurationLocked(config, r, false)) {
                    mStackSupervisor.resumeTopActivitiesLocked();
                }
            }
@@ -11218,7 +11219,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            mAlwaysFinishActivities = alwaysFinishActivities;
            // This happens before any activities are started, so we can
            // change mConfiguration in-place.
            updateConfigurationLocked(configuration, null, false, true);
            updateConfigurationLocked(configuration, null, true);
            if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                    "Initial config: " + mConfiguration);
        }
@@ -16946,6 +16947,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        return ci;
    }
    @Override
    public void updatePersistentConfiguration(Configuration values) {
        enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
                "updateConfiguration()");
@@ -16955,9 +16957,11 @@ public final class ActivityManagerService extends ActivityManagerNative
            throw new NullPointerException("Configuration must not be null");
        }
        int userId = UserHandle.getCallingUserId();
        synchronized(this) {
            final long origId = Binder.clearCallingIdentity();
            updateConfigurationLocked(values, null, true, false);
            updateConfigurationLocked(values, null, false, true, userId);
            Binder.restoreCallingIdentity(origId);
        }
    }
@@ -16980,21 +16984,30 @@ public final class ActivityManagerService extends ActivityManagerNative
            if (values != null) {
                Settings.System.clearConfiguration(values);
            }
            updateConfigurationLocked(values, null, false, false);
            updateConfigurationLocked(values, null, false);
            Binder.restoreCallingIdentity(origId);
        }
    }
    boolean updateConfigurationLocked(Configuration values,
            ActivityRecord starting, boolean initLocale) {
        // pass UserHandle.USER_NULL as userId because we don't persist configuration for any user
        return updateConfigurationLocked(values, starting, initLocale, false,
                UserHandle.USER_NULL);
    }
    /**
     * Do either or both things: (1) change the current configuration, and (2)
     * make sure the given activity is running with the (now) current
     * configuration.  Returns true if the activity has been left running, or
     * false if <var>starting</var> is being destroyed to match the new
     * configuration.
     * @param persistent TODO
     *
     * @param userId is only used when persistent parameter is set to true to persist configuration
     *               for that particular user
     */
    boolean updateConfigurationLocked(Configuration values,
            ActivityRecord starting, boolean persistent, boolean initLocale) {
            ActivityRecord starting, boolean initLocale, boolean persistent, int userId) {
        int changes = 0;
        if (values != null) {
@@ -17046,6 +17059,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) {
                    Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
                    msg.obj = new Configuration(configCopy);
                    msg.arg1 = userId;
                    mHandler.sendMessage(msg);
                }
@@ -19467,6 +19481,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (foreground) {
                    mCurrentUserId = userId;
                    updateUserConfigurationLocked();
                    mTargetUserId = UserHandle.USER_NULL; // reset, mCurrentUserId has caught up
                    updateCurrentProfileIdsLocked();
                    mWindowManager.setCurrentUser(userId, mCurrentProfileIds);
@@ -19551,7 +19566,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (foreground) {
                    if (!uss.initializing) {
                        moveUserToForeground(uss, oldUserId, userId);
                        moveUserToForegroundLocked(uss, oldUserId, userId);
                    }
                } else {
                    mStackSupervisor.startBackgroundUserLocked(userId, uss);
@@ -19693,14 +19708,14 @@ public final class ActivityManagerService extends ActivityManagerNative
    void onUserInitialized(UserStartedState uss, boolean foreground, int oldUserId, int newUserId) {
        synchronized (this) {
            if (foreground) {
                moveUserToForeground(uss, oldUserId, newUserId);
                moveUserToForegroundLocked(uss, oldUserId, newUserId);
            }
        }
        completeSwitchAndInitalize(uss, newUserId, true, false);
    }
    void moveUserToForeground(UserStartedState uss, int oldUserId, int newUserId) {
    void moveUserToForegroundLocked(UserStartedState uss, int oldUserId, int newUserId) {
        boolean homeInFront = mStackSupervisor.switchUserLocked(newUserId, uss);
        if (homeInFront) {
            startHomeActivityLocked(newUserId, "moveUserToFroreground");
@@ -19712,6 +19727,13 @@ public final class ActivityManagerService extends ActivityManagerNative
        sendUserSwitchBroadcastsLocked(oldUserId, newUserId);
    }
    private void updateUserConfigurationLocked() {
        Configuration configuration = new Configuration(mConfiguration);
        Settings.System.getConfigurationForUser(mContext.getContentResolver(), configuration,
                mCurrentUserId);
        updateConfigurationLocked(configuration, null, false);
    }
    void continueUserSwitch(UserStartedState uss, int oldUserId, int newUserId) {
        completeSwitchAndInitalize(uss, newUserId, false, true);
    }
+1 −1
Original line number Diff line number Diff line
@@ -1870,7 +1870,7 @@ final class ActivityStack {
                if (config != null) {
                    next.frozenBeforeDestroy = true;
                }
                notUpdated = !mService.updateConfigurationLocked(config, next, false, false);
                notUpdated = !mService.updateConfigurationLocked(config, next, false);
            }

            if (notUpdated) {
+2 −2
Original line number Diff line number Diff line
@@ -1028,7 +1028,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
                stack.mConfigWillChange = false;
                if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                        "Updating to new configuration after starting activity.");
                mService.updateConfigurationLocked(config, null, false, false);
                mService.updateConfigurationLocked(config, null, false);
            }

            if (outResult != null) {
@@ -1166,7 +1166,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            Configuration config = mWindowManager.updateOrientationFromAppTokens(
                    mService.mConfiguration,
                    r.mayFreezeScreenLocked(app) ? r.appToken : null);
            mService.updateConfigurationLocked(config, r, false, false);
            mService.updateConfigurationLocked(config, r, false);
        }

        r.app = app;