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

Commit ec1caffd authored by Diego Vela's avatar Diego Vela Committed by Automerger Merge Worker
Browse files

Merge "Update WindowManager Jetpack in SC" into sc-dev am: ab36c037

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14163036

Change-Id: I87fd6f81807380f63f00a180baf9127b371c56dd
parents 63f6ea74 ab36c037
Loading
Loading
Loading
Loading
+6 −16
Original line number Diff line number Diff line
@@ -69,21 +69,15 @@ class SampleExtensionImpl extends StubExtension {
                new ResourceConfigDisplayFeatureProducer(context)
        ));

        mDevicePostureProducer.addDataChangedCallback(this::onDevicePostureChanged);
        mDevicePostureProducer.addDataChangedCallback(this::onDisplayFeaturesChanged);
        mDisplayFeatureProducer.addDataChangedCallback(this::onDisplayFeaturesChanged);
    }

    private void onDevicePostureChanged() {
        updateDeviceState(new ExtensionDeviceState(getDevicePosture()));

        // Trigger a change in display features as the posture will be used in place of the feature
        // state if the state is left unset by the producer.
        onDisplayFeaturesChanged();
    }

    private int getDevicePosture() {
    private int getFeatureState(DisplayFeature feature) {
        Integer featureState = feature.getState();
        Optional<Integer> posture = mDevicePostureProducer.getData();
        return posture.orElse(ExtensionDeviceState.POSTURE_UNKNOWN);
        int fallbackPosture = posture.orElse(ExtensionFoldingFeature.STATE_FLAT);
        return featureState == null ? fallbackPosture : featureState;
    }

    private void onDisplayFeaturesChanged() {
@@ -115,17 +109,14 @@ class SampleExtensionImpl extends StubExtension {

        Optional<List<DisplayFeature>> storedFeatures = mDisplayFeatureProducer.getData();
        if (storedFeatures.isPresent()) {
            int posture = getDevicePosture();

            for (DisplayFeature baseFeature : storedFeatures.get()) {
                Rect featureRect = baseFeature.getRect();
                rotateRectToDisplayRotation(displayId, featureRect);
                transformToWindowSpaceRect(activity, featureRect);

                Integer featureState = baseFeature.getState();

                features.add(new ExtensionFoldingFeature(featureRect, baseFeature.getType(),
                        featureState == null ? posture : featureState));
                        getFeatureState(baseFeature)));
            }
        }
        return features;
@@ -141,7 +132,6 @@ class SampleExtensionImpl extends StubExtension {
            mSettingsDisplayFeatureProducer.unregisterObserversIfNeeded();
        }

        onDevicePostureChanged();
        onDisplayFeaturesChanged();
    }
}
+1 −15
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ abstract class StubExtension implements ExtensionInterface {

    private ExtensionCallback mExtensionCallback;
    private final Set<Activity> mWindowLayoutChangeListenerActivities = new HashSet<>();
    private boolean mDeviceStateChangeListenerRegistered;

    StubExtension() {
    }
@@ -53,18 +52,6 @@ abstract class StubExtension implements ExtensionInterface {
        this.onListenersChanged();
    }

    @Override
    public void onDeviceStateListenersChanged(boolean isEmpty) {
        this.mDeviceStateChangeListenerRegistered = !isEmpty;
        this.onListenersChanged();
    }

    void updateDeviceState(ExtensionDeviceState newState) {
        if (this.mExtensionCallback != null) {
            mExtensionCallback.onDeviceStateChanged(newState);
        }
    }

    void updateWindowLayout(@NonNull Activity activity,
            @NonNull ExtensionWindowLayoutInfo newLayout) {
        if (this.mExtensionCallback != null) {
@@ -78,8 +65,7 @@ abstract class StubExtension implements ExtensionInterface {
    }

    protected boolean hasListeners() {
        return !mWindowLayoutChangeListenerActivities.isEmpty()
                || mDeviceStateChangeListenerRegistered;
        return !mWindowLayoutChangeListenerActivities.isEmpty();
    }

    protected abstract void onListenersChanged();