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

Commit 5e393507 authored by Charles Chen's avatar Charles Chen
Browse files

Add more logs in RootTDAOrganizer

There is an issue that obtaining a display specified by
DisplayAreaInfo#displayId in onDisplayAreaAppeared
failed and caused an Exception in Shell and System UI
restarted. It is very odd that the info is directly from WMS
and the display should be initialized already.

This CL tries to add more logs to help debug the root cause.

Test: manual
Bug: 180818790
Change-Id: I0ea6387f80a2f19a985815419fae3602963c6c84
parent 5d3166d4
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2566,9 +2566,7 @@ class ContextImpl extends Context {
    @Override
    public Context createTokenContext(@NonNull IBinder token, @NonNull Display display) {
        if (display == null) {
            throw new UnsupportedOperationException("Token context can only be created from "
                    + "other visual contexts, such as Activity or one created with "
                    + "Context#createDisplayContext(Display)");
            throw new IllegalArgumentException("Display must not be null");
        }
        final ContextImpl tokenContext = createBaseWindowContext(token, display);
        tokenContext.setResources(createWindowContextResources());
+15 −14
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class RootTaskDisplayAreaOrganizer extends DisplayAreaOrganizer {
                listeners.get(i).onDisplayAreaAppeared(displayAreaInfo);
            }
        }
        applyConfigChangesToContext(displayId, displayAreaInfo.configuration);
        applyConfigChangesToContext(displayAreaInfo);
    }

    @Override
@@ -161,24 +161,27 @@ public class RootTaskDisplayAreaOrganizer extends DisplayAreaOrganizer {
                listeners.get(i).onDisplayAreaInfoChanged(displayAreaInfo);
            }
        }
        applyConfigChangesToContext(displayId, displayAreaInfo.configuration);
        applyConfigChangesToContext(displayAreaInfo);
    }

    /**
     * Applies the {@link Configuration} to the {@link DisplayAreaContext} specified by
     * {@code displayId}.
     *
     * @param displayId The ID of the {@link Display} which the {@link DisplayAreaContext} is
     *                  associated with
     * @param newConfig The propagated configuration
     * Applies the {@link DisplayAreaInfo} to the {@link DisplayAreaContext} specified by
     * {@link DisplayAreaInfo#displayId}.
     */
    private void applyConfigChangesToContext(int displayId, @NonNull Configuration newConfig) {
    private void applyConfigChangesToContext(@NonNull DisplayAreaInfo displayAreaInfo) {
        final int displayId = displayAreaInfo.displayId;
        final Display display = mContext.getSystemService(DisplayManager.class)
                .getDisplay(displayId);
        if (display == null) {
            throw new UnsupportedOperationException("The display #" + displayId + " is invalid."
                    + "displayAreaInfo:" + displayAreaInfo);
        }
        DisplayAreaContext daContext = mDisplayAreaContexts.get(displayId);
        if (daContext == null) {
            daContext = new DisplayAreaContext(mContext, displayId);
            daContext = new DisplayAreaContext(mContext, display);
            mDisplayAreaContexts.put(displayId, daContext);
        }
        daContext.updateConfigurationChanges(newConfig);
        daContext.updateConfigurationChanges(displayAreaInfo.configuration);
    }

    /**
@@ -228,10 +231,8 @@ public class RootTaskDisplayAreaOrganizer extends DisplayAreaOrganizer {
        private final IBinder mToken = new Binder();
        private final ResourcesManager mResourcesManager = ResourcesManager.getInstance();

        public DisplayAreaContext(@NonNull Context context, int displayId) {
        public DisplayAreaContext(@NonNull Context context, @NonNull Display display) {
            super(null);
            final Display display = context.getSystemService(DisplayManager.class)
                    .getDisplay(displayId);
            attachBaseContext(context.createTokenContext(mToken, display));
        }