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

Commit 3696301a authored by Filip Gruszczynski's avatar Filip Gruszczynski Committed by Android (Google) Code Review
Browse files

Merge "Update client configuration when resizing without crossing size threshold."

parents a99fce54 ca664812
Loading
Loading
Loading
Loading
+20 −13
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ import android.util.AndroidRuntimeException;
import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.IntArray;
import android.util.Log;
import android.util.LogPrinter;
import android.util.Pair;
@@ -184,6 +183,9 @@ public final class ActivityThread {
    private static final int USER_LEAVING = 1;
    private static final int DONT_REPORT = 2;

    // Whether to invoke an activity callback after delivering new configuration.
    private static final boolean REPORT_TO_ACTIVITY = true;

    private ContextImpl mSystemContext;

    static IPackageManager sPackageManager;
@@ -943,9 +945,9 @@ public final class ActivityThread {

        @Override
        public void scheduleActivityConfigurationChanged(
                IBinder token, Configuration overrideConfig) {
                IBinder token, Configuration overrideConfig, boolean reportToActivity) {
            sendMessage(H.ACTIVITY_CONFIGURATION_CHANGED,
                    new ActivityConfigChangeData(token, overrideConfig));
                    new ActivityConfigChangeData(token, overrideConfig), reportToActivity ? 1 : 0);
        }

        @Override
@@ -1537,7 +1539,8 @@ public final class ActivityThread {
                    break;
                case ACTIVITY_CONFIGURATION_CHANGED:
                    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityConfigChanged");
                    handleActivityConfigurationChanged((ActivityConfigChangeData)msg.obj);
                    handleActivityConfigurationChanged((ActivityConfigChangeData) msg.obj,
                            msg.arg1 == 1 ? REPORT_TO_ACTIVITY : !REPORT_TO_ACTIVITY);
                    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
                    break;
                case PROFILER_CONTROL:
@@ -3347,7 +3350,7 @@ public final class ActivityThread {
                    }
                    if (DEBUG_CONFIGURATION) Slog.v(TAG, "Resuming activity "
                            + r.activityInfo.name + " with newConfig " + r.tmpConfig);
                    performConfigurationChanged(r.activity, r.tmpConfig);
                    performConfigurationChanged(r.activity, r.tmpConfig, REPORT_TO_ACTIVITY);
                    freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
                    r.newConfig = null;
                }
@@ -3687,7 +3690,7 @@ public final class ActivityThread {
                    }
                    if (DEBUG_CONFIGURATION) Slog.v(TAG, "Updating activity vis "
                            + r.activityInfo.name + " with new config " + r.tmpConfig);
                    performConfigurationChanged(r.activity, r.tmpConfig);
                    performConfigurationChanged(r.activity, r.tmpConfig, REPORT_TO_ACTIVITY);
                    freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
                    r.newConfig = null;
                }
@@ -4340,7 +4343,8 @@ public final class ActivityThread {
        return callbacks;
    }

    private static void performConfigurationChanged(ComponentCallbacks2 cb, Configuration config) {
    private static void performConfigurationChanged(ComponentCallbacks2 cb, Configuration config,
            boolean reportToActivity) {
        // Only for Activity objects, check that they actually call up to their
        // superclass implementation.  ComponentCallbacks2 is an interface, so
        // we check the runtime type and act accordingly.
@@ -4371,10 +4375,12 @@ public final class ActivityThread {
        if (DEBUG_CONFIGURATION) Slog.v(TAG, "Config callback " + cb
                + ": shouldChangeConfig=" + shouldChangeConfig);
        if (shouldChangeConfig) {
            if (reportToActivity) {
                cb.onConfigurationChanged(config);
            }

            if (activity != null) {
                if (!activity.mCalled) {
                if (reportToActivity && !activity.mCalled) {
                    throw new SuperNotCalledException(
                            "Activity " + activity.getLocalClassName() +
                        " did not call through to super.onConfigurationChanged()");
@@ -4449,7 +4455,7 @@ public final class ActivityThread {
        if (callbacks != null) {
            final int N = callbacks.size();
            for (int i=0; i<N; i++) {
                performConfigurationChanged(callbacks.get(i), config);
                performConfigurationChanged(callbacks.get(i), config, REPORT_TO_ACTIVITY);
            }
        }
    }
@@ -4465,21 +4471,22 @@ public final class ActivityThread {
        }
    }

    final void handleActivityConfigurationChanged(ActivityConfigChangeData data) {
    final void handleActivityConfigurationChanged(ActivityConfigChangeData data,
            boolean reportToActivity) {
        ActivityClientRecord r = mActivities.get(data.activityToken);
        if (r == null || r.activity == null) {
            return;
        }

        if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: "
                + r.activityInfo.name);
                + r.activityInfo.name + ", with callback=" + reportToActivity);

        r.tmpConfig.setTo(mCompatConfiguration);
        if (data.overrideConfig != null) {
            r.overrideConfig = data.overrideConfig;
            r.tmpConfig.updateFrom(data.overrideConfig);
        }
        performConfigurationChanged(r.activity, r.tmpConfig);
        performConfigurationChanged(r.activity, r.tmpConfig, reportToActivity);

        freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(mCompatConfiguration));

+5 −3
Original line number Diff line number Diff line
@@ -420,7 +420,8 @@ public abstract class ApplicationThreadNative extends Binder
            if (data.readInt() != 0) {
                overrideConfig = Configuration.CREATOR.createFromParcel(data);
            }
            scheduleActivityConfigurationChanged(b, overrideConfig);
            final boolean reportToActivity = data.readInt() == 1;
            scheduleActivityConfigurationChanged(b, overrideConfig, reportToActivity);
            return true;
        }

@@ -1169,8 +1170,8 @@ class ApplicationThreadProxy implements IApplicationThread {
    }

    @Override
    public final void scheduleActivityConfigurationChanged(
            IBinder token, Configuration overrideConfig) throws RemoteException {
    public final void scheduleActivityConfigurationChanged(IBinder token,
            Configuration overrideConfig, boolean reportToActivity) throws RemoteException {
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeStrongBinder(token);
@@ -1180,6 +1181,7 @@ class ApplicationThreadProxy implements IApplicationThread {
        } else {
            data.writeInt(0);
        }
        data.writeInt(reportToActivity ? 1 : 0);
        mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null,
                IBinder.FLAG_ONEWAY);
        data.recycle();
+2 −2
Original line number Diff line number Diff line
@@ -116,8 +116,8 @@ public interface IApplicationThread extends IInterface {
            int resultCode, String data, Bundle extras, boolean ordered,
            boolean sticky, int sendingUser, int processState) throws RemoteException;
    void scheduleLowMemory() throws RemoteException;
    void scheduleActivityConfigurationChanged(IBinder token, Configuration overrideConfig)
            throws RemoteException;
    void scheduleActivityConfigurationChanged(IBinder token, Configuration overrideConfig,
            boolean reportToActivity) throws RemoteException;
    void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
            throws RemoteException;
    void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd)
+13 −0
Original line number Diff line number Diff line
@@ -384,6 +384,19 @@ final class ActivityRecord {
        mSmallestSizeConfigurations = smallestSizeConfigurations;
    }

    void scheduleConfigurationChanged(Configuration config, boolean reportToActivity) {
        if (app != null && app.thread != null) {
            try {
                if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + this + " " +
                        "reportToActivity=" + reportToActivity + " and config: " + config);
                app.thread.scheduleActivityConfigurationChanged(
                        appToken, new Configuration(config), reportToActivity);
            } catch (RemoteException e) {
                // If process died, whatever.
            }
        }
    }

    static class Token extends IApplicationToken.Stub {
        private final WeakReference<ActivityRecord> weakActivity;
        private final ActivityManagerService mService;
+6 −10
Original line number Diff line number Diff line
@@ -4105,6 +4105,9 @@ final class ActivityStack {
        if (changes == 0 && !r.forceNewConfig) {
            if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                    "Configuration no differences in " + r);
            // There are no significant differences, so we won't relaunch but should still deliver
            // the new configuration to the client process.
            r.scheduleConfigurationChanged(taskConfig, false);
            return true;
        }

@@ -4127,7 +4130,8 @@ final class ActivityStack {
        if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                "Checking to restart " + r.info.name + ": changed=0x"
                + Integer.toHexString(changes) + ", handles=0x"
                + Integer.toHexString(r.info.getRealConfigChanged()) + ", newConfig=" + newConfig);
                + Integer.toHexString(r.info.getRealConfigChanged()) + ", newConfig=" + newConfig
                + ", taskConfig=" + taskConfig);

        if ((changes&(~r.info.getRealConfigChanged())) != 0 || r.forceNewConfig) {
            // Aha, the activity isn't handling the change, so DIE DIE DIE.
@@ -4173,15 +4177,7 @@ final class ActivityStack {
        // NOTE: We only forward the task override configuration as the system level configuration
        // changes is always sent to all processes when they happen so it can just use whatever
        // system level configuration it last got.
        if (r.app != null && r.app.thread != null) {
            try {
                if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Sending new config to " + r);
                r.app.thread.scheduleActivityConfigurationChanged(
                        r.appToken, new Configuration(taskConfig));
            } catch (RemoteException e) {
                // If process died, whatever.
            }
        }
        r.scheduleConfigurationChanged(taskConfig, true);
        r.stopFreezingScreenLocked(false);

        return true;