Fix StrictModeTest#testNonSdkApiUsage
Test: atest android.os.cts.StrictModeTest#testNonSdkApiUsage
Bug: 131923046
Bug: 129892635
Merged-In: I6759339000eb239112c0c83ce1131f34164ee0cf
Change-Id: I6759339000eb239112c0c83ce1131f34164ee0cf
diff --git a/api/test-current.txt b/api/test-current.txt
index b1ffbad..dd11b83 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1916,6 +1916,10 @@
method public boolean hasSingleFileDescriptor();
}
+ public final class Parcel {
+ method public int readExceptionCode();
+ }
+
public class ParcelFileDescriptor implements java.io.Closeable android.os.Parcelable {
method public static java.io.File getFile(java.io.FileDescriptor) throws java.io.IOException;
}
@@ -1985,6 +1989,7 @@
public class SystemProperties {
method @NonNull public static String get(@NonNull String);
method @NonNull public static String get(@NonNull String, @Nullable String);
+ method public static boolean getBoolean(@NonNull String, boolean);
}
public final class UserHandle implements android.os.Parcelable {
@@ -2139,6 +2144,36 @@
}
+package android.os.image {
+
+ public class DynamicSystemClient {
+ ctor public DynamicSystemClient(@NonNull android.content.Context);
+ method @RequiresPermission("android.permission.INSTALL_DYNAMIC_SYSTEM") public void bind();
+ method public void setOnStatusChangedListener(@NonNull java.util.concurrent.Executor, @NonNull android.os.image.DynamicSystemClient.OnStatusChangedListener);
+ method public void setOnStatusChangedListener(@NonNull android.os.image.DynamicSystemClient.OnStatusChangedListener);
+ method @RequiresPermission("android.permission.INSTALL_DYNAMIC_SYSTEM") public void start(@NonNull android.net.Uri, long);
+ method @RequiresPermission("android.permission.INSTALL_DYNAMIC_SYSTEM") public void start(@NonNull android.net.Uri, long, long);
+ method @RequiresPermission("android.permission.INSTALL_DYNAMIC_SYSTEM") public void unbind();
+ field public static final int CAUSE_ERROR_EXCEPTION = 6; // 0x6
+ field public static final int CAUSE_ERROR_INVALID_URL = 4; // 0x4
+ field public static final int CAUSE_ERROR_IO = 3; // 0x3
+ field public static final int CAUSE_ERROR_IPC = 5; // 0x5
+ field public static final int CAUSE_INSTALL_CANCELLED = 2; // 0x2
+ field public static final int CAUSE_INSTALL_COMPLETED = 1; // 0x1
+ field public static final int CAUSE_NOT_SPECIFIED = 0; // 0x0
+ field public static final int STATUS_IN_PROGRESS = 2; // 0x2
+ field public static final int STATUS_IN_USE = 4; // 0x4
+ field public static final int STATUS_NOT_STARTED = 1; // 0x1
+ field public static final int STATUS_READY = 3; // 0x3
+ field public static final int STATUS_UNKNOWN = 0; // 0x0
+ }
+
+ public static interface DynamicSystemClient.OnStatusChangedListener {
+ method public void onStatusChanged(int, int, long, @Nullable Throwable);
+ }
+
+}
+
package android.os.storage {
public class StorageManager {
@@ -2930,6 +2965,21 @@
method public E valueAtUnchecked(int);
}
+ public class FeatureFlagUtils {
+ ctor public FeatureFlagUtils();
+ method public static java.util.Map<java.lang.String,java.lang.String> getAllFeatureFlags();
+ method public static boolean isEnabled(android.content.Context, String);
+ method public static void setEnabled(android.content.Context, String, boolean);
+ field public static final String DYNAMIC_SYSTEM = "settings_dynamic_system";
+ field public static final String FFLAG_OVERRIDE_PREFIX = "sys.fflag.override.";
+ field public static final String FFLAG_PREFIX = "sys.fflag.";
+ field public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid";
+ field public static final String PERSIST_PREFIX = "persist.sys.fflag.override.";
+ field public static final String PIXEL_WALLPAPER_CATEGORY_SWITCH = "settings_pixel_wallpaper_category_switch";
+ field public static final String SCREENRECORD_LONG_PRESS = "settings_screenrecord_long_press";
+ field public static final String SEAMLESS_TRANSFER = "settings_seamless_transfer";
+ }
+
public class TimeUtils {
method public static String formatDuration(long);
}
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index de963c9..fe2e948 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -18,6 +18,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -2001,6 +2002,7 @@
* @hide
*/
@UnsupportedAppUsage
+ @TestApi
public final int readExceptionCode() {
int code = readInt();
if (code == EX_HAS_REPLY_HEADER) {
diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java
index edfdda8..4538410 100644
--- a/core/java/android/os/SystemProperties.java
+++ b/core/java/android/os/SystemProperties.java
@@ -174,6 +174,7 @@
* @hide
*/
@SystemApi
+ @TestApi
public static boolean getBoolean(@NonNull String key, boolean def) {
if (TRACK_KEY_ACCESS) onKeyAccess(key);
return native_get_boolean(key, def);
diff --git a/core/java/android/os/image/DynamicSystemClient.java b/core/java/android/os/image/DynamicSystemClient.java
index f1f24fb..921f0f2 100644
--- a/core/java/android/os/image/DynamicSystemClient.java
+++ b/core/java/android/os/image/DynamicSystemClient.java
@@ -22,6 +22,7 @@
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -67,6 +68,7 @@
* @hide
*/
@SystemApi
+@TestApi
public class DynamicSystemClient {
/** @hide */
@IntDef(prefix = { "STATUS_" }, value = {
@@ -283,6 +285,7 @@
* @hide
*/
@SystemApi
+ @TestApi
public DynamicSystemClient(@NonNull Context context) {
mContext = context;
mConnection = new DynSystemServiceConnection();
@@ -314,8 +317,11 @@
* Bind to {@code DynamicSystem} installation service. Binding to the installation service
* allows it to send status updates to {@link #OnStatusChangedListener}. It is recommanded
* to bind before calling {@link #start} and get status updates.
+ * @hide
*/
@RequiresPermission(android.Manifest.permission.INSTALL_DYNAMIC_SYSTEM)
+ @SystemApi
+ @TestApi
public void bind() {
if (!featureFlagEnabled()) {
Slog.w(TAG, FeatureFlagUtils.DYNAMIC_SYSTEM + " not enabled; bind() aborted.");
@@ -334,8 +340,11 @@
/**
* Unbind from {@code DynamicSystem} installation service. Unbinding from the installation
* service stops it from sending following status updates.
+ * @hide
*/
@RequiresPermission(android.Manifest.permission.INSTALL_DYNAMIC_SYSTEM)
+ @SystemApi
+ @TestApi
public void unbind() {
if (!mBound) {
return;
@@ -367,8 +376,11 @@
*
* @param systemUrl a network Uri, a file Uri or a content Uri pointing to a system image file.
* @param systemSize size of system image.
+ * @hide
*/
@RequiresPermission(android.Manifest.permission.INSTALL_DYNAMIC_SYSTEM)
+ @SystemApi
+ @TestApi
public void start(@NonNull Uri systemUrl, @BytesLong long systemSize) {
start(systemUrl, systemSize, DEFAULT_USERDATA_SIZE);
}
diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java
index c42dc81..324e02c 100644
--- a/core/java/android/util/FeatureFlagUtils.java
+++ b/core/java/android/util/FeatureFlagUtils.java
@@ -16,6 +16,7 @@
package android.util;
+import android.annotation.TestApi;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.Settings;
@@ -29,6 +30,7 @@
*
* @hide
*/
+@TestApi
public class FeatureFlagUtils {
public static final String FFLAG_PREFIX = "sys.fflag.";