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

Commit 5fa84cde authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Include stack override configurations in onConfigurationChanged() call."

parents dea0bbbe c2607b4e
Loading
Loading
Loading
Loading
+41 −13
Original line number Original line Diff line number Diff line
@@ -294,6 +294,8 @@ public final class ActivityThread {
        Configuration newConfig;
        Configuration newConfig;
        Configuration createdConfig;
        Configuration createdConfig;
        Configuration overrideConfig;
        Configuration overrideConfig;
        // Used for consolidating configs before sending on to Activity.
        private Configuration tmpConfig = new Configuration();
        ActivityClientRecord nextIdle;
        ActivityClientRecord nextIdle;


        ProfilerInfo profilerInfo;
        ProfilerInfo profilerInfo;
@@ -557,6 +559,15 @@ public final class ActivityThread {
        int requestType;
        int requestType;
    }
    }


    static final class ActivityConfigChangeData {
        final IBinder activityToken;
        final Configuration overrideConfig;
        public ActivityConfigChangeData(IBinder token, Configuration config) {
            activityToken = token;
            overrideConfig = config;
        }
    }

    private native void dumpGraphicsInfo(FileDescriptor fd);
    private native void dumpGraphicsInfo(FileDescriptor fd);


    private class ApplicationThread extends ApplicationThreadNative {
    private class ApplicationThread extends ApplicationThreadNative {
@@ -888,15 +899,19 @@ public final class ActivityThread {
                    sticky, sendingUser);
                    sticky, sendingUser);
        }
        }


        @Override
        public void scheduleLowMemory() {
        public void scheduleLowMemory() {
            sendMessage(H.LOW_MEMORY, null);
            sendMessage(H.LOW_MEMORY, null);
        }
        }


        @Override
        @Override
        public void scheduleActivityConfigurationChanged(IBinder token) {
        public void scheduleActivityConfigurationChanged(
            sendMessage(H.ACTIVITY_CONFIGURATION_CHANGED, token);
                IBinder token, Configuration overrideConfig) {
            sendMessage(H.ACTIVITY_CONFIGURATION_CHANGED,
                    new ActivityConfigChangeData(token, overrideConfig));
        }
        }


        @Override
        public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) {
        public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) {
            sendMessage(H.PROFILER_CONTROL, profilerInfo, start ? 1 : 0, profileType);
            sendMessage(H.PROFILER_CONTROL, profilerInfo, start ? 1 : 0, profileType);
        }
        }
@@ -1456,7 +1471,7 @@ public final class ActivityThread {
                    break;
                    break;
                case ACTIVITY_CONFIGURATION_CHANGED:
                case ACTIVITY_CONFIGURATION_CHANGED:
                    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityConfigChanged");
                    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityConfigChanged");
                    handleActivityConfigurationChanged((IBinder)msg.obj);
                    handleActivityConfigurationChanged((ActivityConfigChangeData)msg.obj);
                    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
                    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
                    break;
                    break;
                case PROFILER_CONTROL:
                case PROFILER_CONTROL:
@@ -3099,10 +3114,14 @@ public final class ActivityThread {
            if (!r.activity.mFinished && willBeVisible
            if (!r.activity.mFinished && willBeVisible
                    && r.activity.mDecor != null && !r.hideForNow) {
                    && r.activity.mDecor != null && !r.hideForNow) {
                if (r.newConfig != null) {
                if (r.newConfig != null) {
                    r.tmpConfig.setTo(r.newConfig);
                    if (r.overrideConfig != null) {
                        r.tmpConfig.updateFrom(r.overrideConfig);
                    }
                    if (DEBUG_CONFIGURATION) Slog.v(TAG, "Resuming activity "
                    if (DEBUG_CONFIGURATION) Slog.v(TAG, "Resuming activity "
                            + r.activityInfo.name + " with newConfig " + r.newConfig);
                            + r.activityInfo.name + " with newConfig " + r.tmpConfig);
                    performConfigurationChanged(r.activity, r.newConfig);
                    performConfigurationChanged(r.activity, r.tmpConfig);
                    freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.newConfig));
                    freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
                    r.newConfig = null;
                    r.newConfig = null;
                }
                }
                if (localLOGV) Slog.v(TAG, "Resuming " + r + " with isForward="
                if (localLOGV) Slog.v(TAG, "Resuming " + r + " with isForward="
@@ -3431,10 +3450,14 @@ public final class ActivityThread {
                    }
                    }
                }
                }
                if (r.newConfig != null) {
                if (r.newConfig != null) {
                    r.tmpConfig.setTo(r.newConfig);
                    if (r.overrideConfig != null) {
                        r.tmpConfig.updateFrom(r.overrideConfig);
                    }
                    if (DEBUG_CONFIGURATION) Slog.v(TAG, "Updating activity vis "
                    if (DEBUG_CONFIGURATION) Slog.v(TAG, "Updating activity vis "
                            + r.activityInfo.name + " with new config " + r.newConfig);
                            + r.activityInfo.name + " with new config " + r.tmpConfig);
                    performConfigurationChanged(r.activity, r.newConfig);
                    performConfigurationChanged(r.activity, r.tmpConfig);
                    freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.newConfig));
                    freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
                    r.newConfig = null;
                    r.newConfig = null;
                }
                }
            } else {
            } else {
@@ -4164,8 +4187,8 @@ public final class ActivityThread {
        }
        }
    }
    }


    final void handleActivityConfigurationChanged(IBinder token) {
    final void handleActivityConfigurationChanged(ActivityConfigChangeData data) {
        ActivityClientRecord r = mActivities.get(token);
        ActivityClientRecord r = mActivities.get(data.activityToken);
        if (r == null || r.activity == null) {
        if (r == null || r.activity == null) {
            return;
            return;
        }
        }
@@ -4173,7 +4196,12 @@ public final class ActivityThread {
        if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: "
        if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: "
                + r.activityInfo.name);
                + r.activityInfo.name);


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


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


+16 −2
Original line number Original line Diff line number Diff line
@@ -409,7 +409,11 @@ public abstract class ApplicationThreadNative extends Binder
        {
        {
            data.enforceInterface(IApplicationThread.descriptor);
            data.enforceInterface(IApplicationThread.descriptor);
            IBinder b = data.readStrongBinder();
            IBinder b = data.readStrongBinder();
            scheduleActivityConfigurationChanged(b);
            Configuration overrideConfig = null;
            if (data.readInt() != 0) {
                overrideConfig = Configuration.CREATOR.createFromParcel(data);
            }
            scheduleActivityConfigurationChanged(b, overrideConfig);
            return true;
            return true;
        }
        }


@@ -1116,6 +1120,7 @@ class ApplicationThreadProxy implements IApplicationThread {
        data.recycle();
        data.recycle();
    }
    }


    @Override
    public final void scheduleLowMemory() throws RemoteException {
    public final void scheduleLowMemory() throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeInterfaceToken(IApplicationThread.descriptor);
@@ -1124,15 +1129,24 @@ class ApplicationThreadProxy implements IApplicationThread {
        data.recycle();
        data.recycle();
    }
    }


    public final void scheduleActivityConfigurationChanged(IBinder token) throws RemoteException {
    @Override
    public final void scheduleActivityConfigurationChanged(
            IBinder token, Configuration overrideConfig) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeStrongBinder(token);
        data.writeStrongBinder(token);
        if (overrideConfig != null) {
            data.writeInt(1);
            overrideConfig.writeToParcel(data, 0);
        } else {
            data.writeInt(0);
        }
        mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null,
        mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null,
                IBinder.FLAG_ONEWAY);
                IBinder.FLAG_ONEWAY);
        data.recycle();
        data.recycle();
    }
    }


    @Override
    public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
    public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
            throws RemoteException {
            throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
+2 −1
Original line number Original line Diff line number Diff line
@@ -114,7 +114,8 @@ public interface IApplicationThread extends IInterface {
            int resultCode, String data, Bundle extras, boolean ordered,
            int resultCode, String data, Bundle extras, boolean ordered,
            boolean sticky, int sendingUser, int processState) throws RemoteException;
            boolean sticky, int sendingUser, int processState) throws RemoteException;
    void scheduleLowMemory() throws RemoteException;
    void scheduleLowMemory() throws RemoteException;
    void scheduleActivityConfigurationChanged(IBinder token) throws RemoteException;
    void scheduleActivityConfigurationChanged(IBinder token, Configuration overrideConfig)
            throws RemoteException;
    void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
    void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
            throws RemoteException;
            throws RemoteException;
    void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd)
    void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd)
+6 −6
Original line number Original line Diff line number Diff line
@@ -3797,15 +3797,15 @@ final class ActivityStack {
            return false;
            return false;
        }
        }


        // Default case: the activity can handle this new configuration, so
        // Default case: the activity can handle this new configuration, so hand it over.
        // hand it over.  Note that we don't need to give it the new
        // NOTE: We only forward the stack override configuration as the system level configuration
        // configuration, since we always send configuration changes to all
        // changes is always sent to all processes when they happen so it can just use whatever
        // process when they happen so it can just use whatever configuration
        // system level configuration it last got.
        // it last got.
        if (r.app != null && r.app.thread != null) {
        if (r.app != null && r.app.thread != null) {
            try {
            try {
                if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + r);
                if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + r);
                r.app.thread.scheduleActivityConfigurationChanged(r.appToken);
                r.app.thread.scheduleActivityConfigurationChanged(
                        r.appToken, new Configuration(mOverrideConfig));
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                // If process died, whatever.
                // If process died, whatever.
            }
            }