blob: 1a0497bb9ee4a820d0fe54058ac4f9d345973311 [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;
Brandon Maxwell13825f02016-03-06 10:54:00 -080020import android.content.Context;
Yorke Leef5554ce2015-01-27 14:46:02 -080021import android.os.Trace;
Brandon Maxwell03dffbf2016-04-15 13:32:03 -070022import android.preference.PreferenceManager;
Brandon Maxwell13825f02016-03-06 10:54:00 -080023import android.support.annotation.Nullable;
Alon Albert05de7012013-08-22 11:26:28 -070024
25import com.android.contacts.common.extensions.ExtensionsFactory;
Brandon Maxwell13825f02016-03-06 10:54:00 -080026import com.android.contacts.common.testing.NeededForTesting;
Brandon Maxwell03dffbf2016-04-15 13:32:03 -070027import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
28import com.android.dialer.filterednumber.BlockedNumbersAutoMigrator;
Alon Albert05de7012013-08-22 11:26:28 -070029
30public class DialerApplication extends Application {
31
Yorke Leef5554ce2015-01-27 14:46:02 -080032 private static final String TAG = "DialerApplication";
Yorke Lee56fe5892014-06-13 12:38:07 -070033
Brandon Maxwell13825f02016-03-06 10:54:00 -080034 private static Context sContext;
35
Alon Albert05de7012013-08-22 11:26:28 -070036 @Override
37 public void onCreate() {
Brandon Maxwell13825f02016-03-06 10:54:00 -080038 sContext = this;
Yorke Leef5554ce2015-01-27 14:46:02 -080039 Trace.beginSection(TAG + " onCreate");
Alon Albert05de7012013-08-22 11:26:28 -070040 super.onCreate();
Yorke Leef5554ce2015-01-27 14:46:02 -080041 Trace.beginSection(TAG + " ExtensionsFactory initialization");
Alon Albert05de7012013-08-22 11:26:28 -070042 ExtensionsFactory.init(getApplicationContext());
Yorke Leef5554ce2015-01-27 14:46:02 -080043 Trace.endSection();
Brandon Maxwell03dffbf2016-04-15 13:32:03 -070044 new BlockedNumbersAutoMigrator(PreferenceManager.getDefaultSharedPreferences(this),
45 new FilteredNumberAsyncQueryHandler(getContentResolver())).autoMigrate();
Yorke Leef5554ce2015-01-27 14:46:02 -080046 Trace.endSection();
Alon Albert05de7012013-08-22 11:26:28 -070047 }
Brandon Maxwell13825f02016-03-06 10:54:00 -080048
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 Albert05de7012013-08-22 11:26:28 -070058}