Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17631aef authored by Weng Su's avatar Weng Su
Browse files

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
parent f0c38121
Loading
Loading
Loading
Loading
+28 −4
Original line number Diff line number Diff line
@@ -2018,13 +2018,37 @@
    <!-- Title for Wifi hotspot speed [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_title">Speed &amp; compatibility</string>
    <!-- Summary for Wifi hotspot speed to 2.4 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_2g_summary">2.4 GHz / Any device can connect</string>
    <string name="wifi_hotspot_speed_summary_2g">2.4 GHz / Any device can connect</string>
    <!-- Summary for Wifi hotspot speed to 5 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_5g_summary">5 GHz / Most devices can connect</string>
    <string name="wifi_hotspot_speed_summary_5g">5 GHz / Most devices can connect</string>
    <!-- Summary for Wifi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_6g_summary">6 GHz / Few devices can connect</string>
    <string name="wifi_hotspot_speed_summary_6g">6 GHz / Few devices can connect</string>
    <!-- Summary for Wifi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_2g_and_5g_summary">2.4 and 5 GHz / Any device can connect</string>
    <string name="wifi_hotspot_speed_summary_2g_and_5g">2.4 and 5 GHz / Any device can connect</string>
    <!-- Top introduction on the Wi-Fi hotspot speed settings, summarizes options available for Wi-Fi hotspot bands. [CHAR LIMIT=NONE] -->
    <string name="wifi_hotspot_speed_intro">Choose a frequency for your hotspot. The frequency affects the connection speed and what types of devices can find your hotspot.</string>
    <!-- Category title on the radio button of the Wi-Fi hotspot speed. [CHAR LIMIT=NONE] -->
    <string name="wifi_hotspot_speed_category">Preferred frequency</string>
    <!-- Title for radio button of the Wi-Fi hotspot speed to 2.4 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_2g">2.4 GHz</string>
    <!-- Summary for radio button of the Wi-Fi hotspot speed to 2.4 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_2g_summary">Slower speeds. Any device can connect.</string>
    <!-- Title for radio button of the Wi-Fi hotspot speed to 5 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_5g">5 GHz</string>
    <!-- Summary for radio button of the Wi-Fi hotspot speed to 5 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_5g_summary">Fast speeds. Most devices can connect.</string>
    <!-- Title for radio button of the Wi-Fi hotspot speed to 2.4 GHz and 5 GHz bands [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_2g_5g">2.4 and 5 GHz</string>
    <!-- Summary for radio button of the Wi-Fi hotspot speed to 2.4 GHz and 5 GHz bands [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_2g_5g_summary">Fast speeds. Any device can connect to this dual-band hotspot.</string>
    <!-- Title for radio button of the Wi-Fi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_6g">6 GHz</string>
    <!-- Summary for radio button of the Wi-Fi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_6g_summary">Fastest speeds. Fewest devices can connect.</string>
    <!-- Summary for the Wi-Fi hotspot speed unavailable [CHAR LIMIT=NONE]-->
    <string name="wifi_hotspot_speed_summary_unavailable">Not available in your country or region</string>
    <!-- The footer message for switch screen resolution [CHAR LIMIT=NONE] -->
    <string name="wifi_hotspot_speed_footer">If your preferred frequency isn\u0027t available, your hotspot may use a different one. Hotspot security settings may change if you change the frequency.</string>
    <!-- Summary text when turning hotspot on -->
    <string name="wifi_tether_starting">Turning hotspot on\u2026</string>
+61 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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.
  -->
<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/wifi_hotspot_speed_title"
    settings:searchable="false">

    <com.android.settingslib.widget.TopIntroPreference
        android:key="wifi_hotspot_speed_intro"
        android:title="@string/wifi_hotspot_speed_intro"/>

    <PreferenceCategory
        android:key="wifi_hotspot_speed"
        android:title="@string/wifi_hotspot_speed_category">

        <com.android.settingslib.widget.SelectorWithWidgetPreference
            android:key="wifi_hotspot_speed_2g"
            android:title="@string/wifi_hotspot_speed_2g"
            android:summary="@string/wifi_hotspot_speed_2g_summary"
            android:visibility="gone"/>

        <com.android.settingslib.widget.SelectorWithWidgetPreference
            android:key="wifi_hotspot_speed_5g"
            android:title="@string/wifi_hotspot_speed_5g"
            android:summary="@string/wifi_hotspot_speed_5g_summary"
            android:visibility="gone"/>

        <com.android.settingslib.widget.SelectorWithWidgetPreference
            android:key="wifi_hotspot_speed_2g_5g"
            android:title="@string/wifi_hotspot_speed_2g_5g"
            android:summary="@string/wifi_hotspot_speed_2g_5g_summary"/>

        <com.android.settingslib.widget.SelectorWithWidgetPreference
            android:key="wifi_hotspot_speed_6g"
            android:title="@string/wifi_hotspot_speed_6g"
            android:summary="@string/wifi_hotspot_speed_6g_summary"/>
    </PreferenceCategory>

    <com.android.settingslib.widget.FooterPreference
        android:key="wifi_hotspot_speed__footer"
        android:title="@string/wifi_hotspot_speed_footer"
        android:selectable="false"/>
</PreferenceScreen>


+1 −0
Original line number Diff line number Diff line
@@ -50,5 +50,6 @@
        android:key="wifi_hotspot_speed"
        android:title="@string/wifi_hotspot_speed_title"
        android:summary="@string/summary_placeholder"
        android:fragment="com.android.settings.wifi.tether.WifiHotspotSpeedSettings"
        settings:isPreferenceVisible="@bool/config_show_wifi_hotspot_speed"/>
</PreferenceScreen>
+38 −1
Original line number Diff line number Diff line
@@ -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);
    }
}
+55 −0
Original line number Diff line number Diff line
/*
 * 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);
        }
    }
}
Loading