1 /*
2  * Copyright (C) 2011 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 
17 package com.android.server.wifi.p2p;
18 
19 import android.content.Context;
20 import android.net.wifi.WifiContext;
21 import android.util.Log;
22 
23 import com.android.server.SystemService;
24 import com.android.server.wifi.WifiInjector;
25 
26 /**
27  * Wifi P2p Service class, instantiates P2p service
28  * Overrides onStart() and onBootPhase() methods in
29  * the super class.
30  */
31 public final class WifiP2pService extends SystemService {
32 
33     private static final String TAG = "WifiP2pService";
34     final WifiP2pServiceImpl mImpl;
35 
WifiP2pService(Context contextBase)36     public WifiP2pService(Context contextBase) {
37         super(new WifiContext(contextBase));
38         mImpl = new WifiP2pServiceImpl(getContext(), WifiInjector.getInstance());
39     }
40 
41     @Override
onStart()42     public void onStart() {
43         Log.i(TAG, "Registering " + Context.WIFI_P2P_SERVICE);
44         publishBinderService(Context.WIFI_P2P_SERVICE, mImpl);
45     }
46 
47     @Override
onBootPhase(int phase)48     public void onBootPhase(int phase) {
49         if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
50             mImpl.connectivityServiceReady();
51         } else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
52             mImpl.handleBootCompleted();
53         }
54     }
55 }
56