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.CarServiceProvider; 24 import com.android.systemui.statusbar.car.CarFacetButtonController; 25 import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager; 26 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 27 import com.android.systemui.volume.CarVolumeDialogComponent; 28 import com.android.systemui.volume.VolumeDialogComponent; 29 30 import javax.inject.Singleton; 31 32 import dagger.Component; 33 34 /** 35 * Class factory to provide car specific SystemUI components. 36 */ 37 public class CarSystemUIFactory extends SystemUIFactory { 38 39 private CarDependencyComponent mCarDependencyComponent; 40 private CarServiceProvider mCarServiceProvider; 41 42 @Override buildSystemUIRootComponent(Context context)43 protected SystemUIRootComponent buildSystemUIRootComponent(Context context) { 44 mCarDependencyComponent = DaggerCarSystemUIFactory_CarDependencyComponent.builder() 45 .contextHolder(new ContextHolder(context)) 46 .build(); 47 return DaggerCarSystemUIRootComponent.builder() 48 .dependencyProvider(new com.android.systemui.DependencyProvider()) 49 .contextHolder(new ContextHolder(context)) 50 .build(); 51 } 52 53 /** Gets a {@link CarServiceProvider}. */ getCarServiceProvider(Context context)54 public CarServiceProvider getCarServiceProvider(Context context) { 55 if (mCarServiceProvider == null) { 56 mCarServiceProvider = new CarServiceProvider(context); 57 } 58 return mCarServiceProvider; 59 } 60 getCarDependencyComponent()61 public CarDependencyComponent getCarDependencyComponent() { 62 return mCarDependencyComponent; 63 } 64 createStatusBarKeyguardViewManager(Context context, ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils)65 public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context, 66 ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) { 67 return new CarStatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); 68 } 69 createVolumeDialogComponent(SystemUI systemUi, Context context)70 public VolumeDialogComponent createVolumeDialogComponent(SystemUI systemUi, Context context) { 71 return new CarVolumeDialogComponent(systemUi, context); 72 } 73 74 @Singleton 75 @Component(modules = ContextHolder.class) 76 public interface CarDependencyComponent { getCarFacetButtonController()77 CarFacetButtonController getCarFacetButtonController(); 78 } 79 } 80