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 17package com.android.services.telephony; 18 19import android.content.Context; 20 21import com.android.internal.telephony.Phone; 22import com.android.internal.telephony.PhoneFactory; 23 24/** 25 * Singleton entry point for the telephony-services app. Initializes ongoing systems relating to 26 * PSTN calls. This is started when the device starts and will be restarted automatically 27 * if it goes away for any reason (e.g., crashes). 28 * This is separate from the actual Application class because we only support one instance of this 29 * app - running as the default user. {@link com.android.phone.PhoneApp} determines whether or not 30 * we are running as the default user and if we are, then initializes and runs this class's 31 * {@link #onCreate}. 32 */ 33public class TelephonyGlobals { 34 private static TelephonyGlobals sInstance; 35 36 /** The application context. */ 37 private final Context mContext; 38 39 private TtyManager mTtyManager; 40 41 /** 42 * Persists the specified parameters. 43 * 44 * @param context The application context. 45 */ 46 public TelephonyGlobals(Context context) { 47 mContext = context.getApplicationContext(); 48 } 49 50 public static synchronized TelephonyGlobals getInstance(Context context) { 51 if (sInstance == null) { 52 sInstance = new TelephonyGlobals(context); 53 } 54 return sInstance; 55 } 56 57 public void onCreate() { 58 // TODO: Make this work with Multi-SIM devices 59 Phone phone = PhoneFactory.getDefaultPhone(); 60 if (phone != null) { 61 mTtyManager = new TtyManager(mContext, phone); 62 } 63 64 TelecomAccountRegistry.getInstance(mContext).setupOnBoot(); 65 } 66} 67