Always copy SignalIconState when keeping a reference
Defensively copy SignalIconState so that StatusBarWifiView and
StatusBarMobileView can properly detect changes to state.
Also don't do visibility changes if setting the same visibleState on
StatusBarWifiView.
Test: turn wifi on and off; verify that it goes away properly in status
bar
Fixes: 78353558
Fixes: 77738471
Fixes: 78050495
Fixes: 78163313
Change-Id: Ie9b9e05885c130c1ec6d6abb9d0567400df23e52
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java
index f4e45812..5748ec9b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java
@@ -100,13 +100,13 @@
}
if (mState == null) {
- mState = state;
+ mState = state.copy();
initViewState();
return;
}
if (!mState.equals(state)) {
- updateState(state);
+ updateState(state.copy());
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java
index 0e2714d..bf94c1f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java
@@ -64,6 +64,7 @@
private WifiIconState mState;
private String mSlot;
private float mDarkIntensity = 0;
+ private int mVisibleState = -1;
private ContextThemeWrapper mDarkContext;
private ContextThemeWrapper mLightContext;
@@ -73,6 +74,7 @@
StatusBarWifiView v = (StatusBarWifiView) inflater.inflate(R.layout.status_bar_wifi_group, null);
v.setSlot(slot);
v.init();
+ v.setVisibleState(STATE_ICON);
return v;
}
@@ -123,6 +125,11 @@
@Override
public void setVisibleState(int state) {
+ if (state == mVisibleState) {
+ return;
+ }
+ mVisibleState = state;
+
switch (state) {
case STATE_ICON:
mWifiGroup.setVisibility(View.VISIBLE);
@@ -139,12 +146,6 @@
}
}
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- int width = MeasureSpec.getSize(widthMeasureSpec);
- }
-
private void init() {
int dualToneLightTheme = Utils.getThemeAttr(mContext, R.attr.lightIconTheme);
int dualToneDarkTheme = Utils.getThemeAttr(mContext, R.attr.darkIconTheme);
@@ -180,12 +181,12 @@
}
if (mState == null) {
- mState = state;
+ mState = state.copy();
initViewState();
}
if (!mState.equals(state)) {
- updateState(state);
+ updateState(state.copy());
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconHolder.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconHolder.java
index e854dd0..c4ff85f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconHolder.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconHolder.java
@@ -110,6 +110,10 @@
}
public void setVisible(boolean visible) {
+ if (isVisible() == visible) {
+ return;
+ }
+
switch (mType) {
case TYPE_ICON:
mIcon.visible = visible;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java
index 669a8c8..7cd433a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java
@@ -388,6 +388,12 @@
typeContentDescription);
}
+ public MobileIconState copy() {
+ MobileIconState copy = new MobileIconState(this.subId);
+ copyTo(copy);
+ return copy;
+ }
+
public void copyTo(MobileIconState other) {
super.copyTo(other);
other.subId = subId;