diff --git a/core/os/android/adb/device.go b/core/os/android/adb/device.go index 11ac57c4b5..c4711d6b23 100644 --- a/core/os/android/adb/device.go +++ b/core/os/android/adb/device.go @@ -194,22 +194,25 @@ func scanDevices(ctx context.Context) error { defer cacheMutex.Unlock() for serial, status := range parsed { - device, ok := cache[serial] - if !ok { - device, err = newDevice(ctx, serial, status) + cached, ok := cache[serial] + if !ok || status != cached.Status() { + device, err := newDevice(ctx, serial, status) if err != nil { return err } + if ok { + registry.RemoveDevice(ctx, cached) + } cache[serial] = device registry.AddDevice(ctx, device) } } // Remove cached results for removed devices. - for serial, device := range cache { + for serial, cached := range cache { if _, found := parsed[serial]; !found { delete(cache, serial) - registry.RemoveDevice(ctx, device) + registry.RemoveDevice(ctx, cached) } }