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