1 /* 2 * Copyright (C) 2024 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 package android.app.fgsstarttesthelper; 17 18 import android.R.drawable; 19 import android.app.Notification; 20 import android.app.NotificationChannel; 21 import android.app.NotificationManager; 22 import android.content.Context; 23 24 public class FgsTestCommon { FgsTestCommon()25 private FgsTestCommon() { 26 } 27 28 public static final String ACTION_START_NEW_LOGIC_TEST = "ACTION_START_NEW_LOGIC_TEST"; 29 public static final String EXTRA_REPLY_INTENT = "EXTRA_REPLY_INTENT"; 30 getNotificationChannelId(Context context)31 private static String getNotificationChannelId(Context context) { 32 return "channel/" + context.getPackageName(); 33 } 34 ensureNotificationChannel(Context context)35 public static String ensureNotificationChannel(Context context) { 36 final var channel = getNotificationChannelId(context); 37 context.getSystemService(NotificationManager.class) 38 .createNotificationChannel( 39 new NotificationChannel(channel, channel, 40 NotificationManager.IMPORTANCE_DEFAULT)); 41 return channel; 42 } 43 createNotification(Context context)44 public static Notification createNotification(Context context) { 45 Notification.Builder builder = 46 new Notification.Builder(context, ensureNotificationChannel(context)) 47 .setContentTitle("Title: " + context.getPackageName()) 48 .setSmallIcon(drawable.star_on); 49 return builder.build(); 50 } 51 } 52