Loading core/api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -5006,7 +5006,7 @@ package android.hardware.devicestate { } public static interface DeviceStateManager.DeviceStateCallback { method public default void onDeviceStateChanged(@NonNull android.hardware.devicestate.DeviceState); method public void onDeviceStateChanged(@NonNull android.hardware.devicestate.DeviceState); method public default void onSupportedStatesChanged(@NonNull java.util.List<android.hardware.devicestate.DeviceState>); } core/api/test-current.txt +19 −7 Original line number Diff line number Diff line Loading @@ -1625,25 +1625,37 @@ package android.hardware.camera2.params { package android.hardware.devicestate { @FlaggedApi("android.hardware.devicestate.feature.flags.device_state_property_api") public final class DeviceState { ctor public DeviceState(@NonNull android.hardware.devicestate.DeviceState.Configuration); field public static final int PROPERTY_POLICY_AVAILABLE_FOR_APP_REQUEST = 8; // 0x8 } public static final class DeviceState.Configuration implements android.os.Parcelable { method public int describeContents(); method public int getIdentifier(); method @NonNull public String getName(); method @NonNull public java.util.Set<java.lang.Integer> getPhysicalProperties(); method @NonNull public java.util.Set<java.lang.Integer> getSystemProperties(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.hardware.devicestate.DeviceState.Configuration> CREATOR; } public static final class DeviceState.Configuration.Builder { ctor public DeviceState.Configuration.Builder(int, @NonNull String); method @NonNull public android.hardware.devicestate.DeviceState.Configuration build(); method @NonNull public android.hardware.devicestate.DeviceState.Configuration.Builder setPhysicalProperties(@NonNull java.util.Set<java.lang.Integer>); method @NonNull public android.hardware.devicestate.DeviceState.Configuration.Builder setSystemProperties(@NonNull java.util.Set<java.lang.Integer>); } @FlaggedApi("android.hardware.devicestate.feature.flags.device_state_property_api") public final class DeviceStateManager { method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE) public void cancelBaseStateOverride(); method @RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true) public void cancelStateRequest(); method @Deprecated @NonNull public int[] getSupportedStates(); method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE) public void requestBaseStateOverride(@NonNull android.hardware.devicestate.DeviceStateRequest, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.devicestate.DeviceStateRequest.Callback); method @RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true) public void requestState(@NonNull android.hardware.devicestate.DeviceStateRequest, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.devicestate.DeviceStateRequest.Callback); field public static final int INVALID_DEVICE_STATE_IDENTIFIER = -1; // 0xffffffff field public static final int MAXIMUM_DEVICE_STATE_IDENTIFIER = 10000; // 0x2710 field public static final int MINIMUM_DEVICE_STATE_IDENTIFIER = 0; // 0x0 } public static interface DeviceStateManager.DeviceStateCallback { method @Deprecated public default void onBaseStateChanged(int); method @Deprecated public void onStateChanged(int); method @Deprecated public default void onSupportedStatesChanged(@NonNull int[]); } public final class DeviceStateRequest { method public int getFlags(); method public int getState(); Loading core/java/android/hardware/camera2/CameraManager.java +6 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.hardware.camera2.params.StreamConfiguration; import android.hardware.camera2.utils.CameraIdAndSessionConfiguration; import android.hardware.camera2.utils.ConcurrentCameraIdCombination; import android.hardware.camera2.utils.ExceptionUtils; import android.hardware.devicestate.DeviceState; import android.hardware.devicestate.DeviceStateManager; import android.hardware.display.DisplayManager; import android.os.Binder; Loading Loading @@ -204,14 +205,12 @@ public final class CameraManager { mDeviceStateListeners.add(new WeakReference<>(listener)); } @SuppressWarnings("FlaggedApi") @Override public final void onBaseStateChanged(int state) { handleStateChange(state); } @Override public final void onStateChanged(int state) { handleStateChange(state); public void onDeviceStateChanged(DeviceState state) { // Suppressing the FlaggedAPI warning as this specific API isn't new, just moved to // system API which requires it to be flagged. handleStateChange(state.getIdentifier()); } } Loading core/java/android/hardware/devicestate/DeviceState.java +13 −129 Original line number Diff line number Diff line Loading @@ -51,78 +51,6 @@ import java.util.Set; @SystemApi @FlaggedApi(android.hardware.devicestate.feature.flags.Flags.FLAG_DEVICE_STATE_PROPERTY_API) public final class DeviceState { /** * Flag that indicates override requests should be cancelled when this device state becomes the * base device state. * @hide * @deprecated use {@link #PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS} */ @Deprecated public static final int FLAG_CANCEL_OVERRIDE_REQUESTS = 1 << 0; /** * Flag that indicates this device state is inaccessible for applications to be placed in. This * could be a device-state where the {@link Display#DEFAULT_DISPLAY} is not enabled. * @hide * @deprecated use {@link #PROPERTY_APP_INACCESSIBLE} */ @Deprecated public static final int FLAG_APP_INACCESSIBLE = 1 << 1; /** * Some device states can be both entered through a physical configuration as well as emulation * through {@link DeviceStateManager#requestState}, while some states can only be entered * through emulation and have no physical configuration to match. * * This flag indicates that the corresponding state can only be entered through emulation. * @hide * @deprecated use {@link #PROPERTY_EMULATED_ONLY} */ @Deprecated public static final int FLAG_EMULATED_ONLY = 1 << 2; /** * This flag indicates that the corresponding state should be automatically canceled when the * requesting app is no longer on top. The app is considered not on top when (1) the top * activity in the system is from a different app, (2) the device is in sleep mode, or * (3) the keyguard shows up. * @hide * @deprecated use {@link #PROPERTY_POLICY_CANCEL_WHEN_REQUESTER_NOT_ON_TOP} */ @Deprecated public static final int FLAG_CANCEL_WHEN_REQUESTER_NOT_ON_TOP = 1 << 3; /** * This flag indicates that the corresponding state should be disabled when the device is * overheating and reaching the critical status. * @hide * @deprecated use {@link #PROPERTY_POLICY_UNSUPPORTED_WHEN_THERMAL_STATUS_CRITICAL} */ @Deprecated public static final int FLAG_UNSUPPORTED_WHEN_THERMAL_STATUS_CRITICAL = 1 << 4; /** * This flag indicates that the corresponding state should be disabled when power save mode * is enabled. * @hide * @deprecated use {@link #PROPERTY_POLICY_UNSUPPORTED_WHEN_POWER_SAVE_MODE} */ @Deprecated public static final int FLAG_UNSUPPORTED_WHEN_POWER_SAVE_MODE = 1 << 5; /** @hide */ @IntDef(prefix = {"FLAG_"}, flag = true, value = { FLAG_CANCEL_OVERRIDE_REQUESTS, FLAG_APP_INACCESSIBLE, FLAG_EMULATED_ONLY, FLAG_CANCEL_WHEN_REQUESTER_NOT_ON_TOP, FLAG_UNSUPPORTED_WHEN_THERMAL_STATUS_CRITICAL, FLAG_UNSUPPORTED_WHEN_POWER_SAVE_MODE }) @Deprecated @Retention(RetentionPolicy.SOURCE) public @interface DeviceStateFlags {} /** * Property that indicates that a fold-in style foldable device is currently in a fully closed * configuration. Loading Loading @@ -302,42 +230,11 @@ public final class DeviceState { @NonNull private final DeviceState.Configuration mDeviceStateConfiguration; @DeviceStateFlags private final int mFlags; /** @hide */ @TestApi public DeviceState(@NonNull DeviceState.Configuration deviceStateConfiguration) { Objects.requireNonNull(deviceStateConfiguration, "Device StateConfiguration is null"); mDeviceStateConfiguration = deviceStateConfiguration; mFlags = 0; } /** @hide */ public DeviceState( @IntRange(from = MINIMUM_DEVICE_STATE_IDENTIFIER, to = MAXIMUM_DEVICE_STATE_IDENTIFIER) int identifier, @NonNull String name, @NonNull Set<@DeviceStateProperties Integer> properties) { mDeviceStateConfiguration = new DeviceState.Configuration(identifier, name, properties, Collections.emptySet()); mFlags = 0; } /** * @deprecated Deprecated in favor of {@link #DeviceState(int, String, Set)} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @Deprecated public DeviceState( @IntRange(from = MINIMUM_DEVICE_STATE_IDENTIFIER, to = MAXIMUM_DEVICE_STATE_IDENTIFIER) int identifier, @NonNull String name, @DeviceStateFlags int flags) { mDeviceStateConfiguration = new DeviceState.Configuration(identifier, name, Collections.emptySet(), Collections.emptySet()); mFlags = flags; } /** Returns the unique identifier for the device state. */ Loading @@ -352,17 +249,6 @@ public final class DeviceState { return mDeviceStateConfiguration.getName(); } /** * @hide * @deprecated in favor of {@link #hasProperty(int)} method */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @Deprecated @DeviceStateFlags public int getFlags() { return mFlags; } @Override public String toString() { return "DeviceState{" + "identifier=" + mDeviceStateConfiguration.getIdentifier() Loading @@ -388,16 +274,6 @@ public final class DeviceState { return Objects.hash(mDeviceStateConfiguration); } /** Checks if a specific flag is set * @hide * @deprecated in favor of {@link #hasProperty(int)} */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @Deprecated public boolean hasFlag(int flagToCheckFor) { return (mFlags & flagToCheckFor) == flagToCheckFor; } /** * Checks if a specific property is set on this state */ Loading Loading @@ -438,6 +314,7 @@ public final class DeviceState { * @see DeviceStateManager * @hide */ @TestApi public static final class Configuration implements Parcelable { /** Unique identifier for the device state. */ @IntRange(from = MINIMUM_DEVICE_STATE_IDENTIFIER, to = MAXIMUM_DEVICE_STATE_IDENTIFIER) Loading Loading @@ -563,29 +440,35 @@ public final class DeviceState { }; /** @hide */ public static class Builder { @TestApi public static final class Builder { private final int mIdentifier; @NonNull private final String mName; @NonNull private Set<@SystemDeviceStateProperties Integer> mSystemProperties = Collections.emptySet(); @NonNull private Set<@PhysicalDeviceStateProperties Integer> mPhysicalProperties = Collections.emptySet(); public Builder(int identifier, String name) { public Builder(int identifier, @NonNull String name) { mIdentifier = identifier; mName = name; } /** Sets the system properties for this {@link DeviceState.Configuration.Builder} */ @NonNull public Builder setSystemProperties( Set<@SystemDeviceStateProperties Integer> systemProperties) { @NonNull Set<@SystemDeviceStateProperties Integer> systemProperties) { mSystemProperties = systemProperties; return this; } /** Sets the system properties for this {@link DeviceState.Configuration.Builder} */ @NonNull public Builder setPhysicalProperties( Set<@PhysicalDeviceStateProperties Integer> physicalProperties) { @NonNull Set<@PhysicalDeviceStateProperties Integer> physicalProperties) { mPhysicalProperties = physicalProperties; return this; } Loading @@ -594,6 +477,7 @@ public final class DeviceState { * Returns a new {@link DeviceState.Configuration} whose values match the values set on * the builder. */ @NonNull public DeviceState.Configuration build() { return new DeviceState.Configuration(mIdentifier, mName, mSystemProperties, mPhysicalProperties); Loading core/java/android/hardware/devicestate/DeviceStateManager.java +2 −72 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ public final class DeviceStateManager { * * @hide */ @TestApi public static final int INVALID_DEVICE_STATE_IDENTIFIER = -1; /** Loading Loading @@ -93,20 +94,6 @@ public final class DeviceStateManager { mGlobal = global; } /** * Returns the list of device states that are supported and can be requested with * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. * @deprecated use {@link #getSupportedDeviceStates()} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated @NonNull public int[] getSupportedStates() { return mGlobal.getSupportedStates(); } /** * Returns the list of device states that are supported and can be requested with * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. Loading Loading @@ -233,23 +220,6 @@ public final class DeviceStateManager { /** Callback to receive notifications about changes in device state. */ public interface DeviceStateCallback { /** * Called in response to a change in the states supported by the device. * <p> * Guaranteed to be called once on registration of the callback with the initial value and * then on every subsequent change in the supported states. * * @param supportedStates the new supported states. * * @see DeviceStateManager#getSupportedStates() * @deprecated use {@link #onSupportedStatesChanged(List)} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated default void onSupportedStatesChanged(@NonNull int[] supportedStates) {} /** * Called in response to a change in the states supported by the device. * <p> Loading @@ -266,42 +236,6 @@ public final class DeviceStateManager { */ default void onSupportedStatesChanged(@NonNull List<DeviceState> supportedStates) {} /** * Called in response to a change in the base device state. * <p> * The base state is the state of the device without considering any requests made through * calls to {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)} * from any client process. The base state is guaranteed to match the state provided with a * call to {@link #onStateChanged(int)} when there are no active requests from any process. * <p> * Guaranteed to be called once on registration of the callback with the initial value and * then on every subsequent change in the non-override state. * * @param state the new base device state. * @deprecated use {@link #onDeviceStateChanged(DeviceState)} and query for physical * properties that are relevant to your needs. * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated default void onBaseStateChanged(int state) {} /** * Called in response to device state changes. * <p> * Guaranteed to be called once on registration of the callback with the initial value and * then on every subsequent change in device state. * * @param state the new device state. * @deprecated use {@link #onDeviceStateChanged(DeviceState)} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated void onStateChanged(int state); /** * Called in response to device state changes. * <p> Loading @@ -310,8 +244,7 @@ public final class DeviceStateManager { * * @param state the new device state. */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. default void onDeviceStateChanged(@NonNull DeviceState state) {} void onDeviceStateChanged(@NonNull DeviceState state); } /** Loading Loading @@ -339,9 +272,6 @@ public final class DeviceStateManager { mFeatureFlags = new android.hardware.devicestate.feature.flags.FeatureFlagsImpl(); } @Override public final void onStateChanged(int state) {} @Override public final void onDeviceStateChanged(@NonNull DeviceState deviceState) { final boolean folded; Loading Loading
core/api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -5006,7 +5006,7 @@ package android.hardware.devicestate { } public static interface DeviceStateManager.DeviceStateCallback { method public default void onDeviceStateChanged(@NonNull android.hardware.devicestate.DeviceState); method public void onDeviceStateChanged(@NonNull android.hardware.devicestate.DeviceState); method public default void onSupportedStatesChanged(@NonNull java.util.List<android.hardware.devicestate.DeviceState>); }
core/api/test-current.txt +19 −7 Original line number Diff line number Diff line Loading @@ -1625,25 +1625,37 @@ package android.hardware.camera2.params { package android.hardware.devicestate { @FlaggedApi("android.hardware.devicestate.feature.flags.device_state_property_api") public final class DeviceState { ctor public DeviceState(@NonNull android.hardware.devicestate.DeviceState.Configuration); field public static final int PROPERTY_POLICY_AVAILABLE_FOR_APP_REQUEST = 8; // 0x8 } public static final class DeviceState.Configuration implements android.os.Parcelable { method public int describeContents(); method public int getIdentifier(); method @NonNull public String getName(); method @NonNull public java.util.Set<java.lang.Integer> getPhysicalProperties(); method @NonNull public java.util.Set<java.lang.Integer> getSystemProperties(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.hardware.devicestate.DeviceState.Configuration> CREATOR; } public static final class DeviceState.Configuration.Builder { ctor public DeviceState.Configuration.Builder(int, @NonNull String); method @NonNull public android.hardware.devicestate.DeviceState.Configuration build(); method @NonNull public android.hardware.devicestate.DeviceState.Configuration.Builder setPhysicalProperties(@NonNull java.util.Set<java.lang.Integer>); method @NonNull public android.hardware.devicestate.DeviceState.Configuration.Builder setSystemProperties(@NonNull java.util.Set<java.lang.Integer>); } @FlaggedApi("android.hardware.devicestate.feature.flags.device_state_property_api") public final class DeviceStateManager { method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE) public void cancelBaseStateOverride(); method @RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true) public void cancelStateRequest(); method @Deprecated @NonNull public int[] getSupportedStates(); method @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE) public void requestBaseStateOverride(@NonNull android.hardware.devicestate.DeviceStateRequest, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.devicestate.DeviceStateRequest.Callback); method @RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true) public void requestState(@NonNull android.hardware.devicestate.DeviceStateRequest, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.devicestate.DeviceStateRequest.Callback); field public static final int INVALID_DEVICE_STATE_IDENTIFIER = -1; // 0xffffffff field public static final int MAXIMUM_DEVICE_STATE_IDENTIFIER = 10000; // 0x2710 field public static final int MINIMUM_DEVICE_STATE_IDENTIFIER = 0; // 0x0 } public static interface DeviceStateManager.DeviceStateCallback { method @Deprecated public default void onBaseStateChanged(int); method @Deprecated public void onStateChanged(int); method @Deprecated public default void onSupportedStatesChanged(@NonNull int[]); } public final class DeviceStateRequest { method public int getFlags(); method public int getState(); Loading
core/java/android/hardware/camera2/CameraManager.java +6 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.hardware.camera2.params.StreamConfiguration; import android.hardware.camera2.utils.CameraIdAndSessionConfiguration; import android.hardware.camera2.utils.ConcurrentCameraIdCombination; import android.hardware.camera2.utils.ExceptionUtils; import android.hardware.devicestate.DeviceState; import android.hardware.devicestate.DeviceStateManager; import android.hardware.display.DisplayManager; import android.os.Binder; Loading Loading @@ -204,14 +205,12 @@ public final class CameraManager { mDeviceStateListeners.add(new WeakReference<>(listener)); } @SuppressWarnings("FlaggedApi") @Override public final void onBaseStateChanged(int state) { handleStateChange(state); } @Override public final void onStateChanged(int state) { handleStateChange(state); public void onDeviceStateChanged(DeviceState state) { // Suppressing the FlaggedAPI warning as this specific API isn't new, just moved to // system API which requires it to be flagged. handleStateChange(state.getIdentifier()); } } Loading
core/java/android/hardware/devicestate/DeviceState.java +13 −129 Original line number Diff line number Diff line Loading @@ -51,78 +51,6 @@ import java.util.Set; @SystemApi @FlaggedApi(android.hardware.devicestate.feature.flags.Flags.FLAG_DEVICE_STATE_PROPERTY_API) public final class DeviceState { /** * Flag that indicates override requests should be cancelled when this device state becomes the * base device state. * @hide * @deprecated use {@link #PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS} */ @Deprecated public static final int FLAG_CANCEL_OVERRIDE_REQUESTS = 1 << 0; /** * Flag that indicates this device state is inaccessible for applications to be placed in. This * could be a device-state where the {@link Display#DEFAULT_DISPLAY} is not enabled. * @hide * @deprecated use {@link #PROPERTY_APP_INACCESSIBLE} */ @Deprecated public static final int FLAG_APP_INACCESSIBLE = 1 << 1; /** * Some device states can be both entered through a physical configuration as well as emulation * through {@link DeviceStateManager#requestState}, while some states can only be entered * through emulation and have no physical configuration to match. * * This flag indicates that the corresponding state can only be entered through emulation. * @hide * @deprecated use {@link #PROPERTY_EMULATED_ONLY} */ @Deprecated public static final int FLAG_EMULATED_ONLY = 1 << 2; /** * This flag indicates that the corresponding state should be automatically canceled when the * requesting app is no longer on top. The app is considered not on top when (1) the top * activity in the system is from a different app, (2) the device is in sleep mode, or * (3) the keyguard shows up. * @hide * @deprecated use {@link #PROPERTY_POLICY_CANCEL_WHEN_REQUESTER_NOT_ON_TOP} */ @Deprecated public static final int FLAG_CANCEL_WHEN_REQUESTER_NOT_ON_TOP = 1 << 3; /** * This flag indicates that the corresponding state should be disabled when the device is * overheating and reaching the critical status. * @hide * @deprecated use {@link #PROPERTY_POLICY_UNSUPPORTED_WHEN_THERMAL_STATUS_CRITICAL} */ @Deprecated public static final int FLAG_UNSUPPORTED_WHEN_THERMAL_STATUS_CRITICAL = 1 << 4; /** * This flag indicates that the corresponding state should be disabled when power save mode * is enabled. * @hide * @deprecated use {@link #PROPERTY_POLICY_UNSUPPORTED_WHEN_POWER_SAVE_MODE} */ @Deprecated public static final int FLAG_UNSUPPORTED_WHEN_POWER_SAVE_MODE = 1 << 5; /** @hide */ @IntDef(prefix = {"FLAG_"}, flag = true, value = { FLAG_CANCEL_OVERRIDE_REQUESTS, FLAG_APP_INACCESSIBLE, FLAG_EMULATED_ONLY, FLAG_CANCEL_WHEN_REQUESTER_NOT_ON_TOP, FLAG_UNSUPPORTED_WHEN_THERMAL_STATUS_CRITICAL, FLAG_UNSUPPORTED_WHEN_POWER_SAVE_MODE }) @Deprecated @Retention(RetentionPolicy.SOURCE) public @interface DeviceStateFlags {} /** * Property that indicates that a fold-in style foldable device is currently in a fully closed * configuration. Loading Loading @@ -302,42 +230,11 @@ public final class DeviceState { @NonNull private final DeviceState.Configuration mDeviceStateConfiguration; @DeviceStateFlags private final int mFlags; /** @hide */ @TestApi public DeviceState(@NonNull DeviceState.Configuration deviceStateConfiguration) { Objects.requireNonNull(deviceStateConfiguration, "Device StateConfiguration is null"); mDeviceStateConfiguration = deviceStateConfiguration; mFlags = 0; } /** @hide */ public DeviceState( @IntRange(from = MINIMUM_DEVICE_STATE_IDENTIFIER, to = MAXIMUM_DEVICE_STATE_IDENTIFIER) int identifier, @NonNull String name, @NonNull Set<@DeviceStateProperties Integer> properties) { mDeviceStateConfiguration = new DeviceState.Configuration(identifier, name, properties, Collections.emptySet()); mFlags = 0; } /** * @deprecated Deprecated in favor of {@link #DeviceState(int, String, Set)} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @Deprecated public DeviceState( @IntRange(from = MINIMUM_DEVICE_STATE_IDENTIFIER, to = MAXIMUM_DEVICE_STATE_IDENTIFIER) int identifier, @NonNull String name, @DeviceStateFlags int flags) { mDeviceStateConfiguration = new DeviceState.Configuration(identifier, name, Collections.emptySet(), Collections.emptySet()); mFlags = flags; } /** Returns the unique identifier for the device state. */ Loading @@ -352,17 +249,6 @@ public final class DeviceState { return mDeviceStateConfiguration.getName(); } /** * @hide * @deprecated in favor of {@link #hasProperty(int)} method */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @Deprecated @DeviceStateFlags public int getFlags() { return mFlags; } @Override public String toString() { return "DeviceState{" + "identifier=" + mDeviceStateConfiguration.getIdentifier() Loading @@ -388,16 +274,6 @@ public final class DeviceState { return Objects.hash(mDeviceStateConfiguration); } /** Checks if a specific flag is set * @hide * @deprecated in favor of {@link #hasProperty(int)} */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @Deprecated public boolean hasFlag(int flagToCheckFor) { return (mFlags & flagToCheckFor) == flagToCheckFor; } /** * Checks if a specific property is set on this state */ Loading Loading @@ -438,6 +314,7 @@ public final class DeviceState { * @see DeviceStateManager * @hide */ @TestApi public static final class Configuration implements Parcelable { /** Unique identifier for the device state. */ @IntRange(from = MINIMUM_DEVICE_STATE_IDENTIFIER, to = MAXIMUM_DEVICE_STATE_IDENTIFIER) Loading Loading @@ -563,29 +440,35 @@ public final class DeviceState { }; /** @hide */ public static class Builder { @TestApi public static final class Builder { private final int mIdentifier; @NonNull private final String mName; @NonNull private Set<@SystemDeviceStateProperties Integer> mSystemProperties = Collections.emptySet(); @NonNull private Set<@PhysicalDeviceStateProperties Integer> mPhysicalProperties = Collections.emptySet(); public Builder(int identifier, String name) { public Builder(int identifier, @NonNull String name) { mIdentifier = identifier; mName = name; } /** Sets the system properties for this {@link DeviceState.Configuration.Builder} */ @NonNull public Builder setSystemProperties( Set<@SystemDeviceStateProperties Integer> systemProperties) { @NonNull Set<@SystemDeviceStateProperties Integer> systemProperties) { mSystemProperties = systemProperties; return this; } /** Sets the system properties for this {@link DeviceState.Configuration.Builder} */ @NonNull public Builder setPhysicalProperties( Set<@PhysicalDeviceStateProperties Integer> physicalProperties) { @NonNull Set<@PhysicalDeviceStateProperties Integer> physicalProperties) { mPhysicalProperties = physicalProperties; return this; } Loading @@ -594,6 +477,7 @@ public final class DeviceState { * Returns a new {@link DeviceState.Configuration} whose values match the values set on * the builder. */ @NonNull public DeviceState.Configuration build() { return new DeviceState.Configuration(mIdentifier, mName, mSystemProperties, mPhysicalProperties); Loading
core/java/android/hardware/devicestate/DeviceStateManager.java +2 −72 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ public final class DeviceStateManager { * * @hide */ @TestApi public static final int INVALID_DEVICE_STATE_IDENTIFIER = -1; /** Loading Loading @@ -93,20 +94,6 @@ public final class DeviceStateManager { mGlobal = global; } /** * Returns the list of device states that are supported and can be requested with * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. * @deprecated use {@link #getSupportedDeviceStates()} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated @NonNull public int[] getSupportedStates() { return mGlobal.getSupportedStates(); } /** * Returns the list of device states that are supported and can be requested with * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. Loading Loading @@ -233,23 +220,6 @@ public final class DeviceStateManager { /** Callback to receive notifications about changes in device state. */ public interface DeviceStateCallback { /** * Called in response to a change in the states supported by the device. * <p> * Guaranteed to be called once on registration of the callback with the initial value and * then on every subsequent change in the supported states. * * @param supportedStates the new supported states. * * @see DeviceStateManager#getSupportedStates() * @deprecated use {@link #onSupportedStatesChanged(List)} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated default void onSupportedStatesChanged(@NonNull int[] supportedStates) {} /** * Called in response to a change in the states supported by the device. * <p> Loading @@ -266,42 +236,6 @@ public final class DeviceStateManager { */ default void onSupportedStatesChanged(@NonNull List<DeviceState> supportedStates) {} /** * Called in response to a change in the base device state. * <p> * The base state is the state of the device without considering any requests made through * calls to {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)} * from any client process. The base state is guaranteed to match the state provided with a * call to {@link #onStateChanged(int)} when there are no active requests from any process. * <p> * Guaranteed to be called once on registration of the callback with the initial value and * then on every subsequent change in the non-override state. * * @param state the new base device state. * @deprecated use {@link #onDeviceStateChanged(DeviceState)} and query for physical * properties that are relevant to your needs. * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated default void onBaseStateChanged(int state) {} /** * Called in response to device state changes. * <p> * Guaranteed to be called once on registration of the callback with the initial value and * then on every subsequent change in device state. * * @param state the new device state. * @deprecated use {@link #onDeviceStateChanged(DeviceState)} * @hide */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. @TestApi @Deprecated void onStateChanged(int state); /** * Called in response to device state changes. * <p> Loading @@ -310,8 +244,7 @@ public final class DeviceStateManager { * * @param state the new device state. */ // TODO(b/325124054): Make non-default and remove deprecated callback methods. default void onDeviceStateChanged(@NonNull DeviceState state) {} void onDeviceStateChanged(@NonNull DeviceState state); } /** Loading Loading @@ -339,9 +272,6 @@ public final class DeviceStateManager { mFeatureFlags = new android.hardware.devicestate.feature.flags.FeatureFlagsImpl(); } @Override public final void onStateChanged(int state) {} @Override public final void onDeviceStateChanged(@NonNull DeviceState deviceState) { final boolean folded; Loading