Get anomaly info from StringArrayList

Statsd populates the anomaly info in StringArrayList, not StringArray. So
in settings we should use the correct API to get the data.

Bug: 77141809
Test: RunSettingsRoboTests
Change-Id: I56fc096106b5c040422fd7f5bb8cb4be7fe71d9d
This commit is contained in:
Lei Yu
2018-03-27 16:10:54 -07:00
parent 4e25277f60
commit bb90c955df
3 changed files with 14 additions and 6 deletions

View File

@@ -58,6 +58,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.shadows.ShadowJobScheduler;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -149,8 +150,9 @@ public class AnomalyDetectionJobServiceTest {
@Test
public void testSaveAnomalyToDatabase_normalAppWithAutoRestriction_save() {
mBundle.putStringArray(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES,
new String[]{SUBSCRIBER_COOKIES_AUTO_RESTRICTION});
final ArrayList<String> cookies = new ArrayList<>();
cookies.add(SUBSCRIBER_COOKIES_AUTO_RESTRICTION);
mBundle.putStringArrayList(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES, cookies);
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
doReturn(Process.FIRST_APPLICATION_UID).when(
@@ -173,8 +175,9 @@ public class AnomalyDetectionJobServiceTest {
@Test
public void testSaveAnomalyToDatabase_normalAppWithoutAutoRestriction_save() {
mBundle.putStringArray(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES,
new String[]{SUBSCRIBER_COOKIES_NOT_AUTO_RESTRICTION});
final ArrayList<String> cookies = new ArrayList<>();
cookies.add(SUBSCRIBER_COOKIES_NOT_AUTO_RESTRICTION);
mBundle.putStringArrayList(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES, cookies);
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
doReturn(Process.FIRST_APPLICATION_UID).when(