1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.notification.collection.init; 18 19 import android.util.Log; 20 21 import com.android.systemui.Dumpable; 22 import com.android.systemui.dagger.SysUISingleton; 23 import com.android.systemui.dump.DumpManager; 24 import com.android.systemui.flags.FeatureFlags; 25 import com.android.systemui.statusbar.NotificationListener; 26 import com.android.systemui.statusbar.notification.collection.NotifCollection; 27 import com.android.systemui.statusbar.notification.collection.NotifInflaterImpl; 28 import com.android.systemui.statusbar.notification.collection.NotifPipeline; 29 import com.android.systemui.statusbar.notification.collection.ShadeListBuilder; 30 import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer; 31 import com.android.systemui.statusbar.notification.collection.coordinator.NotifCoordinators; 32 import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; 33 import com.android.systemui.statusbar.notification.collection.render.ShadeViewManagerFactory; 34 import com.android.systemui.statusbar.notification.stack.NotificationListContainer; 35 36 import java.io.FileDescriptor; 37 import java.io.PrintWriter; 38 39 import javax.inject.Inject; 40 41 /** 42 * Initialization code for the new notification pipeline. 43 */ 44 @SysUISingleton 45 public class NotifPipelineInitializer implements Dumpable { 46 private final NotifPipeline mPipelineWrapper; 47 private final GroupCoalescer mGroupCoalescer; 48 private final NotifCollection mNotifCollection; 49 private final ShadeListBuilder mListBuilder; 50 private final NotifCoordinators mNotifPluggableCoordinators; 51 private final NotifInflaterImpl mNotifInflater; 52 private final DumpManager mDumpManager; 53 private final ShadeViewManagerFactory mShadeViewManagerFactory; 54 private final FeatureFlags mFeatureFlags; 55 56 57 @Inject NotifPipelineInitializer( NotifPipeline pipelineWrapper, GroupCoalescer groupCoalescer, NotifCollection notifCollection, ShadeListBuilder listBuilder, NotifCoordinators notifCoordinators, NotifInflaterImpl notifInflater, DumpManager dumpManager, ShadeViewManagerFactory shadeViewManagerFactory, FeatureFlags featureFlags)58 public NotifPipelineInitializer( 59 NotifPipeline pipelineWrapper, 60 GroupCoalescer groupCoalescer, 61 NotifCollection notifCollection, 62 ShadeListBuilder listBuilder, 63 NotifCoordinators notifCoordinators, 64 NotifInflaterImpl notifInflater, 65 DumpManager dumpManager, 66 ShadeViewManagerFactory shadeViewManagerFactory, 67 FeatureFlags featureFlags) { 68 mPipelineWrapper = pipelineWrapper; 69 mGroupCoalescer = groupCoalescer; 70 mNotifCollection = notifCollection; 71 mListBuilder = listBuilder; 72 mNotifPluggableCoordinators = notifCoordinators; 73 mDumpManager = dumpManager; 74 mNotifInflater = notifInflater; 75 mShadeViewManagerFactory = shadeViewManagerFactory; 76 mFeatureFlags = featureFlags; 77 } 78 79 /** Hooks the new pipeline up to NotificationManager */ initialize( NotificationListener notificationService, NotificationRowBinderImpl rowBinder, NotificationListContainer listContainer)80 public void initialize( 81 NotificationListener notificationService, 82 NotificationRowBinderImpl rowBinder, 83 NotificationListContainer listContainer) { 84 85 mDumpManager.registerDumpable("NotifPipeline", this); 86 87 // Setup inflation 88 if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) { 89 mNotifInflater.setRowBinder(rowBinder); 90 } 91 92 // Wire up coordinators 93 mNotifPluggableCoordinators.attach(mPipelineWrapper); 94 95 // Wire up pipeline 96 if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) { 97 mShadeViewManagerFactory.create(listContainer).attach(mListBuilder); 98 } 99 mListBuilder.attach(mNotifCollection); 100 mNotifCollection.attach(mGroupCoalescer); 101 mGroupCoalescer.attach(notificationService); 102 103 Log.d(TAG, "Notif pipeline initialized"); 104 } 105 106 @Override dump(FileDescriptor fd, PrintWriter pw, String[] args)107 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 108 mNotifPluggableCoordinators.dump(fd, pw, args); 109 mGroupCoalescer.dump(fd, pw, args); 110 } 111 112 private static final String TAG = "NotifPipeline"; 113 } 114