summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-06-01 19:08:06 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-06-01 19:08:11 +0000
commitd0ba2cd40b64c8e18d1391397d938c045f500fd0 (patch)
tree532b02650dd5c3df716098311cfac96e6db54ae0
parent4a7d0772a5cfb95f05b870fe742ab4ffff9d4e85 (diff)
parentfcd97ce795270ca4c5f61bd1515db3ed48bfba83 (diff)
Merge "Fix crash from non-default sims in QS" into oc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/SignalClusterViewTest.java61
2 files changed, 62 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index ab41485793a1..18cc8721ff95 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -308,7 +308,7 @@ public class SignalClusterView extends LinearLayout implements NetworkController
if (state == null) {
return;
}
- if (mQsSignal) {
+ if (mQsSignal && qsIcon != null) {
icon = qsIcon;
type = qsType;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/SignalClusterViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/SignalClusterViewTest.java
new file mode 100644
index 000000000000..28a5aa39be80
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/SignalClusterViewTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.systemui.statusbar;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.support.test.filters.SmallTest;
+import android.telephony.SubscriptionInfo;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
+import android.view.LayoutInflater;
+
+import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.policy.NetworkController.IconState;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Arrays;
+
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper
+@SmallTest
+public class SignalClusterViewTest extends SysuiTestCase {
+
+ private SignalClusterView mSignalCluster;
+
+ @Before
+ public void setup() {
+ mSignalCluster = (SignalClusterView) LayoutInflater.from(mContext)
+ .inflate(R.layout.signal_cluster_view, null);
+ }
+
+ @Test
+ public void testNonDefaultSim() {
+ SubscriptionInfo first = mock(SubscriptionInfo.class);
+ SubscriptionInfo second = mock(SubscriptionInfo.class);
+ when(first.getSubscriptionId()).thenReturn(0);
+ when(second.getSubscriptionId()).thenReturn(1);
+ mSignalCluster.setSubs(Arrays.asList(first, second));
+ mSignalCluster.setQsSignalCluster();
+ mSignalCluster.setMobileDataIndicators(new IconState(true, 0, 0, ""), null, 0, 0,
+ false, false, "", "", false, 1, false);
+ }
+
+} \ No newline at end of file