Skip to content

Commit

Permalink
Fix permission rules to only apply at api level or above that it is n…
Browse files Browse the repository at this point in the history
…eeded
  • Loading branch information
JulianKast committed Feb 13, 2024
1 parent 0b0f350 commit 80dcfa6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down

0 comments on commit 80dcfa6

Please sign in to comment.