Fix a monkey crash in Developer settings.

- DevSetting shouldn't add switchbar listener if it's a Monkey test run
- DevSetting shouldn't remove switchbar listener if it's not registered
- Refactor some switchbar logic in order to create test

Change-Id: Ie65ff9b04778075789010169039393bd0551acfb
Fix: 64021498
Test: robotests
This commit is contained in:
Fan Zhang
2017-07-25 10:30:24 -07:00
parent a39daa25e7
commit 84dd783c36
4 changed files with 163 additions and 18 deletions

View File

@@ -16,6 +16,8 @@
package com.android.settings.widget;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
@@ -41,8 +43,6 @@ import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedChangeListener,
View.OnClickListener {
@@ -71,8 +71,7 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
private String mMetricsTag;
private ArrayList<OnSwitchChangeListener> mSwitchChangeListeners =
new ArrayList<OnSwitchChangeListener>();
private final ArrayList<OnSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
private static int[] XML_ATTRIBUTES = {
R.attr.switchBarMarginStart, R.attr.switchBarMarginEnd,