diff options
| author | 2019-07-09 01:26:37 +0000 | |
|---|---|---|
| committer | 2019-07-09 01:26:37 +0000 | |
| commit | 01808e09953c129e838347876e5283d2350e48ab (patch) | |
| tree | 6e010d2c0aa9ffbbb6de6fed7e6bee8502952813 | |
| parent | 8413b67587b1dbfce97cedaac0ead368b85c5bd6 (diff) | |
| parent | 2ea5a832021fb21e5924827cde3c8e47518f0d37 (diff) | |
Merge changes from topic "b136279712-daggerize-falsingmanager"
* changes:
Allow Services to be created through Dagger.
Pass FalsingManager down through more classes.
37 files changed, 620 insertions, 152 deletions
diff --git a/packages/CarSystemUI/Android.bp b/packages/CarSystemUI/Android.bp index 589623b0d6cd..61cab73c226a 100644 --- a/packages/CarSystemUI/Android.bp +++ b/packages/CarSystemUI/Android.bp @@ -26,8 +26,8 @@ android_app { ], static_libs: [ - "CarNotificationLib", "SystemUI-core", + "CarNotificationLib", "SystemUIPluginLib", "SystemUISharedLib", "SettingsLib", diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index 358e2cd4ee33..812adf94b8bc 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -61,9 +61,9 @@ import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.SystemUIFactory; import com.android.systemui.classifier.FalsingLog; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.keyguard.ScreenLifecycle; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.qs.QS; import com.android.systemui.qs.car.CarQSFragment; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -877,7 +877,7 @@ public class CarStatusBar extends StatusBar implements KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); } - FalsingManagerFactory.getInstance(mContext).dump(pw); + Dependency.get(FalsingManager.class).dump(pw); FalsingLog.dump(pw); pw.println("SharedPreferences:"); diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 17274f418a1e..4f74605b4003 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -20,6 +20,7 @@ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" package="com.android.systemui" android:sharedUserId="android.uid.systemui" + xmlns:tools="http://schemas.android.com/tools" coreApp="true"> <!-- Using OpenGL ES 2.0 --> @@ -259,7 +260,8 @@ android:theme="@style/Theme.SystemUI" android:defaultToDeviceProtectedStorage="true" android:directBootAware="true" - android:appComponentFactory="androidx.core.app.CoreComponentFactory"> + tools:replace="android:appComponentFactory" + android:appComponentFactory=".SystemUIAppComponentFactory"> <!-- Keep theme in sync with SystemUIApplication.onCreate(). Setting the theme on the application does not affect views inflated by services. The application theme is set again from onCreate to take effect for those views. --> diff --git a/packages/SystemUI/docs/dagger.md b/packages/SystemUI/docs/dagger.md index c2159df1cee1..c440fba10135 100644 --- a/packages/SystemUI/docs/dagger.md +++ b/packages/SystemUI/docs/dagger.md @@ -53,7 +53,7 @@ variants (like other form factors e.g. Car). ### Adding injection to a new SystemUI object Anything that depends on any `@Singleton` provider from SystemUIRootComponent -should be declared as an `@Subcomponent` of the root component, this requires +should be declared as a `@Subcomponent` of the root component. This requires declaring your own interface for generating your own modules or just the object you need injected. The subcomponent also needs to be added to SystemUIRootComponent in SystemUIFactory so it can be acquired. @@ -204,6 +204,13 @@ public CustomView(@Named(VIEW_CONTEXT) Context themedViewContext, AttributeSet a } ``` +## Updating Dagger2 + +Binaries can be downloaded from https://repo1.maven.org/maven2/com/google/dagger/ and then loaded +into +[/prebuilts/tools/common/m2/repository/com/google/dagger/](http://cs/android/prebuilts/tools/common/m2/repository/com/google/dagger/) + + ## TODO List - Eliminate usages of Dependency#get diff --git a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java index 14fd149d22f4..b89218c81a91 100644 --- a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java @@ -41,8 +41,10 @@ import android.widget.ScrollView; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; +import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.recents.LegacyRecentsImpl; import com.android.systemui.recents.RecentsActivity; import com.android.systemui.recents.RecentsActivityLaunchState; @@ -86,15 +88,15 @@ import com.android.systemui.recents.events.ui.focus.NavigateTaskViewEvent; import com.android.systemui.recents.misc.DozeTrigger; import com.android.systemui.recents.misc.ReferenceCountedTrigger; import com.android.systemui.recents.misc.SystemServicesProxy; +import com.android.systemui.recents.model.TaskStack; import com.android.systemui.recents.utilities.AnimationProps; import com.android.systemui.recents.utilities.Utilities; -import com.android.systemui.shared.recents.model.Task; -import com.android.systemui.recents.model.TaskStack; import com.android.systemui.recents.views.grid.GridTaskView; import com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm; import com.android.systemui.recents.views.grid.TaskViewFocusFrame; - +import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.ActivityManagerWrapper; + import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -256,7 +258,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, this); mStableLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, null); mStackScroller = new TaskStackViewScroller(context, this, mLayoutAlgorithm); - mTouchHandler = new TaskStackViewTouchHandler(context, this, mStackScroller); + mTouchHandler = new TaskStackViewTouchHandler( + context, this, mStackScroller, Dependency.get(FalsingManager.class)); mAnimationHelper = new TaskStackAnimationHelper(context, this); mTaskCornerRadiusPx = LegacyRecentsImpl.getConfiguration().isGridEnabled ? res.getDimensionPixelSize(R.dimen.recents_grid_task_view_rounded_corners_radius) : diff --git a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java index dd6926c848b4..a7fb4fae09ec 100644 --- a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java +++ b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java @@ -37,6 +37,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.SwipeHelper; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.recents.Constants; import com.android.systemui.recents.LegacyRecentsImpl; import com.android.systemui.recents.events.EventBus; @@ -107,7 +108,7 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback { boolean mInterceptedBySwipeHelper; public TaskStackViewTouchHandler(Context context, TaskStackView sv, - TaskStackViewScroller scroller) { + TaskStackViewScroller scroller, FalsingManager falsingManager) { Resources res = context.getResources(); ViewConfiguration configuration = ViewConfiguration.get(context); mContext = context; @@ -119,7 +120,7 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback { mWindowTouchSlop = configuration.getScaledWindowTouchSlop(); mFlingAnimUtils = new FlingAnimationUtils(context, 0.2f); mOverscrollSize = res.getDimensionPixelSize(R.dimen.recents_fling_overscroll_distance); - mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, context) { + mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, context, falsingManager) { @Override protected float getSize(View v) { return getScaledDismissSize(); diff --git a/packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java b/packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java new file mode 100644 index 000000000000..8fabe7aa9eb6 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2019 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; + +/** + * Interface necessary to make Dagger happy. See {@link ContextComponentResolver}. + */ +public interface ContextComponentHelper { + /** Turns a classname into an instance of the class or returns null. */ + <T> T resolve(String className); +} diff --git a/packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java b/packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java new file mode 100644 index 000000000000..09bccd993f39 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019 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 java.util.Map; + +import javax.inject.Inject; +import javax.inject.Provider; + +/** + * Used during Service and Activity instantiation to make them injectable. + */ +public class ContextComponentResolver implements ContextComponentHelper { + private final Map<Class<?>, Provider<Object>> mCreators; + + @Inject + ContextComponentResolver(Map<Class<?>, Provider<Object>> creators) { + mCreators = creators; + } + + /** + * Looks up the class name to see if Dagger has an instance of it. + */ + @Override + public <T> T resolve(String className) { + for (Map.Entry<Class<?>, Provider<Object>> p : mCreators.entrySet()) { + if (p.getKey().getName().equals(className)) { + return (T) p.getValue().get(); + } + } + + return null; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/ServiceBinder.java b/packages/SystemUI/src/com/android/systemui/ServiceBinder.java new file mode 100644 index 000000000000..6282c6e5282f --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/ServiceBinder.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 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 com.android.systemui.doze.DozeService; + +import dagger.Binds; +import dagger.Module; +import dagger.multibindings.ClassKey; +import dagger.multibindings.IntoMap; + +/** + * Services and Activities that are injectable should go here. + */ +@Module +public abstract class ServiceBinder { + + @Binds + public abstract ContextComponentHelper bindComponentHelper( + ContextComponentResolver componentHelper); + + @Binds + @IntoMap + @ClassKey(DozeService.class) + public abstract Object bindDozeService(DozeService service); + +} diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 84e0238fdd3a..58c52a1fc50e 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -34,7 +34,6 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.statusbar.FlingAnimationUtils; @@ -98,7 +97,8 @@ public class SwipeHelper implements Gefingerpoken { private final ArrayMap<View, Animator> mDismissPendingMap = new ArrayMap<>(); - public SwipeHelper(int swipeDirection, Callback callback, Context context) { + public SwipeHelper( + int swipeDirection, Callback callback, Context context, FalsingManager falsingManager) { mContext = context; mCallback = callback; mHandler = new Handler(); @@ -113,7 +113,7 @@ public class SwipeHelper implements Gefingerpoken { mDensityScale = res.getDisplayMetrics().density; mFalsingThreshold = res.getDimensionPixelSize(R.dimen.swipe_helper_falsing_threshold); mFadeDependingOnAmountSwiped = res.getBoolean(R.bool.config_fadeDependingOnAmountSwiped); - mFalsingManager = FalsingManagerFactory.getInstance(context); + mFalsingManager = falsingManager; mFlingAnimationUtils = new FlingAnimationUtils(context, getMaxEscapeAnimDuration() / 1000f); } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java new file mode 100644 index 000000000000..00ae99295768 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2019 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.app.Application; +import android.app.Service; +import android.content.Intent; + +import androidx.core.app.CoreComponentFactory; + +import javax.inject.Inject; + +/** + * Implementation of AppComponentFactory that injects into constructors. + */ +public class SystemUIAppComponentFactory extends CoreComponentFactory { + + @Inject + public ContextComponentHelper mComponentHelper; + + public SystemUIAppComponentFactory() { + super(); + } + + @Override + public Application instantiateApplication(ClassLoader cl, String className) + throws InstantiationException, IllegalAccessException, ClassNotFoundException { + Application app = super.instantiateApplication(cl, className); + if (app instanceof SystemUIApplication) { + ((SystemUIApplication) app).setContextAvailableCallback( + context -> { + SystemUIFactory.createFromConfig(context); + SystemUIFactory.getInstance().getRootComponent().inject( + SystemUIAppComponentFactory.this); + } + ); + } + + return app; + } + + @Override + public Service instantiateService(ClassLoader cl, String className, Intent intent) + throws InstantiationException, IllegalAccessException, ClassNotFoundException { + Service service = mComponentHelper.resolve(className); + if (service != null) { + return checkCompatWrapper(service); + } + return super.instantiateService(cl, className, intent); + } + + static <T> T checkCompatWrapper(T obj) { + if (obj instanceof CompatWrapped) { + T wrapper = (T) ((CompatWrapped) obj).getWrapper(); + if (wrapper != null) { + return wrapper; + } + } + + return obj; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index e89e6cb269f8..f8449add6dce 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -60,16 +60,20 @@ public class SystemUIApplication extends Application implements SysUiServiceProv private boolean mServicesStarted; private boolean mBootCompleted; private final Map<Class<?>, Object> mComponents = new HashMap<>(); + private ContextAvailableCallback mContextAvailableCallback; @Override public void onCreate() { super.onCreate(); + // This line is used to setup Dagger's dependency injection and should be kept at the + // top of this method. + mContextAvailableCallback.onContextAvailable(this); + // Set the application theme that is inherited by all services. Note that setting the // application theme in the manifest does only work for activities. Keep this in sync with // the theme set there. setTheme(R.style.Theme_SystemUI); - SystemUIFactory.createFromConfig(this); if (Process.myUserHandle().equals(UserHandle.SYSTEM)) { IntentFilter bootCompletedFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED); @@ -286,4 +290,12 @@ public class SystemUIApplication extends Application implements SysUiServiceProv public SystemUI[] getServices() { return mServices; } + + void setContextAvailableCallback(ContextAvailableCallback callback) { + mContextAvailableCallback = callback; + } + + interface ContextAvailableCallback { + void onContextAvailable(Context context); + } } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java index 4d42e0c66817..311ed8a913f1 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java @@ -19,8 +19,8 @@ package com.android.systemui; import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME; import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME; -import android.annotation.Nullable; import android.annotation.NonNull; +import android.annotation.Nullable; import android.app.AlarmManager; import android.content.Context; import android.content.pm.PackageManager; @@ -29,17 +29,15 @@ import android.os.Looper; import android.util.Log; import android.view.ViewGroup; - import com.android.internal.colorextraction.ColorExtractor.GradientColors; import com.android.internal.util.function.TriConsumer; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.assist.AssistManager; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.dock.DockManager; -import com.android.systemui.fragments.FragmentService; import com.android.systemui.keyguard.DismissCallbackRegistry; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.power.EnhancedEstimates; import com.android.systemui.power.EnhancedEstimatesImpl; @@ -69,8 +67,6 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.UnlockMethodCache; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.util.AsyncSensorManager; -import com.android.systemui.util.InjectionInflationController; -import com.android.systemui.util.leak.GarbageMonitor; import com.android.systemui.volume.VolumeDialogComponent; import java.util.function.Consumer; @@ -78,7 +74,6 @@ import java.util.function.Consumer; import javax.inject.Named; import javax.inject.Singleton; -import dagger.Component; import dagger.Module; import dagger.Provides; @@ -116,7 +111,7 @@ public class SystemUIFactory { public SystemUIFactory() {} protected void init(Context context) { - initWithRootComponent(DaggerSystemUIFactory_SystemUIRootComponent.builder() + initWithRootComponent(DaggerSystemUIRootComponent.builder() .systemUIFactory(this) .dependencyProvider(new com.android.systemui.DependencyProvider()) .contextHolder(new ContextHolder(context)) @@ -143,9 +138,10 @@ public class SystemUIFactory { public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback, LockPatternUtils lockPatternUtils, ViewGroup container, DismissCallbackRegistry dismissCallbackRegistry, - KeyguardBouncer.BouncerExpansionCallback expansionCallback) { + KeyguardBouncer.BouncerExpansionCallback expansionCallback, + FalsingManager falsingManager) { return new KeyguardBouncer(context, callback, lockPatternUtils, container, - dismissCallbackRegistry, FalsingManagerFactory.getInstance(context), + dismissCallbackRegistry, falsingManager, expansionCallback, UnlockMethodCache.getInstance(context), KeyguardUpdateMonitor.getInstance(context), new Handler(Looper.getMainLooper())); } @@ -276,29 +272,4 @@ public class SystemUIFactory { return mContext; } } - - @Singleton - @Component(modules = {SystemUIFactory.class, DependencyProvider.class, DependencyBinder.class, - ContextHolder.class}) - public interface SystemUIRootComponent { - @Singleton - Dependency.DependencyInjector createDependency(); - - @Singleton - StatusBar.StatusBarInjector getStatusBarInjector(); - - /** - * FragmentCreator generates all Fragments that need injection. - */ - @Singleton - FragmentService.FragmentCreator createFragmentCreator(); - - /** - * ViewCreator generates all Views that need injection. - */ - InjectionInflationController.ViewCreator createViewCreator(); - - @Singleton - GarbageMonitor createGarbageMonitor(); - } } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java b/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java new file mode 100644 index 000000000000..c732df3fdb9f --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2019 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 com.android.systemui.fragments.FragmentService; +import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.util.InjectionInflationController; +import com.android.systemui.util.leak.GarbageMonitor; + +import javax.inject.Singleton; + +import dagger.Component; + +/** + * Root component for Dagger injection. + */ +@Singleton +@Component(modules = {SystemUIFactory.class, DependencyProvider.class, DependencyBinder.class, + ServiceBinder.class, SystemUIFactory.ContextHolder.class}) +public interface SystemUIRootComponent { + /** + * Main dependency providing module. + */ + @Singleton + Dependency.DependencyInjector createDependency(); + + /** + * Injects the StatusBar. + */ + @Singleton + StatusBar.StatusBarInjector getStatusBarInjector(); + + /** + * FragmentCreator generates all Fragments that need injection. + */ + @Singleton + FragmentService.FragmentCreator createFragmentCreator(); + + /** + * ViewCreator generates all Views that need injection. + */ + InjectionInflationController.ViewCreator createViewCreator(); + + /** + * Creatse a GarbageMonitor. + */ + @Singleton + GarbageMonitor createGarbageMonitor(); + + /** + * Injects into the supplied argument. + */ + void inject(SystemUIAppComponentFactory factory); +} diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFactory.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFactory.java deleted file mode 100644 index 01921f0d9a60..000000000000 --- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2015 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.classifier; - -import android.content.Context; - -import com.android.systemui.Dependency; -import com.android.systemui.plugins.FalsingManager; - -/** - * When the phone is locked, listens to touch, sensor and phone events and sends them to - * DataCollector and HumanInteractionClassifier. - * - * It does not collect touch events when the bouncer shows up. - * - * TODO: FalsingManager supports dependency injection. Use it. - */ -public class FalsingManagerFactory { - private static FalsingManager sInstance = null; - - private FalsingManagerFactory() {} - - public static FalsingManager getInstance(Context context) { - if (sInstance == null) { - sInstance = Dependency.get(FalsingManager.class); - } - return sInstance; - } - -} diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFake.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFake.java new file mode 100644 index 000000000000..0041b0c9a469 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFake.java @@ -0,0 +1,242 @@ +/* + * Copyright (C) 2019 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.classifier; + +import android.net.Uri; +import android.view.MotionEvent; + +import com.android.internal.annotations.VisibleForTesting; +import com.android.systemui.plugins.FalsingManager; + +import java.io.PrintWriter; + +/** + * Simple Fake for testing where {@link FalsingManager} is required. + */ +public class FalsingManagerFake implements FalsingManager { + private boolean mIsFalseTouch; + private boolean mIsUnlockingDisabled; + private boolean mIsClassiferEnabled; + private boolean mShouldEnforceBouncer; + private boolean mIsReportingEnabled; + + @Override + public void onSucccessfulUnlock() { + + } + + @Override + public void onNotificationActive() { + + } + + @Override + public void setShowingAod(boolean showingAod) { + + } + + @Override + public void onNotificatonStartDraggingDown() { + + } + + @VisibleForTesting + public void setIsUnlockingDisabled(boolean isUnlockingDisabled) { + mIsUnlockingDisabled = isUnlockingDisabled; + } + + @Override + public boolean isUnlockingDisabled() { + return mIsUnlockingDisabled; + } + + @VisibleForTesting + public void setIsFalseTouch(boolean isFalseTouch) { + mIsFalseTouch = isFalseTouch; + } + + @Override + public boolean isFalseTouch() { + return mIsFalseTouch; + } + + @Override + public void onNotificatonStopDraggingDown() { + + } + + @Override + public void setNotificationExpanded() { + + } + + @VisibleForTesting + public void setIsClassiferEnabled(boolean isClassiferEnabled) { + mIsClassiferEnabled = isClassiferEnabled; + } + + @Override + public boolean isClassiferEnabled() { + return mIsClassiferEnabled; + } + + @Override + public void onQsDown() { + + } + + @Override + public void setQsExpanded(boolean expanded) { + + } + + @VisibleForTesting + public void setShouldEnforceBouncer(boolean shouldEnforceBouncer) { + mShouldEnforceBouncer = shouldEnforceBouncer; + } + + @Override + public boolean shouldEnforceBouncer() { + return mShouldEnforceBouncer; + } + + @Override + public void onTrackingStarted(boolean secure) { + + } + + @Override + public void onTrackingStopped() { + + } + + @Override + public void onLeftAffordanceOn() { + + } + + @Override + public void onCameraOn() { + + } + + @Override + public void onAffordanceSwipingStarted(boolean rightCorner) { + + } + + @Override + public void onAffordanceSwipingAborted() { + + } + + @Override + public void onStartExpandingFromPulse() { + + } + + @Override + public void onExpansionFromPulseStopped() { + + } + + @Override + public Uri reportRejectedTouch() { + return null; + } + + @Override + public void onScreenOnFromTouch() { + + } + + + @VisibleForTesting + public void setIsReportingEnabled(boolean isReportingEnabled) { + mIsReportingEnabled = isReportingEnabled; + } + + @Override + public boolean isReportingEnabled() { + return mIsReportingEnabled; + } + + @Override + public void onUnlockHintStarted() { + + } + + @Override + public void onCameraHintStarted() { + + } + + @Override + public void onLeftAffordanceHintStarted() { + + } + + @Override + public void onScreenTurningOn() { + + } + + @Override + public void onScreenOff() { + + } + + @Override + public void onNotificatonStopDismissing() { + + } + + @Override + public void onNotificationDismissed() { + + } + + @Override + public void onNotificatonStartDismissing() { + + } + + @Override + public void onNotificationDoubleTap(boolean accepted, float dx, float dy) { + + } + + @Override + public void onBouncerShown() { + + } + + @Override + public void onBouncerHidden() { + + } + + @Override + public void onTouchEvent(MotionEvent ev, int width, int height) { + + } + + @Override + public void dump(PrintWriter pw) { + + } +} diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java index fc3d1a52342f..537c09ed3199 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java @@ -28,8 +28,8 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SystemUIApplication; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.dock.DockManager; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.AsyncSensorManager; import com.android.systemui.util.wakelock.DelayedWakeLock; @@ -41,7 +41,7 @@ public class DozeFactory { } /** Creates a DozeMachine with its parts for {@code dozeService}. */ - public DozeMachine assembleMachine(DozeService dozeService) { + public DozeMachine assembleMachine(DozeService dozeService, FalsingManager falsingManager) { Context context = dozeService; SensorManager sensorManager = Dependency.get(AsyncSensorManager.class); AlarmManager alarmManager = context.getSystemService(AlarmManager.class); @@ -63,7 +63,7 @@ public class DozeFactory { DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock); machine.setParts(new DozeMachine.Part[]{ new DozePauser(handler, machine, alarmManager, params.getPolicy()), - new DozeFalsingManagerAdapter(FalsingManagerFactory.getInstance(context)), + new DozeFalsingManagerAdapter(falsingManager), createDozeTriggers(context, sensorManager, host, alarmManager, config, params, handler, wakeLock, machine, dockManager), createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params), diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java index 2db73065fe19..e92acfc7f219 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java @@ -25,23 +25,29 @@ import android.util.Log; import com.android.systemui.Dependency; import com.android.systemui.plugins.DozeServicePlugin; import com.android.systemui.plugins.DozeServicePlugin.RequestDoze; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.PluginListener; import com.android.systemui.shared.plugins.PluginManager; import java.io.FileDescriptor; import java.io.PrintWriter; +import javax.inject.Inject; + public class DozeService extends DreamService implements DozeMachine.Service, RequestDoze, PluginListener<DozeServicePlugin> { private static final String TAG = "DozeService"; static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + private final FalsingManager mFalsingManager; private DozeMachine mDozeMachine; private DozeServicePlugin mDozePlugin; private PluginManager mPluginManager; - public DozeService() { + @Inject + public DozeService(FalsingManager falsingManager) { setDebug(DEBUG); + mFalsingManager = falsingManager; } @Override @@ -56,7 +62,7 @@ public class DozeService extends DreamService } mPluginManager = Dependency.get(PluginManager.class); mPluginManager.addPluginListener(this, DozeServicePlugin.class, false /* allowMultiple */); - mDozeMachine = new DozeFactory().assembleMachine(this); + mDozeMachine = new DozeFactory().assembleMachine(this, mFalsingManager); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java b/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java index 8dbaf0f681cf..b4cc571be061 100644 --- a/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java +++ b/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java @@ -22,7 +22,7 @@ import android.view.View; import com.android.systemui.ConfigurationChangedReceiver; import com.android.systemui.Dumpable; -import com.android.systemui.SystemUIFactory; +import com.android.systemui.SystemUIRootComponent; import com.android.systemui.qs.QSFragment; import com.android.systemui.statusbar.phone.NavigationBarFragment; @@ -51,7 +51,7 @@ public class FragmentService implements ConfigurationChangedReceiver, Dumpable { private final FragmentCreator mFragmentCreator; @Inject - public FragmentService(SystemUIFactory.SystemUIRootComponent rootComponent) { + public FragmentService(SystemUIRootComponent rootComponent) { mFragmentCreator = rootComponent.createFragmentCreator(); initInjectionMap(); } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 4dcb9f94088c..819ce5f317e8 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -84,7 +84,7 @@ import com.android.systemui.Dependency; import com.android.systemui.SystemUI; import com.android.systemui.SystemUIFactory; import com.android.systemui.UiOffloadThread; -import com.android.systemui.classifier.FalsingManagerFactory; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationPanelView; @@ -1596,7 +1596,7 @@ public class KeyguardViewMediator extends SystemUI { Trace.beginSection("KeyguardViewMediator#handleMessage START_KEYGUARD_EXIT_ANIM"); StartKeyguardExitAnimParams params = (StartKeyguardExitAnimParams) msg.obj; handleStartKeyguardExitAnimation(params.startTime, params.fadeoutDuration); - FalsingManagerFactory.getInstance(mContext).onSucccessfulUnlock(); + Dependency.get(FalsingManager.class).onSucccessfulUnlock(); Trace.endSection(); break; case KEYGUARD_DONE_PENDING_TIMEOUT: @@ -2063,10 +2063,11 @@ public class KeyguardViewMediator extends SystemUI { public StatusBarKeyguardViewManager registerStatusBar(StatusBar statusBar, ViewGroup container, NotificationPanelView panelView, BiometricUnlockController biometricUnlockController, ViewGroup lockIconContainer, - View notificationContainer, KeyguardBypassController bypassController) { + View notificationContainer, KeyguardBypassController bypassController, + FalsingManager falsingManager) { mStatusBarKeyguardViewManager.registerStatusBar(statusBar, container, panelView, biometricUnlockController, mDismissCallbackRegistry, lockIconContainer, - notificationContainer, bypassController); + notificationContainer, bypassController, falsingManager); return mStatusBarKeyguardViewManager; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java index 514a2ae7a74e..d93982889655 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java @@ -29,7 +29,6 @@ import com.android.systemui.ExpandHelper; import com.android.systemui.Gefingerpoken; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.notification.row.ExpandableView; @@ -59,14 +58,15 @@ public class DragDownHelper implements Gefingerpoken { private FalsingManager mFalsingManager; public DragDownHelper(Context context, View host, ExpandHelper.Callback callback, - DragDownCallback dragDownCallback) { + DragDownCallback dragDownCallback, + FalsingManager falsingManager) { mMinDragDistance = context.getResources().getDimensionPixelSize( R.dimen.keyguard_drag_down_min_distance); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mCallback = callback; mDragDownCallback = dragDownCallback; mHost = host; - mFalsingManager = FalsingManagerFactory.getInstance(context); + mFalsingManager = falsingManager; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt index 986486ac14d4..48d6de964b08 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt @@ -27,11 +27,11 @@ import android.os.SystemClock import android.view.MotionEvent import android.view.VelocityTracker import android.view.ViewConfiguration +import com.android.systemui.Dependency import com.android.systemui.Gefingerpoken import com.android.systemui.Interpolators import com.android.systemui.R -import com.android.systemui.classifier.FalsingManagerFactory import com.android.systemui.plugins.FalsingManager import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow @@ -115,7 +115,7 @@ constructor(context: Context, mMinDragDistance = context.resources.getDimensionPixelSize( R.dimen.keyguard_drag_down_min_distance) mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop.toFloat() - mFalsingManager = FalsingManagerFactory.getInstance(context) + mFalsingManager = Dependency.get(FalsingManager::class.java) mPowerManager = context.getSystemService(PowerManager::class.java) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index dca152fbe37a..8d7325118139 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -33,9 +33,9 @@ import android.view.accessibility.AccessibilityManager; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; +import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.notification.FakeShadowView; @@ -130,7 +130,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView private boolean mLastInSection; private boolean mFirstInSection; private boolean mIsBelowSpeedBump; - private FalsingManager mFalsingManager; + private final FalsingManager mFalsingManager; private float mNormalBackgroundVisibilityAmount; private float mDimmedBackgroundFadeInAmount = -1; @@ -164,10 +164,10 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView super(context, attrs); mSlowOutFastInInterpolator = new PathInterpolator(0.8f, 0.0f, 0.6f, 1.0f); mSlowOutLinearInInterpolator = new PathInterpolator(0.8f, 0.0f, 1.0f, 1.0f); + mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller. setClipChildren(false); setClipToPadding(false); updateColors(); - mFalsingManager = FalsingManagerFactory.getInstance(context); mAccessibilityManager = AccessibilityManager.getInstance(mContext); mDoubleTapHelper = new DoubleTapHelper(this, (active) -> { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index a8327f63dcf7..6e84089e8ff5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -74,7 +74,6 @@ import com.android.internal.widget.CachingIconView; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; @@ -1635,7 +1634,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public ExpandableNotificationRow(Context context, AttributeSet attrs) { super(context, attrs); - mFalsingManager = FalsingManagerFactory.getInstance(context); + mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller. mNotificationInflater = new NotificationContentInflater(this); mMenuRow = new NotificationMenuRow(mContext); mImageResolver = new NotificationInlineImageResolver(context, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index b654cd6569fe..bec95201e4b2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -86,7 +86,6 @@ import com.android.systemui.ExpandHelper; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.SwipeHelper; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.FalsingManager; @@ -512,7 +511,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd ActivityStarter activityStarter, StatusBarStateController statusBarStateController, HeadsUpManagerPhone headsUpManager, - KeyguardBypassController keyguardBypassController) { + KeyguardBypassController keyguardBypassController, + FalsingManager falsingManager) { super(context, attrs, 0, 0); Resources res = getResources(); @@ -527,6 +527,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd mHeadsUpManager.addListener(mRoundnessManager); mHeadsUpManager.setAnimationStateHandler(this::setHeadsUpGoingAwayAnimationsAllowed); mKeyguardBypassController = keyguardBypassController; + mFalsingManager = falsingManager; mSectionsManager = new NotificationSectionsManager( @@ -551,10 +552,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd mExpandHelper.setEventSource(this); mExpandHelper.setScrollAdapter(this); mSwipeHelper = new NotificationSwipeHelper(SwipeHelper.X, mNotificationCallback, - getContext(), mMenuEventListener); + getContext(), mMenuEventListener, mFalsingManager); mStackScrollAlgorithm = createStackScrollAlgorithm(context); initView(context); - mFalsingManager = FalsingManagerFactory.getInstance(context); mShouldDrawNotificationBackground = res.getBoolean(R.bool.config_drawNotificationBackground); mFadeNotificationsOnDismiss = diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java index 4dfc343df283..0968674d31cc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java @@ -28,6 +28,7 @@ import android.view.View; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.SwipeHelper; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; @@ -50,9 +51,11 @@ class NotificationSwipeHelper extends SwipeHelper private boolean mIsExpanded; private boolean mPulsing; - public NotificationSwipeHelper(int swipeDirection, NotificationCallback callback, - Context context, NotificationMenuRowPlugin.OnMenuEventListener menuListener) { - super(swipeDirection, callback, context); + NotificationSwipeHelper( + int swipeDirection, NotificationCallback callback, Context context, + NotificationMenuRowPlugin.OnMenuEventListener menuListener, + FalsingManager falsingManager) { + super(swipeDirection, callback, context, falsingManager); mMenuListener = menuListener; mCallback = callback; mFalsingCheck = new Runnable() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java index 4691a31fad21..66b1dd8db123 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java @@ -27,7 +27,6 @@ import android.view.ViewConfiguration; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.FlingAnimationUtils; import com.android.systemui.statusbar.KeyguardAffordanceView; @@ -59,7 +58,7 @@ public class KeyguardAffordanceHelper { private KeyguardAffordanceView mLeftIcon; private KeyguardAffordanceView mRightIcon; private Animator mSwipeAnimator; - private FalsingManager mFalsingManager; + private final FalsingManager mFalsingManager; private int mMinBackgroundRadius; private boolean mMotionCancelled; private int mTouchTargetSize; @@ -80,12 +79,13 @@ public class KeyguardAffordanceHelper { } }; - KeyguardAffordanceHelper(Callback callback, Context context) { + KeyguardAffordanceHelper(Callback callback, Context context, FalsingManager falsingManager) { mContext = context; mCallback = callback; initIcons(); updateIcon(mLeftIcon, 0.0f, mLeftIcon.getRestingAlpha(), false, false, true, false); updateIcon(mRightIcon, 0.0f, mRightIcon.getRestingAlpha(), false, false, true, false); + mFalsingManager = falsingManager; initDimens(); } @@ -102,7 +102,6 @@ public class KeyguardAffordanceHelper { mHintGrowAmount = mContext.getResources().getDimensionPixelSize(R.dimen.hint_grow_amount_sideways); mFlingAnimationUtils = new FlingAnimationUtils(mContext, 0.4f); - mFalsingManager = FalsingManagerFactory.getInstance(mContext); } private void initIcons() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 7430f7cc2cd1..f64fc81f37ef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -61,7 +61,6 @@ import com.android.systemui.DejankUtils; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentHostManager.FragmentListener; import com.android.systemui.plugins.FalsingManager; @@ -381,11 +380,12 @@ public class NotificationPanelView extends PanelView implements NotificationWakeUpCoordinator coordinator, PulseExpansionHandler pulseExpansionHandler, DynamicPrivacyController dynamicPrivacyController, - KeyguardBypassController bypassController) { + KeyguardBypassController bypassController, + FalsingManager falsingManager) { super(context, attrs); setWillNotDraw(!DEBUG); mInjectionInflationController = injectionInflationController; - mFalsingManager = FalsingManagerFactory.getInstance(context); + mFalsingManager = falsingManager; mPowerManager = context.getSystemService(PowerManager.class); mWakeUpCoordinator = coordinator; mAccessibilityManager = context.getSystemService(AccessibilityManager.class); @@ -610,7 +610,7 @@ public class NotificationPanelView extends PanelView implements } private void initBottomArea() { - mAffordanceHelper = new KeyguardAffordanceHelper(this, getContext()); + mAffordanceHelper = new KeyguardAffordanceHelper(this, getContext(), mFalsingManager); mKeyguardBottomArea.setAffordanceHelper(mAffordanceHelper); mKeyguardBottomArea.setStatusBar(mStatusBar); mKeyguardBottomArea.setUserSetupComplete(mUserSetupComplete); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index a5b221bbad8c..853faabbbc81 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -42,7 +42,6 @@ import com.android.systemui.DejankUtils; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.doze.DozeLog; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; @@ -110,7 +109,7 @@ public abstract class PanelView extends FrameLayout { private FlingAnimationUtils mFlingAnimationUtils; private FlingAnimationUtils mFlingAnimationUtilsClosing; private FlingAnimationUtils mFlingAnimationUtilsDismissing; - private FalsingManager mFalsingManager; + private final FalsingManager mFalsingManager; private final VibratorHelper mVibratorHelper; /** @@ -213,7 +212,7 @@ public abstract class PanelView extends FrameLayout { 0.5f /* maxLengthSeconds */, 0.2f /* speedUpFactor */, 0.6f /* x2 */, 0.84f /* y2 */); mBounceInterpolator = new BounceInterpolator(); - mFalsingManager = FalsingManagerFactory.getInstance(context); + mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller. mNotificationsDragEnabled = getResources().getBoolean(R.bool.config_enableNotificationShadeDrag); mVibratorHelper = Dependency.get(VibratorHelper.class); 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 4392c35ee233..0970f2a7ae67 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -147,7 +147,6 @@ import com.android.systemui.assist.AssistManager; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.charging.WirelessChargingAnimation; import com.android.systemui.classifier.FalsingLog; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.doze.DozeHost; import com.android.systemui.doze.DozeLog; @@ -695,6 +694,7 @@ public class StatusBar extends SystemUI implements DemoMode, mRecents = getComponent(Recents.class); mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); + mFalsingManager = Dependency.get(FalsingManager.class); // Connect in to the status bar manager service mCommandQueue = getComponent(CommandQueue.class); @@ -770,7 +770,6 @@ public class StatusBar extends SystemUI implements DemoMode, putComponent(DozeHost.class, mDozeServiceHost); mScreenPinningRequest = new ScreenPinningRequest(mContext); - mFalsingManager = FalsingManagerFactory.getInstance(mContext); Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(this); @@ -1233,7 +1232,7 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, getBouncerContainer(), mNotificationPanel, mBiometricUnlockController, mStatusBarWindow.findViewById(R.id.lock_icon_container), mStackScroller, - mKeyguardBypassController); + mKeyguardBypassController, mFalsingManager); mKeyguardIndicationController .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); @@ -2390,7 +2389,7 @@ public class StatusBar extends SystemUI implements DemoMode, mKeyguardUpdateMonitor.dump(fd, pw, args); } - FalsingManagerFactory.getInstance(mContext).dump(pw); + Dependency.get(FalsingManager.class).dump(pw); FalsingLog.dump(pw); pw.println("SharedPreferences:"); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index f810293a34ac..d67818273ef2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -44,6 +44,7 @@ import com.android.systemui.Dependency; import com.android.systemui.SystemUIFactory; import com.android.systemui.dock.DockManager; import com.android.systemui.keyguard.DismissCallbackRegistry; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.statusbar.CommandQueue; @@ -211,7 +212,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb BiometricUnlockController biometricUnlockController, DismissCallbackRegistry dismissCallbackRegistry, ViewGroup lockIconContainer, View notificationContainer, - KeyguardBypassController bypassController) { + KeyguardBypassController bypassController, FalsingManager falsingManager) { mStatusBar = statusBar; mContainer = container; mLockIconContainer = lockIconContainer; @@ -221,7 +222,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mBiometricUnlockController = biometricUnlockController; mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext, mViewMediatorCallback, mLockPatternUtils, container, dismissCallbackRegistry, - mExpansionCallback); + mExpansionCallback, falsingManager); mNotificationPanelView = notificationPanelView; notificationPanelView.setExpansionListener(this); mBypassController = bypassController; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 94054188d769..f1049f005dea 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -62,7 +62,6 @@ import com.android.internal.widget.FloatingToolbar; import com.android.systemui.Dependency; import com.android.systemui.ExpandHelper; import com.android.systemui.R; -import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.DragDownHelper; @@ -156,7 +155,7 @@ public class StatusBarWindowView extends FrameLayout { setMotionEventSplittingEnabled(false); mTransparentSrcPaint.setColor(0); mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); - mFalsingManager = FalsingManagerFactory.getInstance(context); + mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller. mGestureDetector = new GestureDetector(context, mGestureListener); mStatusBarStateController = Dependency.get(StatusBarStateController.class); Dependency.get(TunerService.class).addTunable(mTunable, @@ -290,7 +289,7 @@ public class StatusBarWindowView extends FrameLayout { ExpandHelper.Callback expandHelperCallback = stackScrollLayout.getExpandHelperCallback(); DragDownHelper.DragDownCallback dragDownCallback = stackScrollLayout.getDragDownCallback(); setDragDownHelper(new DragDownHelper(getContext(), this, expandHelperCallback, - dragDownCallback)); + dragDownCallback, mFalsingManager)); } @VisibleForTesting diff --git a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java index ede30046d6c3..9b264c4a326e 100644 --- a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java +++ b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java @@ -26,7 +26,7 @@ import android.view.View; import com.android.keyguard.KeyguardClockSwitch; import com.android.keyguard.KeyguardMessageArea; import com.android.keyguard.KeyguardSliceView; -import com.android.systemui.SystemUIFactory; +import com.android.systemui.SystemUIRootComponent; import com.android.systemui.qs.QSCarrierGroup; import com.android.systemui.qs.QSFooterImpl; import com.android.systemui.qs.QSPanel; @@ -62,7 +62,7 @@ public class InjectionInflationController { private final LayoutInflater.Factory2 mFactory = new InjectionFactory(); @Inject - public InjectionInflationController(SystemUIFactory.SystemUIRootComponent rootComponent) { + public InjectionInflationController(SystemUIRootComponent rootComponent) { mViewCreator = rootComponent.createViewCreator(); initInjectionMap(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 92173ccbad2e..c1911eef6671 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -53,6 +53,7 @@ import com.android.systemui.ExpandHelper; import com.android.systemui.InitController; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; +import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.EmptyShadeView; @@ -79,7 +80,6 @@ import com.android.systemui.statusbar.phone.StatusBarTest.TestableNotificationEn import com.android.systemui.statusbar.policy.ConfigurationController; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -164,7 +164,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mock(ActivityStarterDelegate.class), mock(StatusBarStateController.class), mHeadsUpManager, - mKeyguardBypassController); + mKeyguardBypassController, + new FalsingManagerFake()); mStackScroller = spy(mStackScrollerInternal); mStackScroller.setShelf(notificationShelf); mStackScroller.setStatusBar(mBar); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java index b24c3ddc1199..06a2eecd208c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java @@ -40,6 +40,7 @@ import androidx.test.filters.SmallTest; import com.android.systemui.SwipeHelper; import com.android.systemui.SysuiTestCase; +import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; @@ -76,7 +77,8 @@ public class NotificationSwipeHelperTest extends SysuiTestCase { public void setUp() throws Exception { mCallback = mock(NotificationSwipeHelper.NotificationCallback.class); mListener = mock(NotificationMenuRowPlugin.OnMenuEventListener.class); - mSwipeHelper = spy(new NotificationSwipeHelper(SwipeHelper.X, mCallback, mContext, mListener)); + mSwipeHelper = spy(new NotificationSwipeHelper( + SwipeHelper.X, mCallback, mContext, mListener, new FalsingManagerFake())); mView = mock(View.class); mEvent = mock(MotionEvent.class); mMenuRow = mock(NotificationMenuRowPlugin.class); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index d14b460d8c63..a96efd7d2fc2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -36,6 +36,7 @@ import androidx.test.filters.SmallTest; import com.android.keyguard.KeyguardStatusView; import com.android.systemui.SystemUIFactory; import com.android.systemui.SysuiTestCase; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.KeyguardAffordanceView; import com.android.systemui.statusbar.NotificationLockscreenUserManager; @@ -98,6 +99,8 @@ public class NotificationPanelViewTest extends SysuiTestCase { private PanelBar mPanelBar; @Mock private KeyguardAffordanceHelper mAffordanceHelper; + @Mock + private FalsingManager mFalsingManager; private NotificationPanelView mNotificationPanelView; @Before @@ -191,7 +194,8 @@ public class NotificationPanelViewTest extends SysuiTestCase { new InjectionInflationController( SystemUIFactory.getInstance().getRootComponent()), coordinator, expansionHandler, mock(DynamicPrivacyController.class), - bypassController); + bypassController, + mFalsingManager); mNotificationStackScroller = mNotificationStackScrollLayout; mKeyguardStatusView = NotificationPanelViewTest.this.mKeyguardStatusView; mKeyguardStatusBar = NotificationPanelViewTest.this.mKeyguardStatusBar; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java index da2e8dc90854..63f653b0b303 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java @@ -39,8 +39,10 @@ import androidx.test.filters.SmallTest; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.SysuiTestCase; +import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -93,7 +95,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { mViewMediatorCallback, mLockPatternUtils); mStatusBarKeyguardViewManager.registerStatusBar(mStatusBar, mContainer, mNotificationPanelView, mBiometrucUnlockController, mDismissCallbackRegistry, - mLockIconContainer, mNotificationContainer, mBypassController); + mLockIconContainer, mNotificationContainer, mBypassController, + new FalsingManagerFake()); mStatusBarKeyguardViewManager.show(null); } @@ -232,11 +235,11 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { BiometricUnlockController fingerprintUnlockController, DismissCallbackRegistry dismissCallbackRegistry, ViewGroup lockIconContainer, View notificationContainer, - KeyguardBypassController bypassController) { + KeyguardBypassController bypassController, FalsingManager falsingManager) { super.registerStatusBar(statusBar, container, notificationPanelView, fingerprintUnlockController, dismissCallbackRegistry, lockIconContainer, - notificationContainer, bypassController); + notificationContainer, bypassController, falsingManager); mBouncer = StatusBarKeyguardViewManagerTest.this.mBouncer; } } -}
\ No newline at end of file +} |