diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java index c0708692cb39c..0e7b2f31cba28 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java @@ -29,7 +29,6 @@ import android.graphics.drawable.RippleDrawable; import android.os.UserManager; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; -import android.telephony.SubscriptionInfo; import android.util.AttributeSet; import android.util.SparseBooleanArray; import android.view.View; @@ -65,8 +64,6 @@ import com.android.systemui.statusbar.policy.UserInfoController; import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener; import com.android.systemui.tuner.TunerService; -import java.util.List; - public class QuickStatusBarHeader extends BaseStatusBarHeader implements NextAlarmChangeCallback, OnClickListener, OnUserInfoChangedListener, EmergencyListener, SignalCallback { @@ -443,20 +440,10 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements } } - @Override - public void setSubs(List subs) { - mRoamingsBySubId.clear(); - updateRoaming(); - } - public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType, int qsType, boolean activityIn, boolean activityOut, String typeContentDescription, String description, boolean isWide, int subId, boolean roaming) { mRoamingsBySubId.put(subId, roaming); - updateRoaming(); - } - - private void updateRoaming() { boolean isRoaming = calculateRoaming(); if (mIsRoaming != isRoaming) { mIsRoaming = isRoaming; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationMenuRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationMenuRowTest.java index b8be4fa57c0fb..72f6ca8ec7304 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationMenuRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationMenuRowTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; @RunWith(SysUIRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class NotificationMenuRowTest extends LeakCheckedTest { @Before diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStatusBarHeaderTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStatusBarHeaderTest.java deleted file mode 100644 index c55d43452771e..0000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStatusBarHeaderTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.phone; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import android.os.Handler; -import android.os.Looper; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.TextView; - -import com.android.systemui.R; -import com.android.systemui.R.layout; -import com.android.systemui.SysUIRunner; -import com.android.systemui.utils.TestableLooper; -import com.android.systemui.utils.TestableLooper.RunWithLooper; -import com.android.systemui.utils.ViewUtils; -import com.android.systemui.utils.leaks.LeakCheckedTest; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.ArrayList; - -@RunWith(SysUIRunner.class) -@RunWithLooper(setAsMainLooper = true) -public class QuickStatusBarHeaderTest extends LeakCheckedTest { - - @Before - public void setup() throws NoSuchFieldException, IllegalAccessException { - injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES); - } - - @Test - public void testRoamingStuck() throws Exception { - TestableLooper looper = TestableLooper.get(this); - assertEquals(Looper.myLooper(), looper.getLooper()); - assertEquals(Looper.myLooper(), Looper.getMainLooper()); - QuickStatusBarHeader header = (QuickStatusBarHeader) LayoutInflater.from(mContext).inflate( - layout.quick_status_bar_expanded_header, null); - header.setExpanded(true); - - ViewUtils.attachView(header); - looper.processMessages(1); - TextView emergencyText = (TextView) header.findViewById( - R.id.header_emergency_calls_only); - int subId = 0; - header.setMobileDataIndicators(null, null, 0, 0, false, - false, null, null, false, subId, true); - looper.processAllMessages(); - assertEquals(mContext.getString(R.string.accessibility_data_connection_roaming), - emergencyText.getText()); - assertEquals(View.VISIBLE, emergencyText.getVisibility()); - - header.setSubs(new ArrayList<>()); - subId = 1; - header.setMobileDataIndicators(null, null, 0, 0, false, - false, null, null, false, subId, false); - looper.processAllMessages(); - - assertNotEquals(View.VISIBLE, emergencyText.getVisibility()); - assertEquals(Looper.myLooper(), Looper.getMainLooper()); - ViewUtils.detachView(header); - looper.processAllMessages(); - } - -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/utils/TestableLooper.java b/packages/SystemUI/tests/src/com/android/systemui/utils/TestableLooper.java index 8902e0c23b5f8..d27597331aa20 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/utils/TestableLooper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/utils/TestableLooper.java @@ -244,11 +244,9 @@ public class TestableLooper { mLooper.setAsMainLooper(); } - try { - mBase.evaluate(); - } finally { - mLooper.destroy(); - } + mBase.evaluate(); + + mLooper.destroy(); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/utils/ViewUtils.java b/packages/SystemUI/tests/src/com/android/systemui/utils/ViewUtils.java index 678b9f407bcd2..07e5f6663a3f2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/utils/ViewUtils.java +++ b/packages/SystemUI/tests/src/com/android/systemui/utils/ViewUtils.java @@ -14,11 +14,9 @@ package com.android.systemui.utils; -import android.content.pm.ApplicationInfo; import android.graphics.PixelFormat; import android.os.Handler; import android.os.Looper; -import android.util.Log; import android.view.View; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; @@ -29,19 +27,18 @@ import com.android.systemui.SysuiTestCase; public class ViewUtils { public static void attachView(View view) { - // Make sure hardware acceleration isn't turned on. - view.getContext().getApplicationInfo().flags &= - ~(ApplicationInfo.FLAG_HARDWARE_ACCELERATED); WindowManager.LayoutParams lp = new WindowManager.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, LayoutParams.TYPE_APPLICATION_OVERLAY, 0, PixelFormat.TRANSLUCENT); - InstrumentationRegistry.getContext() - .getSystemService(WindowManager.class).addView(view, lp); + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(() -> InstrumentationRegistry.getContext() + .getSystemService(WindowManager.class).addView(view, lp)); } public static void detachView(View view) { - InstrumentationRegistry.getContext() - .getSystemService(WindowManager.class).removeViewImmediate(view); + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(() -> InstrumentationRegistry.getContext() + .getSystemService(WindowManager.class).removeView(view)); } }