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

Commit f82f2e5a authored by Kenneth Ford's avatar Kenneth Ford
Browse files

Moves DeviceState from the server to the client side.

Moving the DeviceState class to the client side allows us to use this
class on both sides, which can allow us to give more information to
the client instead of just the state identifier.

Bug: 293636629
Test: DeviceStateTest
Change-Id: Ib05b36889db45f3cc9027d66f4bf8f1d528592c9
parent 450c8a7e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.server.devicestate;
package android.hardware.devicestate;

import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STATE;
@@ -22,7 +22,6 @@ import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STA
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.hardware.devicestate.DeviceStateManager;

import com.android.internal.util.Preconditions;

@@ -38,9 +37,9 @@ import java.util.Objects;
 * state of the system. This is useful for variable-state devices, like foldable or rollable
 * devices, that can be configured by users into differing hardware states, which each may have a
 * different expected use case.
 * @hide
 *
 * @see DeviceStateProvider
 * @see DeviceStateManagerService
 * @see DeviceStateManager
 */
public final class DeviceState {
    /**
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ android_test {
        "androidx.test.rules",
        "frameworks-base-testutils",
        "mockito-target-minus-junit4",
        "platform-test-annotations",
        "testng",
    ],
    libs: ["android.test.runner"],
    platform_apis: true,
+4 −5
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.server.devicestate;
package android.hardware.devicestate;

import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STATE;
@@ -25,18 +25,17 @@ import static org.testng.Assert.assertThrows;

import android.platform.test.annotations.Presubmit;

import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
 * Unit tests for {@link DeviceState}.
 * Unit tests for {@link android.hardware.devicestate.DeviceState}.
 * <p/>
 * Run with <code>atest DeviceStateTest</code>.
 */
@Presubmit
@RunWith(AndroidJUnit4.class)
@RunWith(JUnit4.class)
public final class DeviceStateTest {
    @Test
    public void testConstruct() {
+2 −1
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@ package com.android.server.devicestate;
import static android.Manifest.permission.CONTROL_DEVICE_STATE;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.hardware.devicestate.DeviceState.FLAG_CANCEL_OVERRIDE_REQUESTS;
import static android.hardware.devicestate.DeviceStateManager.INVALID_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STATE;

import static com.android.server.devicestate.DeviceState.FLAG_CANCEL_OVERRIDE_REQUESTS;
import static com.android.server.devicestate.OverrideRequest.OVERRIDE_REQUEST_TYPE_BASE_STATE;
import static com.android.server.devicestate.OverrideRequest.OVERRIDE_REQUEST_TYPE_EMULATED_STATE;
import static com.android.server.devicestate.OverrideRequestController.FLAG_POWER_SAVE_ENABLED;
@@ -40,6 +40,7 @@ import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.IProcessObserver;
import android.content.Context;
import android.hardware.devicestate.DeviceState;
import android.hardware.devicestate.DeviceStateInfo;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateManagerInternal;
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.devicestate;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.hardware.devicestate.DeviceState;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateRequest;
import android.os.Binder;
Loading