1 /* 2 * Copyright 2025 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 com.android.virtualization.terminal 17 18 import android.app.Application as AndroidApplication 19 import android.app.NotificationChannel 20 import android.app.NotificationManager 21 import android.content.Context 22 23 public class Application : AndroidApplication() { onCreatenull24 override fun onCreate() { 25 super.onCreate() 26 setupNotificationChannels() 27 } 28 setupNotificationChannelsnull29 private fun setupNotificationChannels() { 30 val nm = getSystemService<NotificationManager>(NotificationManager::class.java) 31 32 nm.createNotificationChannel( 33 NotificationChannel( 34 CHANNEL_LONG_RUNNING_ID, 35 getString(R.string.notification_channel_long_running_name), 36 NotificationManager.IMPORTANCE_DEFAULT, 37 ) 38 ) 39 40 nm.createNotificationChannel( 41 NotificationChannel( 42 CHANNEL_SYSTEM_EVENTS_ID, 43 getString(R.string.notification_channel_system_events_name), 44 NotificationManager.IMPORTANCE_HIGH, 45 ) 46 ) 47 } 48 49 companion object { 50 const val CHANNEL_LONG_RUNNING_ID = "long_running" 51 const val CHANNEL_SYSTEM_EVENTS_ID = "system_events" 52 getInstancenull53 fun getInstance(c: Context): Application = c.getApplicationContext() as Application 54 } 55 } 56