• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.tv.statusbar;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.os.RemoteException;
23 import android.os.ServiceManager;
24 
25 import com.android.internal.statusbar.IStatusBarService;
26 import com.android.systemui.CoreStartable;
27 import com.android.systemui.assist.AssistManager;
28 import com.android.systemui.dagger.SysUISingleton;
29 import com.android.systemui.statusbar.CommandQueue;
30 import com.android.systemui.statusbar.KeyboardShortcuts;
31 import com.android.systemui.utils.windowmanager.WindowManagerProvider;
32 
33 import dagger.Lazy;
34 
35 import javax.inject.Inject;
36 
37 /**
38  * Status bar implementation for "large screen" products that mostly present no on-screen nav.
39  * Serves as a collection of UI components, rather than showing its own UI.
40  */
41 @SysUISingleton
42 public class TvStatusBar implements CoreStartable, CommandQueue.Callbacks {
43 
44     private static final String ACTION_SHOW_PIP_MENU =
45             "com.android.wm.shell.pip.tv.notification.action.SHOW_PIP_MENU";
46     private static final String SYSTEMUI_PERMISSION = "com.android.systemui.permission.SELF";
47 
48     private final Context mContext;
49     private final CommandQueue mCommandQueue;
50     private final Lazy<AssistManager> mAssistManagerLazy;
51     private final WindowManagerProvider mWindowManagerProvider;
52 
53     @Inject
TvStatusBar(Context context, CommandQueue commandQueue, Lazy<AssistManager> assistManagerLazy, WindowManagerProvider windowManagerProvider)54     public TvStatusBar(Context context, CommandQueue commandQueue,
55             Lazy<AssistManager> assistManagerLazy, WindowManagerProvider windowManagerProvider) {
56         mContext = context;
57         mCommandQueue = commandQueue;
58         mAssistManagerLazy = assistManagerLazy;
59         mWindowManagerProvider = windowManagerProvider;
60     }
61 
62     @Override
start()63     public void start() {
64         final IStatusBarService barService = IStatusBarService.Stub.asInterface(
65                 ServiceManager.getService(Context.STATUS_BAR_SERVICE));
66         mCommandQueue.addCallback(this);
67         try {
68             barService.registerStatusBar(mCommandQueue);
69         } catch (RemoteException ex) {
70             // If the system process isn't there we're doomed anyway.
71         }
72     }
73 
74     @Override
startAssist(Bundle args)75     public void startAssist(Bundle args) {
76         mAssistManagerLazy.get().startAssist(args);
77     }
78 
79     @Override
showPictureInPictureMenu()80     public void showPictureInPictureMenu() {
81         mContext.sendBroadcast(
82                 new Intent(ACTION_SHOW_PIP_MENU).setPackage(mContext.getPackageName()),
83                 SYSTEMUI_PERMISSION);
84     }
85 
86     @Override
toggleKeyboardShortcutsMenu(int deviceId)87     public void toggleKeyboardShortcutsMenu(int deviceId) {
88         KeyboardShortcuts.show(mContext, deviceId, mWindowManagerProvider);
89     }
90 }
91