Merge "Fix OEMs unable to get config_supportsBubble" into stage-aosp-tm-ts-dev
diff --git a/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/bluetooth/Bluetooth.java b/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/bluetooth/Bluetooth.java
index 30a642e..4b9e87e 100644
--- a/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/bluetooth/Bluetooth.java
+++ b/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/bluetooth/Bluetooth.java
@@ -17,6 +17,7 @@
package com.android.bedstead.nene.bluetooth;
import static android.os.Build.VERSION_CODES.R;
+import static android.os.Process.BLUETOOTH_UID;
import static com.android.bedstead.nene.permissions.CommonPermissions.BLUETOOTH;
import static com.android.bedstead.nene.permissions.CommonPermissions.BLUETOOTH_CONNECT;
@@ -25,21 +26,24 @@
import static com.android.bedstead.nene.permissions.CommonPermissions.NETWORK_SETTINGS;
import static com.android.bedstead.nene.utils.Versions.T;
-import static com.google.common.truth.Truth.assertThat;
-
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.UserHandle;
import com.android.bedstead.nene.TestApis;
+import com.android.bedstead.nene.annotations.Experimental;
+import com.android.bedstead.nene.exceptions.NeneException;
import com.android.bedstead.nene.permissions.PermissionContext;
import com.android.bedstead.nene.utils.Poll;
+import com.android.bedstead.nene.utils.Versions;
import com.android.compatibility.common.util.BlockingBroadcastReceiver;
/** Test APIs related to bluetooth. */
public final class Bluetooth {
-
public static final Bluetooth sInstance = new Bluetooth();
private static final Context sContext = TestApis.context().instrumentedContext();
@@ -47,90 +51,130 @@
sContext.getSystemService(BluetoothManager.class);
private static final BluetoothAdapter sBluetoothAdapter = sBluetoothManager.getAdapter();
- private Bluetooth() {
- }
+ private Bluetooth() {}
/** Enable or disable bluetooth on the device. */
public void setEnabled(boolean enabled) {
- if (isEnabled() == enabled) {
- return;
- }
+ if (isEnabled() == enabled) {
+ return;
+ }
- if (enabled) {
- enable();
- } else {
- disable();
- }
+ if (enabled) {
+ enable();
+ } else {
+ disable();
+ }
}
private void enable() {
- try (PermissionContext p =
- TestApis.permissions()
- .withPermission(BLUETOOTH_CONNECT, INTERACT_ACROSS_USERS_FULL,
- BLUETOOTH_PRIVILEGED)
- .withPermissionOnVersionAtLeast(T, NETWORK_SETTINGS)) {
- BlockingBroadcastReceiver r = BlockingBroadcastReceiver.create(
- sContext,
- BluetoothAdapter.ACTION_STATE_CHANGED,
- this::isStateEnabled).register();
+ try (PermissionContext p = TestApis.permissions()
+ .withPermission(BLUETOOTH_CONNECT,
+ INTERACT_ACROSS_USERS_FULL, BLUETOOTH_PRIVILEGED)
+ .withPermissionOnVersionAtLeast(T, NETWORK_SETTINGS)) {
+ BlockingBroadcastReceiver r =
+ BlockingBroadcastReceiver
+ .create(sContext, BluetoothAdapter.ACTION_STATE_CHANGED,
+ this::isStateEnabled)
+ .register();
- try {
- boolean returnValue = sBluetoothAdapter.enable();
+ try {
+ boolean returnValue = sBluetoothAdapter.enable();
- r.awaitForBroadcast();
- Poll.forValue("Bluetooth Enabled", this::isEnabled)
- .toBeEqualTo(true)
- .errorOnFail("Waited for bluetooth to be enabled."
- + " .enable() returned " + returnValue)
- .await();
- } finally {
- r.unregisterQuietly();
- }
+ r.awaitForBroadcast();
+ Poll.forValue("Bluetooth Enabled", this::isEnabled)
+ .toBeEqualTo(true)
+ .errorOnFail("Waited for bluetooth to be enabled."
+ + " .enable() returned " + returnValue)
+ .await();
+ } finally {
+ r.unregisterQuietly();
}
-
+ }
}
private void disable() {
- try (PermissionContext p =
- TestApis.permissions()
- .withPermission(BLUETOOTH_CONNECT, INTERACT_ACROSS_USERS_FULL,
- BLUETOOTH_PRIVILEGED)
- .withPermissionOnVersionAtLeast(T, NETWORK_SETTINGS)) {
- BlockingBroadcastReceiver r = BlockingBroadcastReceiver.create(
- sContext,
- BluetoothAdapter.ACTION_STATE_CHANGED,
- this::isStateDisabled).register();
+ try (PermissionContext p = TestApis.permissions()
+ .withPermission(BLUETOOTH_CONNECT,
+ INTERACT_ACROSS_USERS_FULL, BLUETOOTH_PRIVILEGED)
+ .withPermissionOnVersionAtLeast(T, NETWORK_SETTINGS)) {
+ BlockingBroadcastReceiver r =
+ BlockingBroadcastReceiver
+ .create(sContext, BluetoothAdapter.ACTION_STATE_CHANGED,
+ this::isStateDisabled)
+ .register();
- try {
- boolean returnValue = sBluetoothAdapter.disable();
+ try {
+ boolean returnValue = sBluetoothAdapter.disable();
- r.awaitForBroadcast();
- Poll.forValue("Bluetooth Enabled", this::isEnabled)
- .toBeEqualTo(false)
- .errorOnFail("Waited for bluetooth to be disabled."
- + " .disable() returned " + returnValue)
- .await();
- } finally {
- r.unregisterQuietly();
- }
+ r.awaitForBroadcast();
+ Poll.forValue("Bluetooth Enabled", this::isEnabled)
+ .toBeEqualTo(false)
+ .errorOnFail("Waited for bluetooth to be disabled."
+ + " .disable() returned " + returnValue)
+ .await();
+ } finally {
+ r.unregisterQuietly();
}
+ }
}
/** {@code true} if bluetooth is enabled. */
public boolean isEnabled() {
- try (PermissionContext p =
- TestApis.permissions().withPermissionOnVersionAtMost(R, BLUETOOTH)) {
- return sBluetoothAdapter.isEnabled();
- }
+ try (PermissionContext p =
+ TestApis.permissions().withPermissionOnVersionAtMost(R, BLUETOOTH)) {
+ return sBluetoothAdapter.isEnabled();
+ }
}
private boolean isStateEnabled(Intent intent) {
- return intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)
- == BluetoothAdapter.STATE_ON;
+ return intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_ON;
}
private boolean isStateDisabled(Intent intent) {
- return intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)
- == BluetoothAdapter.STATE_OFF;
+ return intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_OFF;
+ }
+
+ /** The bluetooth UID is associated with multiple packages. Get the main one. */
+ @Experimental
+ public String findPackageName() {
+ if (!Versions.meetsMinimumSdkVersionRequirement(T)) {
+ return "com.android.bluetooth";
+ }
+ // this activity will always be in the package where the rest of Bluetooth lives
+ var sentinelActivity = "com.android.bluetooth.opp.BluetoothOppLauncherActivity";
+ var packageManager = sContext.createContextAsUser(UserHandle.SYSTEM, 0).getPackageManager();
+ var allPackages = packageManager.getPackagesForUid(BLUETOOTH_UID);
+ String matchedPackage = null;
+ for (String candidatePackage : allPackages) {
+ PackageInfo packageInfo;
+ try {
+ packageInfo =
+ packageManager.getPackageInfo(
+ candidatePackage,
+ PackageManager.GET_ACTIVITIES
+ | PackageManager.MATCH_ANY_USER
+ | PackageManager.MATCH_UNINSTALLED_PACKAGES
+ | PackageManager.MATCH_DISABLED_COMPONENTS);
+ } catch (PackageManager.NameNotFoundException e) {
+ // rethrow
+ throw new NeneException(e);
+ }
+ if (packageInfo.activities == null) {
+ continue;
+ }
+ for (var activity : packageInfo.activities) {
+ if (sentinelActivity.equals(activity.name)) {
+ if (matchedPackage == null) {
+ matchedPackage = candidatePackage;
+ } else {
+ throw new NeneException("multiple main bluetooth packages found");
+ }
+ }
+ }
+ }
+ if (matchedPackage != null) {
+ return matchedPackage;
+ }
+ throw new NeneException("Could not find main bluetooth package");
}
}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp b/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
index 0fc8b16..e65bc93 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
@@ -43,6 +43,7 @@
"androidx.legacy_legacy-support-v4",
"devicepolicy-deviceside-common",
"DpmWrapper",
+ "NeneInternal",
],
min_sdk_version: "21",
// tag this module as a cts test artifact
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
index f30d29e..95f5693 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
@@ -17,7 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.deviceowner">
- <uses-sdk android:minSdkVersion="20"/>
+ <uses-sdk android:minSdkVersion="29"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
index eb5cc56..7606b79 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
@@ -16,8 +16,6 @@
package com.android.cts.deviceowner;
-import static android.os.Process.BLUETOOTH_UID;
-
import static com.google.common.truth.Truth.assertWithMessage;
import android.bluetooth.BluetoothAdapter;
@@ -28,6 +26,7 @@
import android.util.DebugUtils;
import android.util.Log;
+import com.android.bedstead.nene.TestApis;
import com.android.internal.util.ArrayUtils;
/**
@@ -134,11 +133,8 @@
return;
}
- String bluetoothPackageName = mContext.getPackageManager()
- .getPackagesForUid(BLUETOOTH_UID)[0];
-
- ComponentName oppLauncherComponent = new ComponentName(
- bluetoothPackageName, OPP_LAUNCHER_CLASS);
+ ComponentName oppLauncherComponent =
+ new ComponentName(TestApis.bluetooth().findPackageName(), OPP_LAUNCHER_CLASS);
// First verify DISALLOW_BLUETOOTH.
testOppDisabledWhenRestrictionSet(UserManager.DISALLOW_BLUETOOTH,
@@ -146,8 +142,8 @@
// Verify DISALLOW_BLUETOOTH_SHARING which leaves bluetooth workable but the sharing
// component should be disabled.
- testOppDisabledWhenRestrictionSet(UserManager.DISALLOW_BLUETOOTH_SHARING,
- oppLauncherComponent);
+ testOppDisabledWhenRestrictionSet(
+ UserManager.DISALLOW_BLUETOOTH_SHARING, oppLauncherComponent);
}
/** Verifies that a given restriction disables the bluetooth sharing component. */
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp b/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp
index 376b76b..7a0a26b 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp
@@ -36,6 +36,7 @@
"androidx.legacy_legacy-support-v4",
"devicepolicy-deviceside-common",
"permission-test-util-lib",
+ "NeneInternal",
],
min_sdk_version: "27",
// tag this module as a cts test artifact
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml b/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
index 0a049c9..267f56e 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
@@ -17,7 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.managedprofile">
- <uses-sdk android:minSdkVersion="27"/>
+ <uses-sdk android:minSdkVersion="29"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BluetoothSharingRestrictionTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BluetoothSharingRestrictionTest.java
index 18f0d7c..ea41868 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BluetoothSharingRestrictionTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BluetoothSharingRestrictionTest.java
@@ -15,8 +15,6 @@
*/
package com.android.cts.managedprofile;
-import static android.os.Process.BLUETOOTH_UID;
-
import android.app.UiAutomation;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
@@ -32,6 +30,7 @@
import androidx.test.InstrumentationRegistry;
+import com.android.bedstead.nene.TestApis;
import com.android.internal.util.ArrayUtils;
import junit.framework.TestCase;
@@ -113,8 +112,7 @@
: new int[] {PackageManager.COMPONENT_ENABLED_STATE_DISABLED};
sUiAutomation.adoptShellPermissionIdentity(INTERACT_ACROSS_USERS_PERMISSION);
- String bluetoothPackageName = context.getPackageManager()
- .getPackagesForUid(BLUETOOTH_UID)[0];
+ String bluetoothPackageName = TestApis.bluetooth().findPackageName();
sUiAutomation.dropShellPermissionIdentity();
ComponentName oppLauncherComponent = new ComponentName(
diff --git a/tests/app/shared/src/android/app/cts/NotificationTemplateTestBase.kt b/tests/app/shared/src/android/app/cts/NotificationTemplateTestBase.kt
index 6b84cd3..47da9fa 100644
--- a/tests/app/shared/src/android/app/cts/NotificationTemplateTestBase.kt
+++ b/tests/app/shared/src/android/app/cts/NotificationTemplateTestBase.kt
@@ -146,4 +146,7 @@
@BoolRes
protected fun getAndroidRBool(boolName: String): Int = getAndroidRes("bool", boolName)
+
+ @DimenRes
+ protected fun getAndroidRDimen(dimenName: String) : Int = getAndroidRes("dimen", dimenName)
}
\ No newline at end of file
diff --git a/tests/app/src/android/app/cts/NotificationTemplateTest.kt b/tests/app/src/android/app/cts/NotificationTemplateTest.kt
index 5f3f7e8..bef1319 100644
--- a/tests/app/src/android/app/cts/NotificationTemplateTest.kt
+++ b/tests/app/src/android/app/cts/NotificationTemplateTest.kt
@@ -21,6 +21,7 @@
import android.app.Person
import android.app.cts.CtsAppTestUtils.platformNull
import android.content.Intent
+import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
@@ -299,8 +300,8 @@
assertThat(iconView.width.toFloat())
.isWithin(1f)
.of((iconView.height * 4 / 3).toFloat())
- assertThat(iconView.drawable.intrinsicWidth).isEqualTo(400)
- assertThat(iconView.drawable.intrinsicHeight).isEqualTo(300)
+ assertThat(iconView.drawable.intrinsicWidth).isEqualTo(rightIconSize())
+ assertThat(iconView.drawable.intrinsicHeight).isEqualTo(rightIconSize() * 3 / 4)
}
}
@@ -399,8 +400,9 @@
assertThat(iconView.width.toFloat())
.isWithin(1f)
.of((iconView.height * 4 / 3).toFloat())
- assertThat(iconView.drawable.intrinsicWidth).isEqualTo(400)
- assertThat(iconView.drawable.intrinsicHeight).isEqualTo(300)
+
+ assertThat(iconView.drawable.intrinsicWidth).isEqualTo(rightIconSize())
+ assertThat(iconView.drawable.intrinsicHeight).isEqualTo(rightIconSize() * 3 / 4)
}
}
@@ -782,6 +784,11 @@
PendingIntent.getBroadcast(mContext, 0, Intent("test"), PendingIntent.FLAG_IMMUTABLE)
}
+ private fun rightIconSize(): Int {
+ return mContext.resources.getDimensionPixelSize(
+ getAndroidRDimen("notification_right_icon_size"))
+ }
+
companion object {
val TAG = NotificationTemplateTest::class.java.simpleName
const val NOTIFICATION_CHANNEL_ID = "NotificationTemplateTest"
diff --git a/tests/location/location_none/src/android/location/cts/none/LocationDisabledAppOpsTest.java b/tests/location/location_none/src/android/location/cts/none/LocationDisabledAppOpsTest.java
index a70065c..c406052 100644
--- a/tests/location/location_none/src/android/location/cts/none/LocationDisabledAppOpsTest.java
+++ b/tests/location/location_none/src/android/location/cts/none/LocationDisabledAppOpsTest.java
@@ -34,6 +34,8 @@
import androidx.test.InstrumentationRegistry;
+import com.android.compatibility.common.util.ApiTest;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -54,6 +56,11 @@
}
@Test
+ @ApiTest(apis = {
+ "android.location.LocationManager#setLocationEnabledForUser",
+ "android.app.AppOpsManager#noteOpNoThrow",
+ "android.app.AppOpsManager#checkOpNoThrow",
+ })
public void testLocationAppOpIsIgnoredForAppsWhenLocationIsDisabled() {
PackageTagsList ignoreList = mLm.getIgnoreSettingsAllowlist();
@@ -85,7 +92,8 @@
mode[0] = mAom.noteOpNoThrow(
OPSTR_FINE_LOCATION, ai.uid, ai.packageName);
});
- if (mode[0] == MODE_ALLOWED && !ignoreList.containsAll(pi.packageName)) {
+ if (mode[0] == MODE_ALLOWED && !ignoreList.containsAll(pi.packageName)
+ && !mLm.isProviderPackage(null, pi.packageName, null)) {
bypassedNoteOps.add(pi.packageName);
}
@@ -95,7 +103,8 @@
mode[0] = mAom
.checkOpNoThrow(OPSTR_FINE_LOCATION, ai.uid, ai.packageName);
});
- if (mode[0] == MODE_ALLOWED && !ignoreList.includes(pi.packageName)) {
+ if (mode[0] == MODE_ALLOWED && !ignoreList.includes(pi.packageName)
+ && !mLm.isProviderPackage(null, pi.packageName, null)) {
bypassedCheckOps.add(pi.packageName);
}
diff --git a/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java b/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java
index f03fa90..efa8441 100644
--- a/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java
@@ -135,9 +135,9 @@
{MediaFormat.MIMETYPE_VIDEO_AVC, "bbb_360x640_768kbps_30fps_avc.mp4",
"bbb_520x390_1mbps_30fps_avc.mp4", CODEC_ALL},
{MediaFormat.MIMETYPE_VIDEO_AVC, "bbb_160x1024_1500kbps_30fps_avc.mp4",
- "bbb_520x390_1mbps_30fps_avc.mp4", CODEC_ALL},
+ "bbb_520x390_1mbps_30fps_avc.mp4", CODEC_OPTIONAL},
{MediaFormat.MIMETYPE_VIDEO_AVC, "bbb_1280x120_1500kbps_30fps_avc.mp4",
- "bbb_340x280_768kbps_30fps_avc.mp4", CODEC_ALL},
+ "bbb_340x280_768kbps_30fps_avc.mp4", CODEC_OPTIONAL},
{MediaFormat.MIMETYPE_VIDEO_HEVC, "bbb_520x390_1mbps_30fps_hevc.mp4",
"bbb_340x280_768kbps_30fps_hevc.mp4", CODEC_ALL},
{MediaFormat.MIMETYPE_VIDEO_MPEG4, "bbb_128x96_64kbps_12fps_mpeg4.mp4",
diff --git a/tests/media/src/android/mediav2/cts/CodecInfoTest.java b/tests/media/src/android/mediav2/cts/CodecInfoTest.java
index 143b795..c3a1b09 100644
--- a/tests/media/src/android/mediav2/cts/CodecInfoTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecInfoTest.java
@@ -103,6 +103,7 @@
@ApiTest(apis = "MediaCodecInfo.CodecCapabilities#profileLevels")
public void testHDRDisplayCapabilities() {
Assume.assumeTrue("Test needs Android 13", IS_AT_LEAST_T);
+ Assume.assumeTrue("Test needs VNDK Android 13", VNDK_IS_AT_LEAST_T);
Assume.assumeTrue("Test is applicable for video codecs", mMediaType.startsWith("video/"));
// TODO (b/228237404) Remove the following once there is a reliable way to query HDR
// display capabilities at native level, till then limit the test to vendor codecs
diff --git a/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt b/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt
index e6eab02..9667a55 100644
--- a/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt
+++ b/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt
@@ -517,9 +517,9 @@
val parent = waitFindObject(
By.clickable(true)
.hasDescendant(By.textStartsWith("Remove permissions"))
- .hasDescendant(By.clazz(Switch::class.java.name))
+ .hasDescendant(By.checkable(true))
)
- return parent.findObject(By.clazz(Switch::class.java.name))
+ return parent.findObject(By.checkable(true))
}
private fun waitForIdle() {
diff --git a/tests/tests/security/Android.bp b/tests/tests/security/Android.bp
index 00a1e37..0cf3dd5 100644
--- a/tests/tests/security/Android.bp
+++ b/tests/tests/security/Android.bp
@@ -35,6 +35,7 @@
"platform-test-annotations",
"sts-device-util",
"hamcrest-library",
+ "NeneInternal",
],
libs: [
"android.test.runner",
diff --git a/tests/tests/security/src/android/security/cts/BluetoothIntentsTest.java b/tests/tests/security/src/android/security/cts/BluetoothIntentsTest.java
index ab05f91..0374220 100644
--- a/tests/tests/security/src/android/security/cts/BluetoothIntentsTest.java
+++ b/tests/tests/security/src/android/security/cts/BluetoothIntentsTest.java
@@ -15,14 +15,13 @@
*/
package android.security.cts;
-import static android.os.Process.BLUETOOTH_UID;
-
import android.content.ComponentName;
import android.content.Intent;
import android.platform.test.annotations.AsbSecurityTest;
import androidx.test.runner.AndroidJUnit4;
+import com.android.bedstead.nene.TestApis;
import com.android.sts.common.util.StsExtraBusinessLogicTestCase;
import org.junit.Test;
@@ -48,27 +47,27 @@
genericIntentTest("DECLINE");
}
- private static final String prefix = "android.btopp.intent.action.";
- private void genericIntentTest(String action) throws SecurityException {
- try {
- Intent should_be_protected_broadcast = new Intent();
+ private static final String PREFIX = "android.btopp.intent.action.";
+ private static final String RECEIVER = "com.android.bluetooth.opp.BluetoothOppReceiver";
- String bluetoothPackageName = getInstrumentation().getContext().getPackageManager()
- .getPackagesForUid(BLUETOOTH_UID)[0];
-
- ComponentName oppLauncherComponent = new ComponentName(bluetoothPackageName,
- "com.android.bluetooth.opp.BluetoothOppReceiver");
-
- should_be_protected_broadcast.setComponent(oppLauncherComponent);
- should_be_protected_broadcast.setAction(prefix + action);
+ private void genericIntentTest(String action) throws SecurityException {
+ try {
+ Intent should_be_protected_broadcast = new Intent();
+ ComponentName oppLauncherComponent =
+ new ComponentName(TestApis.bluetooth().findPackageName(), RECEIVER);
+ should_be_protected_broadcast.setComponent(oppLauncherComponent);
+ should_be_protected_broadcast.setAction(PREFIX + action);
getInstrumentation().getContext().sendBroadcast(should_be_protected_broadcast);
}
catch (SecurityException e) {
return;
}
- throw new SecurityException("An " + prefix + action +
- " intent should not be broadcastable except by the system (declare " +
- " as protected-broadcast in manifest)");
- }
+ throw new SecurityException(
+ "An "
+ + PREFIX
+ + action
+ + " intent should not be broadcastable except by the system (declare "
+ + " as protected-broadcast in manifest)");
+ }
}
diff --git a/tests/tests/textclassifier/src/android/view/textclassifier/cts/TextViewIntegrationTest.java b/tests/tests/textclassifier/src/android/view/textclassifier/cts/TextViewIntegrationTest.java
index b96293f..568277f 100644
--- a/tests/tests/textclassifier/src/android/view/textclassifier/cts/TextViewIntegrationTest.java
+++ b/tests/tests/textclassifier/src/android/view/textclassifier/cts/TextViewIntegrationTest.java
@@ -36,6 +36,7 @@
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.net.Uri;
+import android.os.RemoteException;
import android.provider.Settings;
import android.text.Spannable;
import android.text.SpannableString;
@@ -87,28 +88,16 @@
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
@Before
- public void setup() throws Exception {
+ public void setup() throws RemoteException {
Assume.assumeTrue(
ApplicationProvider.getApplicationContext().getPackageManager()
.hasSystemFeature(FEATURE_TOUCHSCREEN));
- workAroundNotificationShadeWindowIssue();
mSimpleTextClassifier = new SimpleTextClassifier();
sDevice.wakeUp();
dismissKeyguard();
closeSystemDialog();
}
- // Somehow there is a stale "NotificationShade" window from SysUI stealing the inputs.
- // The window is in the "exiting" state and seems never finish exiting.
- // The workaround here is to (hopefully) reset its state by expanding the notification panel
- // and collapsing it again.
- private void workAroundNotificationShadeWindowIssue() throws InterruptedException {
- ShellUtils.runShellCommand("cmd statusbar expand-notifications");
- Thread.sleep(1000);
- ShellUtils.runShellCommand("cmd statusbar collapse");
- Thread.sleep(1000);
- }
-
private void dismissKeyguard() {
ShellUtils.runShellCommand("wm dismiss-keyguard");
}
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
index 3b004dd..e3ff5f8 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
@@ -97,6 +97,7 @@
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.compatibility.common.util.ApiLevelUtil;
+import com.android.compatibility.common.util.ApiTest;
import com.android.compatibility.common.util.FeatureUtil;
import com.android.compatibility.common.util.PollingCheck;
import com.android.compatibility.common.util.PropertyUtil;
@@ -5468,6 +5469,7 @@
/**
* Tests {@link WifiConfiguration#setBssidAllowlist(List)}.
*/
+ @ApiTest(apis = "android.net.wifi.WifiConfiguration#setBssidAllowlist")
public void testBssidAllowlist() throws Exception {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
@@ -5518,7 +5520,6 @@
waitForConnection();
wifiInfo = mWifiManager.getConnectionInfo();
assertEquals(networkId, wifiInfo.getNetworkId());
- assertEquals(connectedBssid, wifiInfo.getBSSID());
} finally {
// Reset BSSID allow list to accept all APs
for (WifiConfiguration network : savedNetworks) {