Fix crash on Wi-Fi Slice when it's continuously pinned and unpinned
It's because WifiTracker's initialization and onStop is on different thread. Fine tune the thread logic in SliceBackgroundWorker. Fixes: 118165942 Test: manual Change-Id: Icc86b5df7ec3c6fd0e4a79a62ea0c84465e9528d
This commit is contained in:
@@ -67,6 +67,7 @@ import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.annotation.Resetter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -485,11 +486,15 @@ public class SettingsSliceProviderTest {
|
||||
final SliceBackgroundWorker worker = spy(new SliceBackgroundWorker(
|
||||
mContext.getContentResolver(), uri) {
|
||||
@Override
|
||||
public void onSlicePinned() {
|
||||
protected void onSlicePinned() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSliceUnpinned() {
|
||||
protected void onSliceUnpinned() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
});
|
||||
final WifiSlice wifiSlice = spy(new WifiSlice(mContext));
|
||||
@@ -519,6 +524,17 @@ public class SettingsSliceProviderTest {
|
||||
verify(worker).onSliceUnpinned();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shutdown_backgroundWorker_closed() throws IOException {
|
||||
final Uri uri = WifiSlice.WIFI_URI;
|
||||
final SliceBackgroundWorker worker = initBackgroundWorker(uri);
|
||||
|
||||
mProvider.onSlicePinned(uri);
|
||||
mProvider.shutdown();
|
||||
|
||||
verify(worker).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void grantWhitelistedPackagePermissions_noWhitelist_shouldNotGrant() {
|
||||
final List<Uri> uris = new ArrayList<>();
|
||||
|
Reference in New Issue
Block a user