diff options
18 files changed, 6 insertions, 108 deletions
diff --git a/packages/SystemUI/README.md b/packages/SystemUI/README.md index a4dbf38d8782..f170a11edd7e 100644 --- a/packages/SystemUI/README.md +++ b/packages/SystemUI/README.md @@ -24,12 +24,6 @@ the main path for onConfigurationChanged, now also happens through ConfigurationController). They also receive a callback for onBootCompleted since these objects may be started before the device has finished booting. -SystemUI and SystemUIApplication also have methods for putComponent and -getComponent which were existing systems to get a hold of other parts of -sysui before Dependency existed. Generally new things should not be added -to putComponent, instead Dependency and other refactoring is preferred to -make sysui structure cleaner. - Each SystemUI service is expected to be a major part of system ui and the goal is to minimize communication between them. So in general they should be relatively silo'd. diff --git a/packages/SystemUI/src/com/android/systemui/SysUiServiceProvider.java b/packages/SystemUI/src/com/android/systemui/SysUiServiceProvider.java deleted file mode 100644 index ff4b7cb0ac71..000000000000 --- a/packages/SystemUI/src/com/android/systemui/SysUiServiceProvider.java +++ /dev/null @@ -1,29 +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; - -import android.content.Context; - -/** - * The interface for getting core components of SysUI. Exists for Testability - * since tests don't have SystemUIApplication as their ApplicationContext. - */ -public interface SysUiServiceProvider { - <T> T getComponent(Class<T> interfaceType); - - public static <T> T getComponent(Context context, Class<T> interfaceType) { - return ((SysUiServiceProvider) context.getApplicationContext()).getComponent(interfaceType); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUI.java b/packages/SystemUI/src/com/android/systemui/SystemUI.java index 75700379caca..f795faf30603 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUI.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUI.java @@ -23,11 +23,9 @@ import android.os.Bundle; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.util.Map; -public abstract class SystemUI implements SysUiServiceProvider { +public abstract class SystemUI { protected final Context mContext; - public Map<Class<?>, Object> mComponents; public SystemUI(Context context) { mContext = context; @@ -44,17 +42,6 @@ public abstract class SystemUI implements SysUiServiceProvider { protected void onBootCompleted() { } - @SuppressWarnings("unchecked") - public <T> T getComponent(Class<T> interfaceType) { - return (T) (mComponents != null ? mComponents.get(interfaceType) : null); - } - - public <T, C extends T> void putComponent(Class<T> interfaceType, C component) { - if (mComponents != null) { - mComponents.put(interfaceType, component); - } - } - public static void overrideNotificationAppName(Context context, Notification.Builder n, boolean system) { final Bundle extras = new Bundle(); diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index 4b28e4af7d8b..f0317b4a02d0 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -36,13 +36,11 @@ import com.android.systemui.util.NotificationChannels; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; /** * Application class for SystemUI. */ -public class SystemUIApplication extends Application implements SysUiServiceProvider, +public class SystemUIApplication extends Application implements SystemUIAppComponentFactory.ContextInitializer { public static final String TAG = "SystemUIService"; @@ -56,7 +54,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv private SystemUI[] mServices; private boolean mServicesStarted; private boolean mBootCompleted; - private final Map<Class<?>, Object> mComponents = new HashMap<>(); private SystemUIAppComponentFactory.ContextAvailableCallback mContextAvailableCallback; public SystemUIApplication() { @@ -199,7 +196,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv throw new RuntimeException(ex); } - mServices[i].mComponents = mComponents; if (DEBUG) Log.d(TAG, "running: " + mServices[i]); mServices[i].start(); log.traceEnd(); @@ -232,11 +228,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv } } - @SuppressWarnings("unchecked") - public <T> T getComponent(Class<T> interfaceType) { - return (T) mComponents.get(interfaceType); - } - public SystemUI[] getServices() { return mServices; } diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java index 60bc6b6855e6..fcdd23463c5b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java @@ -35,7 +35,6 @@ import android.widget.Toast; import com.android.systemui.Dependency; import com.android.systemui.R; -import com.android.systemui.SysUiServiceProvider; import com.android.systemui.shared.recents.IOverviewProxy; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.stackdivider.Divider; @@ -73,7 +72,7 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { } @Override - public void onStart(Context context, SysUiServiceProvider sysUiServiceProvider) { + public void onStart(Context context) { mContext = context; mHandler = new Handler(); mTrustManager = (TrustManager) context.getSystemService(Context.TRUST_SERVICE); diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java index 882930bc1049..5f37cc4520a3 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java @@ -45,7 +45,7 @@ public class Recents extends SystemUI implements CommandQueue.Callbacks { @Override public void start() { mCommandQueue.addCallback(this); - mImpl.onStart(mContext, this); + mImpl.onStart(mContext); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImplementation.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImplementation.java index 8cd17e9a1728..1d29ac629cd8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImplementation.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImplementation.java @@ -19,15 +19,13 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.Rect; -import com.android.systemui.SysUiServiceProvider; - import java.io.PrintWriter; /** * API for creating a Recents view. */ public interface RecentsImplementation { - default void onStart(Context context, SysUiServiceProvider sysUiServiceProvider) {} + default void onStart(Context context) {} default void onBootCompleted() {} default void onAppTransitionFinished() {} default void onConfigurationChanged(Configuration newConfig) {} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index eb39a4f3d405..7b2f0025de4a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -148,7 +148,6 @@ import com.android.systemui.bubbles.BubbleController; import com.android.systemui.charging.WirelessChargingAnimation; import com.android.systemui.classifier.FalsingLog; import com.android.systemui.colorextraction.SysuiColorExtractor; -import com.android.systemui.doze.DozeHost; import com.android.systemui.fragments.ExtensionFragmentListener; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.keyguard.DismissCallbackRegistry; @@ -794,7 +793,6 @@ public class StatusBar extends SystemUI implements DemoMode, R.bool.config_vibrateOnIconAnimation); DateTimeView.setReceiverHandler(Dependency.get(Dependency.TIME_TICK_HANDLER)); - putComponent(StatusBar.class, this); // start old BaseStatusBar.start(). mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); @@ -896,7 +894,6 @@ public class StatusBar extends SystemUI implements DemoMode, mDozeServiceHost.initialize(this, mNotificationIconAreaController, mStatusBarWindowViewController, mStatusBarWindow, mStatusBarKeyguardViewManager, mNotificationPanel, mAmbientIndicationContainer); - putComponent(DozeHost.class, mDozeServiceHost); Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(this); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java index 379cf1f273e5..39de0f3f5a9f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java @@ -50,8 +50,6 @@ public class TvStatusBar extends SystemUI implements CommandQueue.Callbacks { @Override public void start() { - putComponent(TvStatusBar.class, this); - final IStatusBarService barService = IStatusBarService.Stub.asInterface( ServiceManager.getService(Context.STATUS_BAR_SERVICE)); mCommandQueue.addCallback(this); diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java index 1e9000b76c3f..ba264c0ae6db 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java @@ -136,7 +136,6 @@ public class ScreenDecorationsTest extends SysuiTestCase { mTestableLooper.processAllMessages(); } }; - mScreenDecorations.mComponents = mContext.getComponents(); reset(mTunerService); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/SysuiTestableContext.java b/packages/SystemUI/tests/src/com/android/systemui/SysuiTestableContext.java index f792d7d11e15..d847208bc4f7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/SysuiTestableContext.java +++ b/packages/SystemUI/tests/src/com/android/systemui/SysuiTestableContext.java @@ -17,13 +17,9 @@ package com.android.systemui; import android.content.Context; import android.testing.LeakCheck; import android.testing.TestableContext; -import android.util.ArrayMap; import android.view.Display; -public class SysuiTestableContext extends TestableContext implements SysUiServiceProvider { - - private ArrayMap<Class<?>, Object> mComponents; - +public class SysuiTestableContext extends TestableContext { public SysuiTestableContext(Context base) { super(base); setTheme(R.style.Theme_SystemUI); @@ -34,21 +30,6 @@ public class SysuiTestableContext extends TestableContext implements SysUiServic setTheme(R.style.Theme_SystemUI); } - public ArrayMap<Class<?>, Object> getComponents() { - if (mComponents == null) mComponents = new ArrayMap<>(); - return mComponents; - } - - @SuppressWarnings("unchecked") - public <T> T getComponent(Class<T> interfaceType) { - return (T) (mComponents != null ? mComponents.get(interfaceType) : null); - } - - public <T, C extends T> void putComponent(Class<T> interfaceType, C component) { - if (mComponents == null) mComponents = new ArrayMap<>(); - mComponents.put(interfaceType, component); - } - @Override public Context createDisplayContext(Display display) { if (display == null) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java index 486fa12e0577..f6375fce8b4e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java @@ -53,7 +53,6 @@ import android.testing.TestableLooper.RunWithLooper; import com.android.internal.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.phone.StatusBar; import org.junit.Before; import org.junit.Test; @@ -88,8 +87,6 @@ public class AuthControllerTest extends SysuiTestCase { TestableContext context = spy(mContext); - mContext.putComponent(StatusBar.class, mock(StatusBar.class)); - when(context.getPackageManager()).thenReturn(mPackageManager); when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)) .thenReturn(true); @@ -104,7 +101,6 @@ public class AuthControllerTest extends SysuiTestCase { mAuthController = new TestableAuthController( context, mock(CommandQueue.class), new MockInjector()); - mAuthController.mComponents = mContext.getComponents(); mAuthController.start(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java index 47b35fdc6dc1..e8f19238fdb8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java @@ -687,7 +687,6 @@ public class PowerUITest extends SysuiTestCase { private void createPowerUi() { mPowerUI = new PowerUI(mContext, mBroadcastDispatcher, mStatusBarLazy); - mPowerUI.mComponents = mContext.getComponents(); mPowerUI.mThermalService = mThermalServiceMock; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java index bc4e401c49e4..8decae33d45b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java @@ -34,8 +34,6 @@ import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiBaseFragmentTest; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.tuner.TunerService; import org.junit.Before; import org.junit.Test; @@ -58,10 +56,8 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { @Before public void setup() { - mSysuiContext.putComponent(CommandQueue.class, mock(CommandQueue.class)); StatusBar statusBar = mock(StatusBar.class); mDependency.injectTestDependency(StatusBar.class, statusBar); - mSysuiContext.putComponent(TunerService.class, mock(TunerService.class)); mStatusBarStateController = mDependency .injectMockDependency(StatusBarStateController.class); injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarButtonTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarButtonTest.java index 098a69f5a897..aae075777506 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarButtonTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarButtonTest.java @@ -18,7 +18,6 @@ package com.android.systemui.statusbar.phone; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; import android.graphics.PixelFormat; import android.hardware.display.DisplayManager; @@ -37,7 +36,6 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestableContext; import com.android.systemui.assist.AssistManager; import com.android.systemui.recents.OverviewProxyService; -import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.policy.KeyguardStateController; import org.junit.After; @@ -60,11 +58,9 @@ public class NavigationBarButtonTest extends SysuiTestCase { @Before public void setup() { - mContext.putComponent(CommandQueue.class, mock(CommandQueue.class)); final Display display = createVirtualDisplay(); final SysuiTestableContext context = (SysuiTestableContext) mContext.createDisplayContext(display); - context.putComponent(CommandQueue.class, mock(CommandQueue.class)); mDependency.injectMockDependency(AssistManager.class); mDependency.injectMockDependency(OverviewProxyService.class); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarInflaterViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarInflaterViewTest.java index 991e49588417..80e33fbc6acb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarInflaterViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarInflaterViewTest.java @@ -33,7 +33,6 @@ import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.assist.AssistManager; import com.android.systemui.recents.OverviewProxyService; -import com.android.systemui.statusbar.CommandQueue; import org.junit.After; import org.junit.Before; @@ -52,7 +51,6 @@ public class NavigationBarInflaterViewTest extends SysuiTestCase { @Before public void setUp() { - mContext.putComponent(CommandQueue.class, mock(CommandQueue.class)); mDependency.injectMockDependency(AssistManager.class); mDependency.injectMockDependency(OverviewProxyService.class); mDependency.injectMockDependency(NavigationModeController.class); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index 95929c3adcb8..af4b34d0fc2e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -389,7 +389,6 @@ public class StatusBarTest extends SysuiTestCase { // TODO: we should be able to call mStatusBar.start() and have all the below values // initialized automatically. - mStatusBar.mComponents = mContext.getComponents(); mStatusBar.mStatusBarWindow = mStatusBarWindowView; mStatusBar.mNotificationPanel = mNotificationPanelView; mStatusBar.mDozeScrimController = mDozeScrimController; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java index 4d4e9ae47d18..e08551abdca2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java @@ -82,7 +82,6 @@ public class StatusBarWindowViewTest extends SysuiTestCase { MockitoAnnotations.initMocks(this); mView = new StatusBarWindowView(getContext(), null); - mContext.putComponent(StatusBar.class, mStatusBar); when(mStatusBar.isDozing()).thenReturn(false); mDependency.injectTestDependency(ShadeController.class, mShadeController); |