1 /* 2 * Copyright (C) 2016 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.util; 18 19 import android.net.wifi.ScanResult; 20 21 import com.android.server.wifi.ScanDetail; 22 import com.android.server.wifi.hotspot2.NetworkDetail; 23 24 /** 25 * Utility for converting a ScanResult to a ScanDetail. 26 * Only fields that are supported in ScanResult are copied. 27 */ 28 public class ScanDetailUtil { ScanDetailUtil()29 private ScanDetailUtil() { /* not constructable */ } 30 31 /** 32 * This method should only be used when the informationElements field in the provided scan 33 * result is filled in with the IEs from the beacon. 34 */ toScanDetail(ScanResult scanResult)35 public static ScanDetail toScanDetail(ScanResult scanResult) { 36 NetworkDetail networkDetail = new NetworkDetail(scanResult.BSSID, 37 scanResult.informationElements, scanResult.anqpLines, scanResult.frequency); 38 return new ScanDetail(scanResult, networkDetail, null); 39 } 40 } 41