Fix DataSaverBackend objects created on background threads

Add the main looper to the handler created with each
DataSaverBackend to avoid crashes when the objects are
created on background threads.

Bug: 62022517
Test: make RunSettingsRoboTests
Change-Id: I7396107e4ed06982c8cd300912ce1f4e3c63df4c
Merged-In: Ie5ffabbfbe7660761527b3ecd51e6bc5a43c1ace
This commit is contained in:
Matthew Fritze
2017-07-18 13:12:05 -07:00
parent 4f0e5f8395
commit 7c1825aa64
2 changed files with 25 additions and 13 deletions

View File

@@ -0,0 +1,21 @@
package com.android.settings.testutils.shadow;
import com.android.settings.datausage.DataSaverBackend;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@Implements(DataSaverBackend.class)
public class ShadowDataSaverBackend {
private static boolean isEnabled = true;
@Implementation
public boolean isDataSaverEnabled() {
return isEnabled;
}
@Implementation
public void setDataSaverEnabled(boolean enabled) {
isEnabled = enabled;
}
}