Add impl for force stop action
Also refactor the AnomalyAction so it could take source id as a parameter, which represents the fragment that invokes it. Bug: 36924669 Test: RunSettingsRoboTests Change-Id: Ib53865f92e1a6f1e9dcc1480c0c74fbcfb0226f4
This commit is contained in:
@@ -34,9 +34,11 @@ public class AnomalyDialogFragment extends InstrumentedDialogFragment implements
|
||||
DialogInterface.OnClickListener {
|
||||
|
||||
private static final String ARG_ANOMALY = "anomaly";
|
||||
private static final String ARG_METRICS_KEY = "metrics_key";
|
||||
|
||||
@VisibleForTesting
|
||||
Anomaly mAnomaly;
|
||||
private AnomalyUtils mAnomalyUtils;
|
||||
|
||||
/**
|
||||
* Listener to give the control back to target fragment
|
||||
@@ -52,16 +54,23 @@ public class AnomalyDialogFragment extends InstrumentedDialogFragment implements
|
||||
void onAnomalyHandled(Anomaly anomaly);
|
||||
}
|
||||
|
||||
public static AnomalyDialogFragment newInstance(Anomaly anomaly) {
|
||||
public static AnomalyDialogFragment newInstance(Anomaly anomaly, int metricsKey) {
|
||||
AnomalyDialogFragment dialogFragment = new AnomalyDialogFragment();
|
||||
|
||||
Bundle args = new Bundle(1);
|
||||
Bundle args = new Bundle(2);
|
||||
args.putParcelable(ARG_ANOMALY, anomaly);
|
||||
args.putInt(ARG_METRICS_KEY, metricsKey);
|
||||
dialogFragment.setArguments(args);
|
||||
|
||||
return dialogFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mAnomalyUtils = AnomalyUtils.getInstance(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
// TODO(b/37681923): add anomaly metric id
|
||||
@@ -75,8 +84,10 @@ public class AnomalyDialogFragment extends InstrumentedDialogFragment implements
|
||||
return;
|
||||
}
|
||||
|
||||
final AnomalyAction anomalyAction = AnomalyUtils.getAnomalyAction(mAnomaly.type);
|
||||
anomalyAction.handlePositiveAction(mAnomaly.packageName);
|
||||
final AnomalyAction anomalyAction = mAnomalyUtils.getAnomalyAction(mAnomaly.type);
|
||||
final int metricsKey = getArguments().getInt(ARG_METRICS_KEY);
|
||||
|
||||
anomalyAction.handlePositiveAction(mAnomaly.packageName, metricsKey);
|
||||
lsn.onAnomalyHandled(mAnomaly);
|
||||
}
|
||||
|
||||
@@ -86,7 +97,7 @@ public class AnomalyDialogFragment extends InstrumentedDialogFragment implements
|
||||
mAnomaly = bundle.getParcelable(ARG_ANOMALY);
|
||||
|
||||
final Context context = getContext();
|
||||
final AnomalyAction anomalyAction = AnomalyUtils.getAnomalyAction(mAnomaly.type);
|
||||
final AnomalyAction anomalyAction = mAnomalyUtils.getAnomalyAction(mAnomaly.type);
|
||||
switch (anomalyAction.getActionType()) {
|
||||
case Anomaly.AnomalyActionType.FORCE_STOP:
|
||||
return new AlertDialog.Builder(context)
|
||||
|
Reference in New Issue
Block a user