aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/Android.bp1
-rw-r--r--java/android/annotation/DurationMicrosLong.java36
-rw-r--r--java/com/android/modules/utils/build/testing/DeviceSdkLevel.java5
-rw-r--r--java/com/android/modules/utils/pm/PackageStateModulesUtils.java15
-rw-r--r--java/com/android/modules/utils/testing/Android.bp1
5 files changed, 52 insertions, 6 deletions
diff --git a/java/Android.bp b/java/Android.bp
index d1835f5..a872c41 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -102,6 +102,7 @@ filegroup {
"android/annotation/IntDef.java",
"android/annotation/SystemApi.java",
"android/annotation/TestApi.java",
+ "android/annotation/UserIdInt.java",
// aconfig annotations
"com/android/aconfig/annotations/*.java",
],
diff --git a/java/android/annotation/DurationMicrosLong.java b/java/android/annotation/DurationMicrosLong.java
new file mode 100644
index 0000000..621f601
--- /dev/null
+++ b/java/android/annotation/DurationMicrosLong.java
@@ -0,0 +1,36 @@
+/*
+ * 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.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * @memberDoc Value is a non-negative duration in microseconds.
+ * @paramDoc Value is a non-negative duration in microseconds.
+ * @returnDoc Value is a non-negative duration in microseconds.
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({METHOD, PARAMETER, FIELD})
+public @interface DurationMicrosLong {
+}
diff --git a/java/com/android/modules/utils/build/testing/DeviceSdkLevel.java b/java/com/android/modules/utils/build/testing/DeviceSdkLevel.java
index 041d6a5..2f76759 100644
--- a/java/com/android/modules/utils/build/testing/DeviceSdkLevel.java
+++ b/java/com/android/modules/utils/build/testing/DeviceSdkLevel.java
@@ -49,10 +49,9 @@ public final class DeviceSdkLevel {
return device.getApiLevel() >= 33;
}
- /** Checks if the device is running on a (pre-)release version of Android U or newer. */
+ /** Checks if the device is running on a release version of Android U or newer. */
public boolean isDeviceAtLeastU() throws DeviceNotAvailableException {
- return device.getApiLevel() >= 34 ||
- (device.getApiLevel() == 33 && isDeviceAtLeastPreReleaseCodename("UpsideDownCake"));
+ return device.getApiLevel() >= 34;
}
/** Checks if the device is running on a (pre-)release version of Android V or newer. */
diff --git a/java/com/android/modules/utils/pm/PackageStateModulesUtils.java b/java/com/android/modules/utils/pm/PackageStateModulesUtils.java
index 34fd16b..2944592 100644
--- a/java/com/android/modules/utils/pm/PackageStateModulesUtils.java
+++ b/java/com/android/modules/utils/pm/PackageStateModulesUtils.java
@@ -22,6 +22,7 @@ import android.text.TextUtils;
import androidx.annotation.RequiresApi;
+import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.AndroidPackageSplit;
import com.android.server.pm.pkg.PackageState;
@@ -35,8 +36,7 @@ public class PackageStateModulesUtils {
*/
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
public static boolean isDexoptable(@NonNull PackageState packageState) {
- if (packageState.isApex() || "android".equals(packageState.getPackageName())
- || packageState.getAppId() <= 0) {
+ if (packageState.isApex() || "android".equals(packageState.getPackageName())) {
return false;
}
@@ -45,6 +45,10 @@ public class PackageStateModulesUtils {
return false;
}
+ if ((packageState.getAppId() <= 0) && !isSdkLibrary(pkg)) {
+ return false;
+ }
+
List<AndroidPackageSplit> splits = pkg.getSplits();
for (int index = 0; index < splits.size(); index++) {
if (splits.get(index).isHasCode()) {
@@ -76,7 +80,7 @@ public class PackageStateModulesUtils {
return true;
}
- if (!TextUtils.isEmpty(pkg.getSdkLibraryName())) {
+ if (isSdkLibrary(pkg)) {
return true;
}
@@ -86,4 +90,9 @@ public class PackageStateModulesUtils {
return !codeOnly && pkg.isResourceOverlay();
}
+
+ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
+ private static boolean isSdkLibrary(AndroidPackage pkg) {
+ return !TextUtils.isEmpty(pkg.getSdkLibraryName());
+ }
}
diff --git a/java/com/android/modules/utils/testing/Android.bp b/java/com/android/modules/utils/testing/Android.bp
index f866d8d..6e6926f 100644
--- a/java/com/android/modules/utils/testing/Android.bp
+++ b/java/com/android/modules/utils/testing/Android.bp
@@ -59,6 +59,7 @@ java_library {
java_defaults {
name: "modules-utils-testable-device-config-defaults",
static_libs: ["modules-utils-testable-device-config"],
+ compile_multilib: "both",
defaults: ["modules-utils-extended-mockito-rule-defaults"],
defaults_visibility: ["//visibility:public"],
}