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; |
Brandon Maxwell | 13825f0 | 2016-03-06 10:54:00 -0800 | [diff] [blame] | 20 | import android.content.Context; |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 21 | import android.os.Trace; |
Brandon Maxwell | 03dffbf | 2016-04-15 13:32:03 -0700 | [diff] [blame] | 22 | import android.preference.PreferenceManager; |
Brandon Maxwell | 13825f0 | 2016-03-06 10:54:00 -0800 | [diff] [blame] | 23 | import android.support.annotation.Nullable; |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 24 | |
| 25 | import com.android.contacts.common.extensions.ExtensionsFactory; |
Brandon Maxwell | 13825f0 | 2016-03-06 10:54:00 -0800 | [diff] [blame] | 26 | import com.android.contacts.common.testing.NeededForTesting; |
Brandon Maxwell | 03dffbf | 2016-04-15 13:32:03 -0700 | [diff] [blame] | 27 | import com.android.dialer.database.FilteredNumberAsyncQueryHandler; |
| 28 | import com.android.dialer.filterednumber.BlockedNumbersAutoMigrator; |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 29 | |
| 30 | public class DialerApplication extends Application { |
| 31 | |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 32 | private static final String TAG = "DialerApplication"; |
Yorke Lee | 56fe589 | 2014-06-13 12:38:07 -0700 | [diff] [blame] | 33 | |
Brandon Maxwell | 13825f0 | 2016-03-06 10:54:00 -0800 | [diff] [blame] | 34 | private static Context sContext; |
| 35 | |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 36 | @Override |
| 37 | public void onCreate() { |
Brandon Maxwell | 13825f0 | 2016-03-06 10:54:00 -0800 | [diff] [blame] | 38 | sContext = this; |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 39 | Trace.beginSection(TAG + " onCreate"); |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 40 | super.onCreate(); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 41 | Trace.beginSection(TAG + " ExtensionsFactory initialization"); |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 42 | ExtensionsFactory.init(getApplicationContext()); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 43 | Trace.endSection(); |
Brandon Maxwell | 03dffbf | 2016-04-15 13:32:03 -0700 | [diff] [blame] | 44 | new BlockedNumbersAutoMigrator(PreferenceManager.getDefaultSharedPreferences(this), |
| 45 | new FilteredNumberAsyncQueryHandler(getContentResolver())).autoMigrate(); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 46 | Trace.endSection(); |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 47 | } |
Brandon Maxwell | 13825f0 | 2016-03-06 10:54:00 -0800 | [diff] [blame] | 48 | |
| 49 | @Nullable |
| 50 | public static Context getContext() { |
| 51 | return sContext; |
| 52 | } |
| 53 | |
| 54 | @NeededForTesting |
| 55 | public static void setContextForTest(Context context) { |
| 56 | sContext = context; |
| 57 | } |
Alon Albert | 05de701 | 2013-08-22 11:26:28 -0700 | [diff] [blame] | 58 | } |