Home | History | Annotate | Download | only in systemui
      1 /*
      2  * Copyright (C) 2018 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;
     18 
     19 import android.content.Context;
     20 
     21 import com.android.internal.widget.LockPatternUtils;
     22 import com.android.keyguard.ViewMediatorCallback;
     23 import com.android.systemui.car.CarNotificationEntryManager;
     24 import com.android.systemui.car.CarNotificationInterruptionStateProvider;
     25 import com.android.systemui.statusbar.car.CarFacetButtonController;
     26 import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager;
     27 import com.android.systemui.statusbar.notification.NotificationEntryManager;
     28 import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
     29 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
     30 import com.android.systemui.volume.CarVolumeDialogComponent;
     31 import com.android.systemui.volume.VolumeDialogComponent;
     32 
     33 import javax.inject.Singleton;
     34 
     35 import dagger.Component;
     36 import dagger.Module;
     37 import dagger.Provides;
     38 
     39 /**
     40  * Class factory to provide car specific SystemUI components.
     41  */
     42 public class CarSystemUIFactory extends SystemUIFactory {
     43 
     44     private CarDependencyComponent mCarDependencyComponent;
     45 
     46     @Override
     47     protected void init(Context context) {
     48         super.init(context);
     49         mCarDependencyComponent = DaggerCarSystemUIFactory_CarDependencyComponent.builder()
     50                 .contextHolder(new ContextHolder(context))
     51                 .build();
     52     }
     53 
     54     public CarDependencyComponent getCarDependencyComponent() {
     55         return mCarDependencyComponent;
     56     }
     57 
     58     public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context,
     59             ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) {
     60         return new CarStatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils);
     61     }
     62 
     63     public VolumeDialogComponent createVolumeDialogComponent(SystemUI systemUi, Context context) {
     64         return new CarVolumeDialogComponent(systemUi, context);
     65     }
     66 
     67     @Override
     68     public NotificationInterruptionStateProvider provideNotificationInterruptionStateProvider(
     69             Context context) {
     70         return new CarNotificationInterruptionStateProvider(context);
     71     }
     72 
     73     @Override
     74     public boolean provideAllowNotificationLongPress() {
     75         return false;
     76     }
     77 
     78     @Module
     79     protected static class ContextHolder {
     80         private Context mContext;
     81 
     82         public ContextHolder(Context context) {
     83             mContext = context;
     84         }
     85 
     86         @Provides
     87         public Context provideContext() {
     88             return mContext;
     89         }
     90     }
     91 
     92     @Singleton
     93     @Component(modules = ContextHolder.class)
     94     public interface CarDependencyComponent {
     95         CarFacetButtonController getCarFacetButtonController();
     96     }
     97 
     98     /**
     99      * Use {@link CarNotificationEntryManager}, which does nothing when adding a notification.
    100      */
    101     @Singleton
    102     public NotificationEntryManager provideNotificationEntryManager(Context context) {
    103         return new CarNotificationEntryManager(context);
    104     }
    105 }
    106