blob: 7f477f992e6cbe7452ea2eb55932f71b2e9c3f86 [file] [log] [blame]
Santos Cordon049b7b62014-01-30 05:34:26 -08001/*
2 * Copyright (C) 2014 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
17package com.android.telecomm;
18
19import android.app.Application;
Amith Yamasani60e75842014-05-23 10:09:14 -070020import android.os.UserHandle;
Santos Cordon049b7b62014-01-30 05:34:26 -080021
22/**
23 * Top-level Application class for Telecomm.
24 */
25public final class TelecommApp extends Application {
26
Santos Cordona0e5f1a2014-03-31 21:43:00 -070027 /** Singleton instance of TelecommApp. */
Santos Cordon049b7b62014-01-30 05:34:26 -080028 private static TelecommApp sInstance;
29
Santos Cordona0e5f1a2014-03-31 21:43:00 -070030 /**
31 * Missed call notifier. Exists here so that the instance can be shared with
32 * {@link TelecommBroadcastReceiver}.
33 */
34 private MissedCallNotifier mMissedCallNotifier;
35
Santos Cordon049b7b62014-01-30 05:34:26 -080036 /** {@inheritDoc} */
37 @Override public void onCreate() {
38 super.onCreate();
39 sInstance = this;
Santos Cordonae193062014-05-21 21:21:49 -070040
Santos Cordona0e5f1a2014-03-31 21:43:00 -070041 mMissedCallNotifier = new MissedCallNotifier(this);
Amith Yamasani60e75842014-05-23 10:09:14 -070042 if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
43 TelecommServiceImpl.init();
44 }
Santos Cordon049b7b62014-01-30 05:34:26 -080045 }
46
47 public static TelecommApp getInstance() {
48 if (null == sInstance) {
49 throw new IllegalStateException("No TelecommApp running.");
50 }
51 return sInstance;
52 }
Santos Cordona0e5f1a2014-03-31 21:43:00 -070053
54 MissedCallNotifier getMissedCallNotifier() {
55 return mMissedCallNotifier;
56 }
Santos Cordon049b7b62014-01-30 05:34:26 -080057}