Yorke Lee | 56fe589 | 2014-06-13 12:38:07 -0700 | [diff] [blame] | 1 | /* |
| 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 Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 16 | |
| 17 | package com.android.dialer; |
| 18 | |
| 19 | import android.app.Application; |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame^] | 20 | import android.os.Trace; |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 21 | |
Yorke Lee | 56fe589 | 2014-06-13 12:38:07 -0700 | [diff] [blame] | 22 | import com.android.contacts.common.ContactPhotoManager; |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 23 | import com.android.contacts.common.extensions.ExtensionsFactory; |
Brian Attwell | beab3bb | 2014-10-27 12:24:49 -0700 | [diff] [blame] | 24 | import com.android.contacts.commonbind.analytics.AnalyticsUtil; |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 25 | |
| 26 | public class DialerApplication extends Application { |
| 27 | |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame^] | 28 | private static final String TAG = "DialerApplication"; |
Yorke Lee | 56fe589 | 2014-06-13 12:38:07 -0700 | [diff] [blame] | 29 | private ContactPhotoManager mContactPhotoManager; |
| 30 | |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 31 | @Override |
| 32 | public void onCreate() { |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame^] | 33 | Trace.beginSection(TAG + " onCreate"); |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 34 | super.onCreate(); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame^] | 35 | Trace.beginSection(TAG + " ExtensionsFactory initialization"); |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 36 | ExtensionsFactory.init(getApplicationContext()); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame^] | 37 | Trace.endSection(); |
| 38 | Trace.beginSection(TAG + " Analytics initialization"); |
Brian Attwell | beab3bb | 2014-10-27 12:24:49 -0700 | [diff] [blame] | 39 | AnalyticsUtil.initialize(this); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame^] | 40 | Trace.endSection(); |
| 41 | Trace.endSection(); |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 42 | } |
Yorke Lee | 56fe589 | 2014-06-13 12:38:07 -0700 | [diff] [blame] | 43 | |
| 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 Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 57 | } |