From fcd97ce795270ca4c5f61bd1515db3ed48bfba83 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Thu, 1 Jun 2017 11:00:00 -0400 Subject: [PATCH] Fix crash from non-default sims in QS Test: runtest systemui Change-Id: Icdb063589258a6b4bd94634cc9f41f788a7d2299 Fixes: 62209034 --- .../systemui/statusbar/SignalClusterView.java | 2 +- .../statusbar/SignalClusterViewTest.java | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 packages/SystemUI/tests/src/com/android/systemui/statusbar/SignalClusterViewTest.java diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java index ab41485793a1a..18cc8721ff955 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 0000000000000..28a5aa39be805 --- /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