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 Original line Diff line number Diff line
@@ -69,21 +69,15 @@ class SampleExtensionImpl extends StubExtension {
                new ResourceConfigDisplayFeatureProducer(context)
                new ResourceConfigDisplayFeatureProducer(context)
        ));
        ));


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


    private void onDevicePostureChanged() {
    private int getFeatureState(DisplayFeature feature) {
        updateDeviceState(new ExtensionDeviceState(getDevicePosture()));
        Integer featureState = feature.getState();

        // 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() {
        Optional<Integer> posture = mDevicePostureProducer.getData();
        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() {
    private void onDisplayFeaturesChanged() {
@@ -115,17 +109,14 @@ class SampleExtensionImpl extends StubExtension {


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


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


                Integer featureState = baseFeature.getState();

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


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


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


    StubExtension() {
    StubExtension() {
    }
    }
@@ -53,18 +52,6 @@ abstract class StubExtension implements ExtensionInterface {
        this.onListenersChanged();
        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,
    void updateWindowLayout(@NonNull Activity activity,
            @NonNull ExtensionWindowLayoutInfo newLayout) {
            @NonNull ExtensionWindowLayoutInfo newLayout) {
        if (this.mExtensionCallback != null) {
        if (this.mExtensionCallback != null) {
@@ -78,8 +65,7 @@ abstract class StubExtension implements ExtensionInterface {
    }
    }


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


    protected abstract void onListenersChanged();
    protected abstract void onListenersChanged();