Added "Speed and Compatibility" Settings page

- Show each band option individually in single-band devices
  - Show "2.4 and 5GHz" combined option in dual-band devices

- Disable 5 GHz option if the device is in the restricted country

- Disable 6 GHz option if the device is in the restricted country
  - Hide 6 GHz option if the old device does not support 6 GHz band.

Bug: 245258763
Test: manual test
atest -c WifiHotspotSpeedSettingsTest
atest -c WifiHotspotSpeedViewModelTest \
         WifiHotspotRepositoryTest

Change-Id: I358d4ff8d62df72fd5080e55f40d588c238d01fb
This commit is contained in:
Weng Su
2023-03-21 04:31:03 +08:00
parent f0c3812123
commit 17631aeff7
13 changed files with 1374 additions and 55 deletions

View File

@@ -16,14 +16,17 @@
package com.android.settings.wifi.factory;
import android.annotation.Nullable;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;
import com.android.settings.wifi.repository.WifiHotspotRepository;
import com.android.settings.wifi.tether.WifiHotspotSpeedViewModel;
import com.android.settings.wifi.tether.WifiTetherViewModel;
import org.jetbrains.annotations.NotNull;
@@ -32,9 +35,11 @@ import org.jetbrains.annotations.NotNull;
* Wi-Fi Feature Provider
*/
public class WifiFeatureProvider {
private static final String TAG = "WifiFeatureProvider";
private final Context mAppContext;
private WifiManager mWifiManager;
private WifiVerboseLogging mWifiVerboseLogging;
private WifiHotspotRepository mWifiHotspotRepository;
public WifiFeatureProvider(@NonNull Context appContext) {
@@ -52,11 +57,22 @@ public class WifiFeatureProvider {
}
/**
* Get WifiRepository
* Get WifiVerboseLogging
*/
public WifiVerboseLogging getWifiVerboseLogging() {
if (mWifiVerboseLogging == null) {
mWifiVerboseLogging = new WifiVerboseLogging(mAppContext, getWifiManager());
}
return mWifiVerboseLogging;
}
/**
* Get WifiHotspotRepository
*/
public WifiHotspotRepository getWifiHotspotRepository() {
if (mWifiHotspotRepository == null) {
mWifiHotspotRepository = new WifiHotspotRepository(mAppContext, getWifiManager());
verboseLog(TAG, "getWifiHotspotRepository():" + mWifiHotspotRepository);
}
return mWifiHotspotRepository;
}
@@ -68,5 +84,26 @@ public class WifiFeatureProvider {
return new ViewModelProvider(owner).get(WifiTetherViewModel.class);
}
/**
* Get WifiHotspotSpeedViewModel
*/
public WifiHotspotSpeedViewModel getWifiHotspotSpeedViewModel(
@NotNull ViewModelStoreOwner owner) {
WifiHotspotSpeedViewModel viewModel =
new ViewModelProvider(owner).get(WifiHotspotSpeedViewModel.class);
verboseLog(TAG, "getWifiHotspotSpeedViewModel():" + viewModel);
return viewModel;
}
/**
* Send a {@link Log#VERBOSE} log message.
*
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
*/
public void verboseLog(@Nullable String tag, @NonNull String msg) {
getWifiVerboseLogging().log(tag, msg);
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.wifi.factory;
import android.annotation.Nullable;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.util.Log;
import androidx.annotation.NonNull;
/**
* Wi-Fi Verbose Logging
*/
public class WifiVerboseLogging {
private static final String TAG = "WifiVerboseLogging";
protected final Context mAppContext;
protected final WifiManager mWifiManager;
protected final boolean mIsVerboseLoggingEnabled;
public WifiVerboseLogging(@NonNull Context appContext, @NonNull WifiManager wifiManager) {
mAppContext = appContext;
mWifiManager = wifiManager;
mIsVerboseLoggingEnabled = wifiManager.isVerboseLoggingEnabled();
Log.v(TAG, "isVerboseLoggingEnabled:" + mIsVerboseLoggingEnabled);
}
/**
* Send a {@link Log#VERBOSE} log message.
*
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
*/
public void log(@Nullable String tag, @NonNull String msg) {
if (mIsVerboseLoggingEnabled) {
Log.v(tag, msg);
}
}
}