Update WindowManager Jetpack in SC
Update window-extensions aar. Update window-sidecar aar. Remove deprecated fields. Bug: 173739071 Test: Manual build with extensions, set a device state 3 Test: Set a dislay feature to go horizontally and run sample app Change-Id: I67f1b109aeb4202c7c531b074d2d6e89e1e8c831
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user