@@ -251,7 +251,7 @@ class SystemBridgeAutoStarterTest {
251251 }
252252
253253 @Test
254- fun `auto start with root when type is ROOT ` () = runTest(testDispatcher) {
254+ fun `auto start with root` () = runTest(testDispatcher) {
255255 whenever(mockClock.elapsedRealtime()).thenReturn(1_000_000L )
256256 isRootGrantedFlow.value = true
257257 fakePreferences.set(Keys .isSystemBridgeEmergencyKilled, false )
@@ -332,6 +332,49 @@ class SystemBridgeAutoStarterTest {
332332 verify(mockConnectionManager).startWithShizuku()
333333 }
334334
335+ @Test
336+ fun `wait a minute when auto starting on boot with shizuku` () = runTest(testDispatcher) {
337+ setAutoStartBootState()
338+ // Shizuku is initially disconnected on boot but shizuku permission is granted
339+ shizukuIsStartedFlow.value = false
340+ shizukuPermissionGrantedFlow.value = true
341+
342+ inOrder(mockConnectionManager) {
343+ systemBridgeAutoStarter.init ()
344+ advanceTimeBy(50000 )
345+ verify(mockConnectionManager, never()).startWithShizuku()
346+
347+ // Shizuku then connects
348+ shizukuIsStartedFlow.value = true
349+
350+ advanceTimeBy(20000 )
351+ verify(mockConnectionManager).startWithShizuku()
352+ }
353+ }
354+
355+ @Test
356+ fun `wait a minute when auto starting on boot with ADB` () = runTest(testDispatcher) {
357+ setAutoStartBootState()
358+
359+ whenever(mockSetupController.isAdbPaired()).thenReturn(true )
360+ writeSecureSettingsGrantedFlow.value = true
361+
362+ // Initially the wifi is disconnected, and is connected 50 seconds after booting
363+ isWifiConnectedFlow.value = false
364+
365+ inOrder(mockSetupController) {
366+ systemBridgeAutoStarter.init ()
367+ advanceTimeBy(50000 )
368+ verify(mockSetupController, never()).autoStartWithAdb()
369+
370+ // Connect to Wi-Fi network
371+ isWifiConnectedFlow.value = true
372+
373+ advanceTimeBy(20000 )
374+ verify(mockSetupController).autoStartWithAdb()
375+ }
376+ }
377+
335378 @Test
336379 fun `do not auto start on boot when clean shutdown is false` () = runTest(testDispatcher) {
337380 whenever(mockClock.elapsedRealtime()).thenReturn(5000L )
@@ -385,13 +428,13 @@ class SystemBridgeAutoStarterTest {
385428
386429 inOrder(mockNotificationAdapter) {
387430 systemBridgeAutoStarter.init ()
388- advanceTimeBy(6000 )
431+ advanceTimeBy(70000 )
389432
390433 // Show the first notification that it is auto starting
391434 verify(mockNotificationAdapter).showNotification(any())
392435
393436 // Set the state as connected within the timeout
394- connectionStateFlow.value = SystemBridgeConnectionState .Connected (time = 10000 )
437+ connectionStateFlow.value = SystemBridgeConnectionState .Connected (time = 70000 )
395438
396439 advanceUntilIdle()
397440 // Do not show another notification after the timeout
@@ -462,7 +505,7 @@ class SystemBridgeAutoStarterTest {
462505
463506 inOrder(mockConnectionManager, mockSetupController) {
464507 systemBridgeAutoStarter.init ()
465- advanceTimeBy(60000 )
508+ advanceTimeBy(100_000 )
466509 verify(mockConnectionManager).startWithRoot()
467510
468511 // Disconnect the system bridge. Expected is true
0 commit comments