1 /*
2  * Copyright (C) 2012 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 package com.android.bluetooth.btservice;
17 
18 import android.app.Application;
19 import android.util.Log;
20 
21 public class AdapterApp extends Application {
22     private static final String TAG = "BluetoothAdapterApp";
23     // For Debugging only
24     private static int sRefCount = 0;
25 
AdapterApp()26     public AdapterApp() {
27         super();
28         synchronized (AdapterApp.class) {
29             sRefCount++;
30             Log.d(TAG, "REFCOUNT: Constructed " + this + " Instance Count = " + sRefCount);
31         }
32     }
33 
34     @Override
onCreate()35     public void onCreate() {
36         super.onCreate();
37         Log.d(TAG, "onCreate");
38         try {
39             DataMigration.run(this);
40         } catch (Exception e) {
41             Log.e(TAG, "Migration failure: ", e);
42         }
43     }
44 
45     @Override
finalize()46     protected void finalize() {
47         synchronized (AdapterApp.class) {
48             sRefCount--;
49             Log.d(TAG, "REFCOUNT: Finalized: " + this + ", Instance Count = " + sRefCount);
50         }
51     }
52 }
53