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 import android.os.Process; 21 import android.os.UserHandle; 22 23 import com.android.systemui.dagger.GlobalRootComponent; 24 import com.android.systemui.dagger.SysUIComponent; 25 import com.android.systemui.dagger.WMComponent; 26 import com.android.systemui.wmshell.CarWMComponent; 27 28 import java.util.Optional; 29 30 /** 31 * Class factory to provide car specific SystemUI components. 32 */ 33 public class CarSystemUIInitializer extends SystemUIInitializer { CarSystemUIInitializer(Context context)34 public CarSystemUIInitializer(Context context) { 35 super(context); 36 } 37 38 @Override getGlobalRootComponentBuilder()39 protected GlobalRootComponent.Builder getGlobalRootComponentBuilder() { 40 return DaggerCarGlobalRootComponent.builder(); 41 } 42 43 @Override prepareSysUIComponentBuilder( SysUIComponent.Builder sysUIBuilder, WMComponent wm)44 protected SysUIComponent.Builder prepareSysUIComponentBuilder( 45 SysUIComponent.Builder sysUIBuilder, WMComponent wm) { 46 CarWMComponent carWm = (CarWMComponent) wm; 47 initWmComponents(carWm); 48 boolean isSystemUser = UserHandle.myUserId() == UserHandle.USER_SYSTEM; 49 return ((CarSysUIComponent.Builder) sysUIBuilder).setRootTaskDisplayAreaOrganizer( 50 isSystemUser ? Optional.of(carWm.getRootTaskDisplayAreaOrganizer()) 51 : Optional.empty()) 52 .setMDSystemBarsController(carWm.getMDSystemBarController()); 53 } 54 initWmComponents(CarWMComponent carWm)55 private void initWmComponents(CarWMComponent carWm) { 56 carWm.getDisplaySystemBarsController(); 57 if (Process.myUserHandle().isSystem()) { 58 carWm.getCarSystemUIProxy(); 59 carWm.getRemoteCarTaskViewTransitions(); 60 } 61 } 62 } 63