summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@google.com> 2024-01-24 13:56:37 -0700
committer Jeff Sharkey <jsharkey@google.com> 2024-01-24 16:12:20 -0700
commit221597ac607bd649aa89b8eefc8fb13d008ae307 (patch)
tree45ba074344e85892f441f7a04f32dd58a5c9ec68
parent63ab1df34253ca44f86d799ab9d908874987d99b (diff)
Misc baseline support for SysUI.
SysUI code relies on the straightforward Singleton, DisplayInfo, and PinResult classes, and working around them in SysUI would be quite disruptive, so this change supports them under Ravenwood, along with tests to confirm their behavior. Bug: 319647875 Test: atest FrameworksCoreTestsRavenwood Change-Id: Iea091bb09f6df9f8b23593871a805646a215ac0a
-rw-r--r--core/java/android/util/Singleton.java1
-rw-r--r--core/java/android/view/Display.java2
-rw-r--r--core/java/android/view/DisplayInfo.java1
-rw-r--r--core/java/com/android/internal/display/BrightnessSynchronizer.java2
-rw-r--r--core/tests/coretests/Android.bp2
-rw-r--r--core/tests/coretests/src/android/telephony/PinResultTest.java34
-rw-r--r--core/tests/coretests/src/android/util/SingletonTest.java41
-rw-r--r--core/tests/coretests/src/android/view/DisplayInfoTest.java6
-rw-r--r--ravenwood/framework-minus-apex-ravenwood-policies.txt3
-rw-r--r--ravenwood/ravenwood-annotation-allowed-classes.txt6
10 files changed, 98 insertions, 0 deletions
diff --git a/core/java/android/util/Singleton.java b/core/java/android/util/Singleton.java
index 92646b47cef2..d27bef9e9adc 100644
--- a/core/java/android/util/Singleton.java
+++ b/core/java/android/util/Singleton.java
@@ -25,6 +25,7 @@ import android.compat.annotation.UnsupportedAppUsage;
*
* @hide
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public abstract class Singleton<T> {
@UnsupportedAppUsage
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 1908c64ce42d..fbadef3d19ef 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -2079,6 +2079,7 @@ public final class Display {
*
* @see Display#getSupportedModes()
*/
+ @android.ravenwood.annotation.RavenwoodKeepWholeClass
public static final class Mode implements Parcelable {
/**
* @hide
@@ -2467,6 +2468,7 @@ public final class Display {
* <p>You can get an instance for a given {@link Display} object with
* {@link Display#getHdrCapabilities getHdrCapabilities()}.
*/
+ @android.ravenwood.annotation.RavenwoodKeepWholeClass
public static final class HdrCapabilities implements Parcelable {
/**
* Invalid luminance value.
diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java
index 981911ec8880..5654bc159568 100644
--- a/core/java/android/view/DisplayInfo.java
+++ b/core/java/android/view/DisplayInfo.java
@@ -51,6 +51,7 @@ import java.util.Objects;
* Describes the characteristics of a particular logical display.
* @hide
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class DisplayInfo implements Parcelable {
/**
* The surface flinger layer stack associated with this logical display.
diff --git a/core/java/com/android/internal/display/BrightnessSynchronizer.java b/core/java/com/android/internal/display/BrightnessSynchronizer.java
index 37aaa72cb7a0..006849034fbd 100644
--- a/core/java/com/android/internal/display/BrightnessSynchronizer.java
+++ b/core/java/com/android/internal/display/BrightnessSynchronizer.java
@@ -47,6 +47,7 @@ import java.io.PrintWriter;
* (new) system for storing the brightness. It has methods to convert between the two and also
* observes for when one of the settings is changed and syncs this with the other.
*/
+@android.ravenwood.annotation.RavenwoodKeepPartialClass
public class BrightnessSynchronizer {
private static final String TAG = "BrightnessSynchronizer";
@@ -282,6 +283,7 @@ public class BrightnessSynchronizer {
* @param b second float to compare
* @return whether the two values are within a small enough tolerance value
*/
+ @android.ravenwood.annotation.RavenwoodKeep
public static boolean floatEquals(float a, float b) {
if (a == b) {
return true;
diff --git a/core/tests/coretests/Android.bp b/core/tests/coretests/Android.bp
index 440630287b7c..3c56f76871b6 100644
--- a/core/tests/coretests/Android.bp
+++ b/core/tests/coretests/Android.bp
@@ -211,7 +211,9 @@ android_ravenwood_test {
srcs: [
"src/android/database/CursorWindowTest.java",
"src/android/os/**/*.java",
+ "src/android/telephony/PinResultTest.java",
"src/android/util/**/*.java",
+ "src/android/view/DisplayInfoTest.java",
"src/com/android/internal/logging/**/*.java",
"src/com/android/internal/os/**/*.java",
"src/com/android/internal/util/**/*.java",
diff --git a/core/tests/coretests/src/android/telephony/PinResultTest.java b/core/tests/coretests/src/android/telephony/PinResultTest.java
new file mode 100644
index 000000000000..c260807e5cbc
--- /dev/null
+++ b/core/tests/coretests/src/android/telephony/PinResultTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class PinResultTest {
+ @Test
+ public void testSimple() throws Exception {
+ final PinResult res = new PinResult(PinResult.PIN_RESULT_TYPE_SUCCESS, 5);
+ assertThat(res.getResult()).isEqualTo(PinResult.PIN_RESULT_TYPE_SUCCESS);
+ assertThat(res.getAttemptsRemaining()).isEqualTo(5);
+ }
+}
diff --git a/core/tests/coretests/src/android/util/SingletonTest.java b/core/tests/coretests/src/android/util/SingletonTest.java
new file mode 100644
index 000000000000..8c5a9639c23a
--- /dev/null
+++ b/core/tests/coretests/src/android/util/SingletonTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.util;
+
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class SingletonTest {
+ @Test
+ public void testSimple() throws Exception {
+ final Singleton<Object> singleton = new Singleton<>() {
+ @Override
+ protected Object create() {
+ return new Object();
+ }
+ };
+
+ final Object first = singleton.get();
+ final Object second = singleton.get();
+ assertTrue(first == second);
+ }
+}
diff --git a/core/tests/coretests/src/android/view/DisplayInfoTest.java b/core/tests/coretests/src/android/view/DisplayInfoTest.java
index 803d38c4208a..4c5b7e508e34 100644
--- a/core/tests/coretests/src/android/view/DisplayInfoTest.java
+++ b/core/tests/coretests/src/android/view/DisplayInfoTest.java
@@ -21,9 +21,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import android.platform.test.ravenwood.RavenwoodRule;
+
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +35,9 @@ import org.junit.runner.RunWith;
public class DisplayInfoTest {
private static final float FLOAT_EQUAL_DELTA = 0.0001f;
+ @Rule
+ public final RavenwoodRule mRavenwood = new RavenwoodRule();
+
@Test
public void testDefaultDisplayInfosAreEqual() {
DisplayInfo displayInfo1 = new DisplayInfo();
diff --git a/ravenwood/framework-minus-apex-ravenwood-policies.txt b/ravenwood/framework-minus-apex-ravenwood-policies.txt
index e33fff117d41..16f99e9289db 100644
--- a/ravenwood/framework-minus-apex-ravenwood-policies.txt
+++ b/ravenwood/framework-minus-apex-ravenwood-policies.txt
@@ -138,6 +138,9 @@ class com.android.modules.utils.TypedXmlSerializer stubclass
class android.net.Uri stubclass
class android.net.UriCodec stubclass
+# Telephony
+class android.telephony.PinResult stubclass
+
# Just enough to support mocking, no further functionality
class android.content.Context stub
method <init> ()V stub
diff --git a/ravenwood/ravenwood-annotation-allowed-classes.txt b/ravenwood/ravenwood-annotation-allowed-classes.txt
index 5700f000cbc5..b4b0beb49477 100644
--- a/ravenwood/ravenwood-annotation-allowed-classes.txt
+++ b/ravenwood/ravenwood-annotation-allowed-classes.txt
@@ -1,5 +1,6 @@
# Only classes listed here can use the Ravenwood annotations.
+com.android.internal.display.BrightnessSynchronizer
com.android.internal.util.ArrayUtils
com.android.internal.logging.MetricsLogger
com.android.internal.logging.testing.FakeMetricsLogger
@@ -31,6 +32,7 @@ android.util.LruCache
android.util.MonthDisplayHelper
android.util.RecurrenceRule
android.util.RotationUtils
+android.util.Singleton
android.util.Slog
android.util.SparseDoubleArray
android.util.SparseSetArray
@@ -134,6 +136,10 @@ android.content.ContentProvider
android.metrics.LogMaker
+android.view.Display$HdrCapabilities
+android.view.Display$Mode
+android.view.DisplayInfo
+
com.android.server.LocalServices
com.android.server.power.stats.BatteryStatsImpl