1 /* 2 * Copyright (C) 2017 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.net.TetheringManager; 20 import android.net.wifi.SoftApCapability; 21 import android.net.wifi.SoftApConfiguration; 22 import android.net.wifi.WifiManager; 23 24 import com.android.internal.util.Preconditions; 25 26 import javax.annotation.Nullable; 27 28 /** 29 * Object holding the parameters needed to start SoftAp mode. 30 */ 31 class SoftApModeConfiguration { 32 /** 33 * Routing mode. Either {@link android.net.wifi.WifiManager#IFACE_IP_MODE_TETHERED} 34 * or {@link android.net.wifi.WifiManager#IFACE_IP_MODE_LOCAL_ONLY}. 35 */ 36 private final int mTargetMode; 37 private final SoftApCapability mCapability; 38 private final String mCountryCode; 39 40 /** 41 * SoftApConfiguration for internal use, or null if it hasn't been generated yet. 42 */ 43 private final @Nullable SoftApConfiguration mSoftApConfig; 44 45 /** 46 * TetheringRequest for internal use, or null if none was passed in. 47 */ 48 private final @Nullable TetheringManager.TetheringRequest mTetheringRequest; 49 SoftApModeConfiguration(int targetMode, @Nullable SoftApConfiguration config, SoftApCapability capability, @Nullable String countryCode, @Nullable TetheringManager.TetheringRequest request)50 SoftApModeConfiguration(int targetMode, @Nullable SoftApConfiguration config, 51 SoftApCapability capability, @Nullable String countryCode, 52 @Nullable TetheringManager.TetheringRequest request) { 53 Preconditions.checkArgument( 54 targetMode == WifiManager.IFACE_IP_MODE_TETHERED 55 || targetMode == WifiManager.IFACE_IP_MODE_LOCAL_ONLY); 56 57 mTargetMode = targetMode; 58 mSoftApConfig = config; 59 mCapability = capability; 60 mCountryCode = countryCode; 61 mTetheringRequest = request; 62 } 63 getTargetMode()64 public int getTargetMode() { 65 return mTargetMode; 66 } 67 getSoftApConfiguration()68 public SoftApConfiguration getSoftApConfiguration() { 69 return mSoftApConfig; 70 } 71 getCapability()72 public SoftApCapability getCapability() { 73 return mCapability; 74 } 75 getCountryCode()76 public String getCountryCode() { 77 return mCountryCode; 78 } 79 getTetheringRequest()80 public TetheringManager.TetheringRequest getTetheringRequest() { 81 return mTetheringRequest; 82 } 83 } 84