• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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;
18 
19 import android.content.Context;
20 import android.util.Log;
21 
22 import com.android.server.SystemService;
23 
24 /**
25  * Service implementing Wi-Fi functionality. Delegates actual interface
26  * implementation to WifiServiceImpl.
27  */
28 public final class WifiService extends SystemService {
29 
30     private static final String TAG = "WifiService";
31     // Notification channels used by the wifi service.
32     public static final String NOTIFICATION_NETWORK_STATUS = "NETWORK_STATUS";
33     public static final String NOTIFICATION_NETWORK_ALERTS = "NETWORK_ALERTS";
34     public static final String NOTIFICATION_NETWORK_AVAILABLE = "NETWORK_AVAILABLE";
35 
36     private final WifiServiceImpl mImpl;
37     private final WifiContext mWifiContext;
38 
WifiService(Context contextBase)39     public WifiService(Context contextBase) {
40         super(contextBase);
41         mWifiContext = new WifiContext(contextBase);
42         WifiInjector injector = new WifiInjector(mWifiContext);
43         mImpl = new WifiServiceImpl(mWifiContext, injector);
44     }
45 
46     @Override
onStart()47     public void onStart() {
48         Log.i(TAG, "Registering " + Context.WIFI_SERVICE);
49         publishBinderService(Context.WIFI_SERVICE, mImpl);
50     }
51 
52     @Override
onBootPhase(int phase)53     public void onBootPhase(int phase) {
54         if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
55             mImpl.checkAndStartWifi();
56         } else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
57             mImpl.handleBootCompleted();
58         }
59     }
60 
61     @Override
onUserSwitching(TargetUser from, TargetUser to)62     public void onUserSwitching(TargetUser from, TargetUser to) {
63         mImpl.handleUserSwitch(to.getUserHandle().getIdentifier());
64     }
65 
66     @Override
onUserUnlocking(TargetUser user)67     public void onUserUnlocking(TargetUser user) {
68         mImpl.handleUserUnlock(user.getUserHandle().getIdentifier());
69     }
70 
71     @Override
onUserStopping(TargetUser user)72     public void onUserStopping(TargetUser user) {
73         mImpl.handleUserStop(user.getUserHandle().getIdentifier());
74     }
75 }
76