blob: 45457c648f229d2c2ca9029d93f5cdd845b458ac [file] [log] [blame]
Yorke Lee56fe5892014-06-13 12:38:07 -07001/*
2 * Copyright (C) 2013 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 */
Alon Albert05de7012013-08-22 11:26:28 -070016
17package com.android.dialer;
18
19import android.app.Application;
Yorke Leef5554ce2015-01-27 14:46:02 -080020import android.os.Trace;
Alon Albert05de7012013-08-22 11:26:28 -070021
Yorke Lee56fe5892014-06-13 12:38:07 -070022import com.android.contacts.common.ContactPhotoManager;
Alon Albert05de7012013-08-22 11:26:28 -070023import com.android.contacts.common.extensions.ExtensionsFactory;
Brian Attwellbeab3bb2014-10-27 12:24:49 -070024import com.android.contacts.commonbind.analytics.AnalyticsUtil;
Alon Albert05de7012013-08-22 11:26:28 -070025
26public class DialerApplication extends Application {
27
Yorke Leef5554ce2015-01-27 14:46:02 -080028 private static final String TAG = "DialerApplication";
Yorke Lee56fe5892014-06-13 12:38:07 -070029 private ContactPhotoManager mContactPhotoManager;
30
Alon Albert05de7012013-08-22 11:26:28 -070031 @Override
32 public void onCreate() {
Yorke Leef5554ce2015-01-27 14:46:02 -080033 Trace.beginSection(TAG + " onCreate");
Alon Albert05de7012013-08-22 11:26:28 -070034 super.onCreate();
Yorke Leef5554ce2015-01-27 14:46:02 -080035 Trace.beginSection(TAG + " ExtensionsFactory initialization");
Alon Albert05de7012013-08-22 11:26:28 -070036 ExtensionsFactory.init(getApplicationContext());
Yorke Leef5554ce2015-01-27 14:46:02 -080037 Trace.endSection();
38 Trace.beginSection(TAG + " Analytics initialization");
Brian Attwellbeab3bb2014-10-27 12:24:49 -070039 AnalyticsUtil.initialize(this);
Yorke Leef5554ce2015-01-27 14:46:02 -080040 Trace.endSection();
41 Trace.endSection();
Alon Albert05de7012013-08-22 11:26:28 -070042 }
Yorke Lee56fe5892014-06-13 12:38:07 -070043
44 @Override
45 public Object getSystemService(String name) {
46 if (ContactPhotoManager.CONTACT_PHOTO_SERVICE.equals(name)) {
47 if (mContactPhotoManager == null) {
48 mContactPhotoManager = ContactPhotoManager.createContactPhotoManager(this);
49 registerComponentCallbacks(mContactPhotoManager);
50 mContactPhotoManager.preloadPhotosInBackground();
51 }
52 return mContactPhotoManager;
53 }
54
55 return super.getSystemService(name);
56 }
Alon Albert05de7012013-08-22 11:26:28 -070057}