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

Commit 005fe695 authored by Arc Wang's avatar Arc Wang
Browse files

[Wi-Fi] Add STA+AP information in Hotspot & tethering footer

Use WifiManager#isStaApConcurrencySupported() to check if a
device supports STA+AP and shows the footer information.

Bug: 121328949
Test: make RunSettingsRoboTests ROBOTEST_FILTER=TetherSettingsTest
      make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherFooterPreferenceControllerTest
Change-Id: I3446abb5cc9cdf76da8d17f5de31bd65715c165c
parent be753c35
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3814,6 +3814,8 @@
    <!-- Tethering footer info [CHAR LIMIT=NONE]-->
    <string name="tethering_footer_info">Use hotspot and tethering to provide internet to other devices through your mobile data connection. Apps can also create a hotspot to share content with nearby devices.</string>
    <!-- Tethering footer info for the device which supports Wi-Fi and Wi-Fi tethering enabled at the same time [CHAR LIMIT=NONE]-->
    <string name="tethering_footer_info_sta_ap_concurrency">Use hotspot and tethering to provide internet to other devices through your Wi\u2011Fi or mobile data connection. Apps can also create a hotspot to share content with nearby devices.</string>
    <!-- Tethering help button - calls up a web view with general tethering info -->
    <string name="tethering_help_button_text">Help</string>
+0 −1
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@

    <com.android.settingslib.widget.FooterPreference
        android:key="tether_prefs_footer_2"
        android:title="@string/tethering_footer_info"
        android:selectable="false"
        settings:searchable="false"/>
</PreferenceScreen>
+0 −1
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@

    <com.android.settingslib.widget.FooterPreference
        android:key="tether_prefs_footer"
        android:title="@string/tethering_footer_info"
        android:selectable="false"
        settings:searchable="false"/>
</PreferenceScreen>
+4 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.settings.widget.SwitchBarController;
import com.android.settings.wifi.tether.WifiTetherApBandPreferenceController;
import com.android.settings.wifi.tether.WifiTetherAutoOffPreferenceController;
import com.android.settings.wifi.tether.WifiTetherBasePreferenceController;
import com.android.settings.wifi.tether.WifiTetherFooterPreferenceController;
import com.android.settings.wifi.tether.WifiTetherPasswordPreferenceController;
import com.android.settings.wifi.tether.WifiTetherSSIDPreferenceController;
import com.android.settings.wifi.tether.WifiTetherSecurityPreferenceController;
@@ -71,7 +72,7 @@ import java.util.concurrent.atomic.AtomicReference;
 * Displays preferences for all Tethering options.
 */
@SearchIndexable
public final class AllInOneTetherSettings extends RestrictedDashboardFragment
public class AllInOneTetherSettings extends RestrictedDashboardFragment
        implements DataSaverBackend.Listener,
        WifiTetherBasePreferenceController.OnTetherConfigUpdateListener,
        SharedPreferences.OnSharedPreferenceChangeListener {
@@ -304,6 +305,8 @@ public final class AllInOneTetherSettings extends RestrictedDashboardFragment
                new WifiTetherSecurityPreferenceController(context, listener));
        controllers.add(
                new WifiTetherAutoOffPreferenceController(context, KEY_WIFI_TETHER_AUTO_OFF));
        controllers.add(
                new WifiTetherFooterPreferenceController(context));

        return controllers;
    }
+16 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.hardware.usb.UsbManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -71,6 +72,8 @@ public class TetherSettings extends RestrictedSettingsFragment
    @VisibleForTesting
    static final String KEY_ENABLE_BLUETOOTH_TETHERING = "enable_bluetooth_tethering";
    private static final String KEY_DATA_SAVER_FOOTER = "disabled_on_data_saver";
    @VisibleForTesting
    static final String KEY_TETHER_PREFS_FOOTER = "tether_prefs_footer";

    private static final String TAG = "TetheringSettings";

@@ -141,6 +144,7 @@ public class TetherSettings extends RestrictedSettingsFragment

        mUsbTether = (SwitchPreference) findPreference(KEY_USB_TETHER_SETTINGS);
        mBluetoothTether = (SwitchPreference) findPreference(KEY_ENABLE_BLUETOOTH_TETHERING);
        setFooterPreferenceTitle();

        mDataSaverBackend.addListener(this);

@@ -201,6 +205,18 @@ public class TetherSettings extends RestrictedSettingsFragment
    public void onBlacklistStatusChanged(int uid, boolean isBlacklisted)  {
    }

    @VisibleForTesting
    void setFooterPreferenceTitle() {
        final Preference footerPreference = findPreference(KEY_TETHER_PREFS_FOOTER);
        final WifiManager wifiManager =
                (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
        if (wifiManager.isStaApConcurrencySupported()) {
            footerPreference.setTitle(R.string.tethering_footer_info_sta_ap_concurrency);
        } else {
            footerPreference.setTitle(R.string.tethering_footer_info);
        }
    }

    private class TetherChangeReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context content, Intent intent) {
Loading