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 android.app.Notification; 20 import android.content.Context; 21 import android.content.res.Configuration; 22 import android.os.Bundle; 23 24 import androidx.annotation.NonNull; 25 26 import java.io.FileDescriptor; 27 import java.io.PrintWriter; 28 29 /** 30 * A top-level module of system UI code (sometimes called "system UI services" elsewhere in code). 31 * Which SystemUI modules are loaded can be controlled via a config resource. 32 * 33 * @see SystemUIApplication#startServicesIfNeeded() 34 */ 35 public abstract class SystemUI implements Dumpable { 36 protected final Context mContext; 37 SystemUI(Context context)38 public SystemUI(Context context) { 39 mContext = context; 40 } 41 start()42 public abstract void start(); 43 onConfigurationChanged(Configuration newConfig)44 protected void onConfigurationChanged(Configuration newConfig) { 45 } 46 47 @Override dump(@onNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args)48 public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { 49 } 50 onBootCompleted()51 protected void onBootCompleted() { 52 } 53 overrideNotificationAppName(Context context, Notification.Builder n, boolean system)54 public static void overrideNotificationAppName(Context context, Notification.Builder n, 55 boolean system) { 56 final Bundle extras = new Bundle(); 57 String appName = system 58 ? context.getString(com.android.internal.R.string.notification_app_name_system) 59 : context.getString(com.android.internal.R.string.notification_app_name_settings); 60 extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, appName); 61 62 n.addExtras(extras); 63 } 64 } 65