Home | History | Annotate | Download | only in scanner
      1 /*
      2  * Copyright (C) 2008 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.scanner;
     18 
     19 import android.content.Context;
     20 import android.os.HandlerThread;
     21 import android.util.Log;
     22 
     23 import com.android.server.SystemService;
     24 import com.android.server.am.BatteryStatsService;
     25 import com.android.server.wifi.WifiInjector;
     26 
     27 public class WifiScanningService extends SystemService {
     28 
     29     static final String TAG = "WifiScanningService";
     30     private final WifiScanningServiceImpl mImpl;
     31     private final HandlerThread mHandlerThread;
     32 
     33     public WifiScanningService(Context context) {
     34         super(context);
     35         Log.i(TAG, "Creating " + Context.WIFI_SCANNING_SERVICE);
     36         mHandlerThread = new HandlerThread("WifiScanningService");
     37         mHandlerThread.start();
     38         mImpl = new WifiScanningServiceImpl(getContext(), mHandlerThread.getLooper(),
     39                 WifiScannerImpl.DEFAULT_FACTORY, BatteryStatsService.getService(),
     40                 WifiInjector.getInstance());
     41     }
     42 
     43     @Override
     44     public void onStart() {
     45         Log.i(TAG, "Publishing " + Context.WIFI_SCANNING_SERVICE);
     46         publishBinderService(Context.WIFI_SCANNING_SERVICE, mImpl);
     47     }
     48 
     49     @Override
     50     public void onBootPhase(int phase) {
     51         if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
     52             Log.i(TAG, "Starting " + Context.WIFI_SCANNING_SERVICE);
     53             mImpl.startService();
     54         }
     55     }
     56 }
     57