Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.telecomm; |
| 18 | |
| 19 | import android.app.Application; |
Amith Yamasani | 60e7584 | 2014-05-23 10:09:14 -0700 | [diff] [blame^] | 20 | import android.os.UserHandle; |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Top-level Application class for Telecomm. |
| 24 | */ |
| 25 | public final class TelecommApp extends Application { |
| 26 | |
Santos Cordon | a0e5f1a | 2014-03-31 21:43:00 -0700 | [diff] [blame] | 27 | /** Singleton instance of TelecommApp. */ |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 28 | private static TelecommApp sInstance; |
| 29 | |
Santos Cordon | a0e5f1a | 2014-03-31 21:43:00 -0700 | [diff] [blame] | 30 | /** |
| 31 | * Missed call notifier. Exists here so that the instance can be shared with |
| 32 | * {@link TelecommBroadcastReceiver}. |
| 33 | */ |
| 34 | private MissedCallNotifier mMissedCallNotifier; |
| 35 | |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 36 | /** {@inheritDoc} */ |
| 37 | @Override public void onCreate() { |
| 38 | super.onCreate(); |
| 39 | sInstance = this; |
Santos Cordon | ae19306 | 2014-05-21 21:21:49 -0700 | [diff] [blame] | 40 | |
Santos Cordon | a0e5f1a | 2014-03-31 21:43:00 -0700 | [diff] [blame] | 41 | mMissedCallNotifier = new MissedCallNotifier(this); |
Amith Yamasani | 60e7584 | 2014-05-23 10:09:14 -0700 | [diff] [blame^] | 42 | if (UserHandle.myUserId() == UserHandle.USER_OWNER) { |
| 43 | TelecommServiceImpl.init(); |
| 44 | } |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | public static TelecommApp getInstance() { |
| 48 | if (null == sInstance) { |
| 49 | throw new IllegalStateException("No TelecommApp running."); |
| 50 | } |
| 51 | return sInstance; |
| 52 | } |
Santos Cordon | a0e5f1a | 2014-03-31 21:43:00 -0700 | [diff] [blame] | 53 | |
| 54 | MissedCallNotifier getMissedCallNotifier() { |
| 55 | return mMissedCallNotifier; |
| 56 | } |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 57 | } |