Loading libs/WindowManager/Jetpack/src/androidx/window/common/CommonFoldingFeature.java +3 −2 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public final class CommonFoldingFeature { /** * The possible states for a folding hinge. */ @IntDef({COMMON_STATE_FLAT, COMMON_STATE_HALF_OPENED}) @IntDef({COMMON_STATE_UNKNOWN, COMMON_STATE_FLAT, COMMON_STATE_HALF_OPENED}) @Retention(RetentionPolicy.SOURCE) public @interface State { } Loading Loading @@ -236,7 +236,8 @@ public final class CommonFoldingFeature { } private static void assertValidState(@Nullable Integer state) { if (state != null && state != COMMON_STATE_FLAT && state != COMMON_STATE_HALF_OPENED) { if (state != null && state != COMMON_STATE_FLAT && state != COMMON_STATE_HALF_OPENED && state != COMMON_STATE_UNKNOWN) { throw new IllegalArgumentException("Invalid state: " + state + "must be either COMMON_STATE_FLAT or COMMON_STATE_HALF_OPENED"); } Loading libs/WindowManager/Jetpack/src/androidx/window/common/SettingsDisplayFeatureProducer.java +17 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package androidx.window.common; import static androidx.window.common.CommonFoldingFeature.COMMON_STATE_FLAT; import static androidx.window.common.CommonFoldingFeature.COMMON_STATE_HALF_OPENED; import static androidx.window.common.CommonFoldingFeature.COMMON_STATE_UNKNOWN; import static androidx.window.common.CommonFoldingFeature.parseListFromString; Loading @@ -42,7 +44,10 @@ import java.util.Optional; public final class SettingsDisplayFeatureProducer extends BaseDataProducer<List<CommonFoldingFeature>> { private static final String DISPLAY_FEATURES = "display_features"; private static final String DEVICE_POSTURE = "device_posture"; private final Uri mDevicePostureUri = Settings.Global.getUriFor(DEVICE_POSTURE); private final Uri mDisplayFeaturesUri = Settings.Global.getUriFor(DISPLAY_FEATURES); Loading @@ -55,6 +60,15 @@ public final class SettingsDisplayFeatureProducer mObserver = new SettingsObserver(); } private int getPosture() { int posture = Settings.Global.getInt(mResolver, DEVICE_POSTURE, COMMON_STATE_UNKNOWN); if (posture == COMMON_STATE_HALF_OPENED || posture == COMMON_STATE_FLAT) { return posture; } else { return COMMON_STATE_UNKNOWN; } } @Override @NonNull public Optional<List<CommonFoldingFeature>> getData() { Loading @@ -66,7 +80,7 @@ public final class SettingsDisplayFeatureProducer if (TextUtils.isEmpty(displayFeaturesString)) { return Optional.of(Collections.emptyList()); } return Optional.of(parseListFromString(displayFeaturesString, COMMON_STATE_UNKNOWN)); return Optional.of(parseListFromString(displayFeaturesString, getPosture())); } /** Loading @@ -80,6 +94,7 @@ public final class SettingsDisplayFeatureProducer mRegisteredObservers = true; mResolver.registerContentObserver(mDisplayFeaturesUri, false /* notifyForDescendants */, mObserver /* ContentObserver */); mResolver.registerContentObserver(mDevicePostureUri, false, mObserver); } /** Loading @@ -101,7 +116,7 @@ public final class SettingsDisplayFeatureProducer @Override public void onChange(boolean selfChange, Uri uri) { if (mDisplayFeaturesUri.equals(uri)) { if (mDisplayFeaturesUri.equals(uri) || mDevicePostureUri.equals(uri)) { notifyDataChanged(); } } Loading Loading
libs/WindowManager/Jetpack/src/androidx/window/common/CommonFoldingFeature.java +3 −2 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public final class CommonFoldingFeature { /** * The possible states for a folding hinge. */ @IntDef({COMMON_STATE_FLAT, COMMON_STATE_HALF_OPENED}) @IntDef({COMMON_STATE_UNKNOWN, COMMON_STATE_FLAT, COMMON_STATE_HALF_OPENED}) @Retention(RetentionPolicy.SOURCE) public @interface State { } Loading Loading @@ -236,7 +236,8 @@ public final class CommonFoldingFeature { } private static void assertValidState(@Nullable Integer state) { if (state != null && state != COMMON_STATE_FLAT && state != COMMON_STATE_HALF_OPENED) { if (state != null && state != COMMON_STATE_FLAT && state != COMMON_STATE_HALF_OPENED && state != COMMON_STATE_UNKNOWN) { throw new IllegalArgumentException("Invalid state: " + state + "must be either COMMON_STATE_FLAT or COMMON_STATE_HALF_OPENED"); } Loading
libs/WindowManager/Jetpack/src/androidx/window/common/SettingsDisplayFeatureProducer.java +17 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package androidx.window.common; import static androidx.window.common.CommonFoldingFeature.COMMON_STATE_FLAT; import static androidx.window.common.CommonFoldingFeature.COMMON_STATE_HALF_OPENED; import static androidx.window.common.CommonFoldingFeature.COMMON_STATE_UNKNOWN; import static androidx.window.common.CommonFoldingFeature.parseListFromString; Loading @@ -42,7 +44,10 @@ import java.util.Optional; public final class SettingsDisplayFeatureProducer extends BaseDataProducer<List<CommonFoldingFeature>> { private static final String DISPLAY_FEATURES = "display_features"; private static final String DEVICE_POSTURE = "device_posture"; private final Uri mDevicePostureUri = Settings.Global.getUriFor(DEVICE_POSTURE); private final Uri mDisplayFeaturesUri = Settings.Global.getUriFor(DISPLAY_FEATURES); Loading @@ -55,6 +60,15 @@ public final class SettingsDisplayFeatureProducer mObserver = new SettingsObserver(); } private int getPosture() { int posture = Settings.Global.getInt(mResolver, DEVICE_POSTURE, COMMON_STATE_UNKNOWN); if (posture == COMMON_STATE_HALF_OPENED || posture == COMMON_STATE_FLAT) { return posture; } else { return COMMON_STATE_UNKNOWN; } } @Override @NonNull public Optional<List<CommonFoldingFeature>> getData() { Loading @@ -66,7 +80,7 @@ public final class SettingsDisplayFeatureProducer if (TextUtils.isEmpty(displayFeaturesString)) { return Optional.of(Collections.emptyList()); } return Optional.of(parseListFromString(displayFeaturesString, COMMON_STATE_UNKNOWN)); return Optional.of(parseListFromString(displayFeaturesString, getPosture())); } /** Loading @@ -80,6 +94,7 @@ public final class SettingsDisplayFeatureProducer mRegisteredObservers = true; mResolver.registerContentObserver(mDisplayFeaturesUri, false /* notifyForDescendants */, mObserver /* ContentObserver */); mResolver.registerContentObserver(mDevicePostureUri, false, mObserver); } /** Loading @@ -101,7 +116,7 @@ public final class SettingsDisplayFeatureProducer @Override public void onChange(boolean selfChange, Uri uri) { if (mDisplayFeaturesUri.equals(uri)) { if (mDisplayFeaturesUri.equals(uri) || mDevicePostureUri.equals(uri)) { notifyDataChanged(); } } Loading