1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package com.android.systemui.globalactions; 16 17 import com.android.internal.statusbar.IStatusBarService; 18 import com.android.systemui.Dependency; 19 import com.android.systemui.SysUiServiceProvider; 20 import com.android.systemui.SystemUI; 21 import com.android.systemui.plugins.GlobalActions; 22 import com.android.systemui.plugins.GlobalActions.GlobalActionsManager; 23 import com.android.systemui.statusbar.CommandQueue; 24 import com.android.systemui.statusbar.CommandQueue.Callbacks; 25 import com.android.systemui.statusbar.policy.ExtensionController; 26 import com.android.systemui.statusbar.policy.ExtensionController.Extension; 27 28 import android.content.Context; 29 import android.os.RemoteException; 30 import android.os.ServiceManager; 31 32 public class GlobalActionsComponent extends SystemUI implements Callbacks, GlobalActionsManager { 33 34 private Extension<GlobalActions> mExtension; 35 private IStatusBarService mBarService; 36 37 @Override start()38 public void start() { 39 mBarService = IStatusBarService.Stub.asInterface( 40 ServiceManager.getService(Context.STATUS_BAR_SERVICE)); 41 mExtension = Dependency.get(ExtensionController.class).newExtension(GlobalActions.class) 42 .withPlugin(GlobalActions.class) 43 .withDefault(() -> new GlobalActionsImpl(mContext)) 44 .build(); 45 SysUiServiceProvider.getComponent(mContext, CommandQueue.class).addCallbacks(this); 46 } 47 48 @Override handleShowGlobalActionsMenu()49 public void handleShowGlobalActionsMenu() { 50 mExtension.get().showGlobalActions(this); 51 } 52 53 @Override onGlobalActionsShown()54 public void onGlobalActionsShown() { 55 try { 56 mBarService.onGlobalActionsShown(); 57 } catch (RemoteException e) { 58 } 59 } 60 61 @Override onGlobalActionsHidden()62 public void onGlobalActionsHidden() { 63 try { 64 mBarService.onGlobalActionsHidden(); 65 } catch (RemoteException e) { 66 } 67 } 68 69 @Override shutdown()70 public void shutdown() { 71 try { 72 mBarService.shutdown(); 73 } catch (RemoteException e) { 74 } 75 } 76 77 @Override reboot(boolean safeMode)78 public void reboot(boolean safeMode) { 79 try { 80 mBarService.reboot(safeMode); 81 } catch (RemoteException e) { 82 } 83 } 84 } 85