From 80dcfa69f57c4218a4e6e8d03819893b814954f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJKAST=E2=80=9D?= Date: Tue, 13 Feb 2024 15:52:53 -0500 Subject: [PATCH] Fix permission rules to only apply at api level or above that it is needed --- .../smartdevicelink/transport/TransportManagerTests.java | 6 +----- .../com/smartdevicelink/util/MediaStreamingStatusTests.java | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java index 2904adae9c..6add9d6a48 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java @@ -34,7 +34,7 @@ public class TransportManagerTests { @Rule - public GrantPermissionRule btRuntimePermissionRule; + public GrantPermissionRule btRuntimePermissionRule = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? GrantPermissionRule.grant(Manifest.permission.BLUETOOTH_CONNECT) : null; MultiplexTransportConfig config; final TransportRecord defaultBtRecord = new TransportRecord(TransportType.BLUETOOTH, "12:34:56:78:90"); final ComponentName routerServiceComponentName = new ComponentName("com.smartdevicelink.test", "com.smartdevicelink.test.SdlRouterService"); @@ -68,10 +68,6 @@ public boolean onLegacyModeEnabled(String info) { @Before public void setUp() throws Exception { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - btRuntimePermissionRule = - GrantPermissionRule.grant(Manifest.permission.BLUETOOTH_CONNECT); - } config = new MultiplexTransportConfig(getInstrumentation().getContext(), SdlUnitTestContants.TEST_APP_ID); config.setService(routerServiceComponentName); if (Looper.myLooper() == null) { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java index 5e19ee78c8..d13aa49a49 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java @@ -37,7 +37,7 @@ @RunWith(AndroidJUnit4.class) public class MediaStreamingStatusTests { @Rule - public GrantPermissionRule btRuntimePermissionRule; + public GrantPermissionRule btRuntimePermissionRule = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? GrantPermissionRule.grant(Manifest.permission.BLUETOOTH_CONNECT) : null; @Mock private AudioManager audioManager = mock(AudioManager.class); @@ -63,9 +63,6 @@ public Object answer(InvocationOnMock invocation) { @Before public void setUp() throws Exception { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - btRuntimePermissionRule = GrantPermissionRule.grant(Manifest.permission.BLUETOOTH_CONNECT); - } mockedContext = mock(Context.class); doAnswer(onGetSystemService).when(mockedContext).getSystemService(Context.AUDIO_SERVICE); defaultMediaStreamingStatus = new MediaStreamingStatus(mockedContext, mock(MediaStreamingStatus.Callback.class));