summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-30 20:47:51 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-30 20:47:51 +0000
commitccebdce6ec92ca555e1c3dde28e99e2772d1e0db (patch)
tree14c2b941eb6bc0c0b2d8ca1eae0e3dfb8619c496
parent98b6b3d990f0d7bc974177aa06ce98fb2c3a998c (diff)
parent2481ff4b245fc2333a68e10e1864449f385dbe87 (diff)
downloadAdServices-android14-qpr2-s1-release.tar.gz
Change-Id: Ie542db3f4bc2374215c65d46e7eb78b305ab2e05
-rw-r--r--sdksandbox/flags/sandbox_flags.aconfig7
-rw-r--r--sdksandbox/service/api/system-server-current.txt2
-rw-r--r--sdksandbox/service/java/com/android/server/sdksandbox/SdkSandboxManagerLocal.java5
-rw-r--r--sdksandbox/tests/inprocess/src/com/android/sdksandbox/inprocess/SdkSandboxInstrumentationTest.java9
4 files changed, 20 insertions, 3 deletions
diff --git a/sdksandbox/flags/sandbox_flags.aconfig b/sdksandbox/flags/sandbox_flags.aconfig
index 572647832..15cdf0ca5 100644
--- a/sdksandbox/flags/sandbox_flags.aconfig
+++ b/sdksandbox/flags/sandbox_flags.aconfig
@@ -20,3 +20,10 @@ flag {
bug: "295861450"
description: "Enables the SELinux domain sdk_sandbox_audit"
}
+
+flag {
+ name: "sdk_sandbox_instrumentation_info"
+ namespace: "sdk_sandbox"
+ bug: "315018061"
+ description: "Enables the getSdkSandboxApplicationInfoForInstrumentation API for tests"
+}
diff --git a/sdksandbox/service/api/system-server-current.txt b/sdksandbox/service/api/system-server-current.txt
index 5618688a8..5a763ce26 100644
--- a/sdksandbox/service/api/system-server-current.txt
+++ b/sdksandbox/service/api/system-server-current.txt
@@ -9,7 +9,7 @@ package com.android.server.sdksandbox {
method @Deprecated public void enforceAllowedToSendBroadcast(@NonNull android.content.Intent);
method public void enforceAllowedToStartActivity(@NonNull android.content.Intent);
method public void enforceAllowedToStartOrBindService(@NonNull android.content.Intent);
- method @NonNull public android.content.pm.ApplicationInfo getSdkSandboxApplicationInfoForInstrumentation(@NonNull android.content.pm.ApplicationInfo, boolean) throws android.content.pm.PackageManager.NameNotFoundException;
+ method @FlaggedApi("com.android.sdksandbox.flags.sdk_sandbox_instrumentation_info") @NonNull public android.content.pm.ApplicationInfo getSdkSandboxApplicationInfoForInstrumentation(@NonNull android.content.pm.ApplicationInfo, boolean) throws android.content.pm.PackageManager.NameNotFoundException;
method @NonNull public String getSdkSandboxProcessNameForInstrumentation(@NonNull android.content.pm.ApplicationInfo);
method public void notifyInstrumentationFinished(@NonNull String, int);
method public void notifyInstrumentationStarted(@NonNull String, int);
diff --git a/sdksandbox/service/java/com/android/server/sdksandbox/SdkSandboxManagerLocal.java b/sdksandbox/service/java/com/android/server/sdksandbox/SdkSandboxManagerLocal.java
index 1401acf03..6acbdad1f 100644
--- a/sdksandbox/service/java/com/android/server/sdksandbox/SdkSandboxManagerLocal.java
+++ b/sdksandbox/service/java/com/android/server/sdksandbox/SdkSandboxManagerLocal.java
@@ -16,9 +16,9 @@
package com.android.server.sdksandbox;
+import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SdkConstant;
-import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.content.Intent;
import android.content.IntentFilter;
@@ -27,6 +27,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ProviderInfo;
import android.os.IBinder;
+import com.android.sdksandbox.flags.Flags;
import com.android.tools.r8.keepanno.annotations.KeepForApi;
import com.android.tools.r8.keepanno.annotations.KeepItemKind;
import com.android.tools.r8.keepanno.annotations.KeepTarget;
@@ -148,8 +149,8 @@ public interface SdkSandboxManagerLocal {
* @return {@link ApplicationInfo} of the sdk sandbox process to be instrumented
* @throws NameNotFoundException if the sandbox package name cannot be found.
*/
- @SuppressLint("UnflaggedApi") // The API is only used for tests.
@NonNull
+ @FlaggedApi(Flags.FLAG_SDK_SANDBOX_INSTRUMENTATION_INFO)
ApplicationInfo getSdkSandboxApplicationInfoForInstrumentation(
@NonNull ApplicationInfo clientAppInfo, boolean isSdkInSandbox)
throws NameNotFoundException;
diff --git a/sdksandbox/tests/inprocess/src/com/android/sdksandbox/inprocess/SdkSandboxInstrumentationTest.java b/sdksandbox/tests/inprocess/src/com/android/sdksandbox/inprocess/SdkSandboxInstrumentationTest.java
index 7e9527bbb..112f2e2da 100644
--- a/sdksandbox/tests/inprocess/src/com/android/sdksandbox/inprocess/SdkSandboxInstrumentationTest.java
+++ b/sdksandbox/tests/inprocess/src/com/android/sdksandbox/inprocess/SdkSandboxInstrumentationTest.java
@@ -27,10 +27,15 @@ import android.app.Activity;
import android.app.sdksandbox.testutils.EmptyActivity;
import android.content.Context;
import android.os.Process;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
+import com.android.sdksandbox.flags.Flags;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -39,12 +44,16 @@ import org.junit.runners.JUnit4;
/** Tests for the instrumentation running the Sdk sanbdox tests. */
@RunWith(JUnit4.class)
+@RequiresFlagsEnabled(Flags.FLAG_SDK_SANDBOX_INSTRUMENTATION_INFO)
public class SdkSandboxInstrumentationTest {
private Context mContext;
private Context mTargetContext;
@Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
+ @Rule
public final ActivityTestRule mActivityRule =
new ActivityTestRule<>(
EmptyActivity.class,