Merge "Get anomaly info from StringArrayList" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
512cb18c2e
@@ -51,6 +51,7 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -126,10 +127,10 @@ public class AnomalyDetectionJobService extends JobService {
|
||||
bundle.getParcelable(StatsManager.EXTRA_STATS_DIMENSIONS_VALUE);
|
||||
final long timeMs = bundle.getLong(AnomalyDetectionReceiver.KEY_ANOMALY_TIMESTAMP,
|
||||
System.currentTimeMillis());
|
||||
final String[] cookies = bundle.getStringArray(
|
||||
final ArrayList<String> cookies = bundle.getStringArrayList(
|
||||
StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES);
|
||||
final AnomalyInfo anomalyInfo = new AnomalyInfo(
|
||||
!ArrayUtils.isEmpty(cookies) ? cookies[0] : "");
|
||||
!ArrayUtils.isEmpty(cookies) ? cookies.get(0) : "");
|
||||
Log.i(TAG, "Extra stats value: " + intentDimsValue.toString());
|
||||
|
||||
try {
|
||||
|
@@ -17,17 +17,21 @@
|
||||
package com.android.settings.fuelgauge.batterytip;
|
||||
|
||||
import android.util.KeyValueListParser;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Model class to parse and store anomaly info from westworld
|
||||
*/
|
||||
public class AnomalyInfo {
|
||||
private static final String TAG = "AnomalyInfo";
|
||||
|
||||
private static final String KEY_ANOMALY_TYPE = "anomaly_type";
|
||||
private static final String KEY_AUTO_RESTRICTION = "auto_restriction";
|
||||
public final Integer anomalyType;
|
||||
public final boolean autoRestriction;
|
||||
|
||||
public AnomalyInfo(String info) {
|
||||
Log.i(TAG, "anomalyInfo: " + info);
|
||||
KeyValueListParser parser = new KeyValueListParser(',');
|
||||
parser.setString(info);
|
||||
anomalyType = parser.getInt(KEY_ANOMALY_TYPE, -1);
|
||||
|
@@ -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(
|
||||
|
Reference in New Issue
Block a user