1 /* 2 * Copyright (C) 2010 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 androidx.annotation.NonNull; 20 21 import java.io.PrintWriter; 22 23 /** 24 * Code that needs to be run when SystemUI is started. 25 * 26 * Which CoreStartable modules are loaded is controlled via the dagger graph. Bind them into the 27 * CoreStartable map with code such as: 28 * 29 * <pre> 30 * @Binds 31 * @IntoMap 32 * @ClassKey(FoobarStartable::class) 33 * abstract fun bind(impl: FoobarStartable): CoreStartable 34 * </pre> 35 * 36 * If your CoreStartable depends on different CoreStartables starting before it, you can specify 37 * another map binding listing out its dependencies: 38 * <pre> 39 * @Provides 40 * @IntoMap 41 * @Dependencies // Important! com.android.systemui.startable.Dependencies. 42 * @ClassKey(FoobarStartable::class) 43 * fun providesDeps(): Set<Class<out CoreStartable>> { 44 * return setOf(OtherStartable::class.java) 45 * } 46 * </pre> 47 * 48 * 49 * @see SystemUIApplication#startSystemUserServicesIfNeeded() 50 */ 51 public interface CoreStartable extends Dumpable { 52 String STARTABLE_DEPENDENCIES = "startable_dependencies"; 53 54 /** Main entry point for implementations. Called shortly after SysUI startup. */ start()55 void start(); 56 57 @Override dump(@onNull PrintWriter pw, @NonNull String[] args)58 default void dump(@NonNull PrintWriter pw, @NonNull String[] args) { 59 } 60 61 /** Called to determine if the dumpable should be registered as critical or normal priority */ isDumpCritical()62 default boolean isDumpCritical() { 63 return true; 64 } 65 66 /** Called immediately after the system broadcasts 67 * {@link android.content.Intent#ACTION_LOCKED_BOOT_COMPLETED} or during SysUI startup if the 68 * property {@code sys.boot_completed} is already set to 1. The latter typically occurs when 69 * starting a new SysUI instance, such as when starting SysUI for a secondary user. 70 * {@link #onBootCompleted()} will never be called before {@link #start()}. */ onBootCompleted()71 default void onBootCompleted() { 72 } 73 } 74