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

Commit 08849011 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9211918 from 02cf722b to tm-qpr2-release

Change-Id: Id065d2e3897ecdf149afecd376bd512dcb294675
parents c0156f0d 02cf722b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -331,6 +331,9 @@
    surface in search results or not.-->
    <bool name="config_show_wifi_settings">true</bool>

    <!-- Whether Wi-Fi hotspot settings should be shown or not. -->
    <bool name="config_show_wifi_hotspot_settings">true</bool>

    <!-- Whether toggle_airplane is available or not. -->
    <bool name="config_show_toggle_airplane">true</bool>

+3 −1
Original line number Diff line number Diff line
@@ -64,7 +64,9 @@ public class MediaOutputUtils {
                        + ", play back type : " + pi.getPlaybackType() + ", play back state : "
                        + playbackState.getState());
            }
            if (playbackState.getState() != PlaybackState.STATE_PLAYING) {
            if (playbackState.getState() == PlaybackState.STATE_STOPPED
                    || playbackState.getState() == PlaybackState.STATE_NONE
                    || playbackState.getState() == PlaybackState.STATE_ERROR) {
                // do nothing
                continue;
            }
+7 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.settingslib.utils.ThreadUtils;

import com.google.android.setupdesign.DividerItemDecoration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
@@ -339,8 +340,13 @@ public class PanelFragment extends Fragment {
            mSliceLiveData.put(uri, sliceLiveData);

            sliceLiveData.observe(getViewLifecycleOwner(), slice -> {
                // If the Slice has already loaded, do nothing.

                // If the Slice has already loaded, refresh list with slice data.
                if (mPanelSlicesLoaderCountdownLatch.isSliceLoaded(uri)) {
                    if (mAdapter != null) {
                        int itemIndex = (new ArrayList<>(mSliceLiveData.keySet())).indexOf(uri);
                        mAdapter.notifyItemChanged(itemIndex);
                    }
                    return;
                }

+7 −8
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public class PanelSlicesAdapter

    @Override
    public void onBindViewHolder(@NonNull SliceRowViewHolder sliceRowViewHolder, int position) {
        sliceRowViewHolder.onBind(mSliceLiveData.get(position), position);
        sliceRowViewHolder.onBind(mSliceLiveData.get(position).getValue());
    }

    /**
@@ -132,15 +132,14 @@ public class PanelSlicesAdapter
        /**
         * Called when the view is displayed.
         */
        public void onBind(LiveData<Slice> sliceLiveData, int position) {
            sliceLiveData.observe(mPanelFragment.getViewLifecycleOwner(), sliceView);

            // Do not show the divider above media devices switcher slice per request
            final Slice slice = sliceLiveData.getValue();

        public void onBind(Slice slice) {
            // Hides slice which reports with error hint or not contain any slice sub-item.
            if (slice == null || !isValidSlice(slice)) {
                sliceView.setVisibility(View.GONE);
                return;
            } else {
                sliceView.setSlice(slice);
                sliceView.setVisibility(View.VISIBLE);
            }

            // Add divider for the end icon
@@ -154,7 +153,7 @@ public class PanelSlicesAdapter
                                .action(0 /* attribution */,
                                        SettingsEnums.ACTION_PANEL_INTERACTION,
                                        mMetricsCategory,
                                        sliceLiveData.getValue().getUri().getLastPathSegment()
                                        slice.getUri().getLastPathSegment()
                                        /* log key */,
                                        eventInfo.actionType /* value */);
                    })
+68 −0
Original line number Diff line number Diff line
@@ -22,14 +22,20 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.NetworkCapabilities;
import android.net.TetheringManager;
import android.net.wifi.ScanResult;
import android.net.wifi.SoftApConfiguration;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.VisibleForTesting;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.wifitrackerlib.WifiEntry;

@@ -38,12 +44,16 @@ import java.nio.charset.StandardCharsets;
/** A utility class for Wi-Fi functions. */
public class WifiUtils extends com.android.settingslib.wifi.WifiUtils {

    static final String TAG = "WifiUtils";

    private static final int SSID_ASCII_MIN_LENGTH = 1;
    private static final int SSID_ASCII_MAX_LENGTH = 32;

    private static final int PSK_PASSPHRASE_ASCII_MIN_LENGTH = 8;
    private static final int PSK_PASSPHRASE_ASCII_MAX_LENGTH = 63;

    private static Boolean sCanShowWifiHotspotCached;

    public static boolean isSSIDTooLong(String ssid) {
        if (TextUtils.isEmpty(ssid)) {
            return false;
@@ -240,4 +250,62 @@ public class WifiUtils extends com.android.settingslib.wifi.WifiUtils {

        return WifiEntry.SECURITY_NONE;
    }

    /**
     * Check if Wi-Fi hotspot settings can be displayed.
     *
     * @param context Context of caller
     * @return true if Wi-Fi hotspot settings can be displayed
     */
    public static boolean checkShowWifiHotspot(Context context) {
        if (context == null) return false;

        boolean showWifiHotspotSettings =
                context.getResources().getBoolean(R.bool.config_show_wifi_hotspot_settings);
        if (!showWifiHotspotSettings) {
            Log.w(TAG, "config_show_wifi_hotspot_settings:false");
            return false;
        }

        WifiManager wifiManager = context.getSystemService(WifiManager.class);
        if (wifiManager == null) {
            Log.e(TAG, "WifiManager is null");
            return false;
        }

        TetheringManager tetheringManager = context.getSystemService(TetheringManager.class);
        if (tetheringManager == null) {
            Log.e(TAG, "TetheringManager is null");
            return false;
        }
        String[] wifiRegexs = tetheringManager.getTetherableWifiRegexs();
        if (wifiRegexs == null || wifiRegexs.length == 0) {
            Log.w(TAG, "TetherableWifiRegexs is empty");
            return false;
        }
        return true;
    }

    /**
     * Return the cached result to see if Wi-Fi hotspot settings can be displayed.
     *
     * @param context Context of caller
     * @return true if Wi-Fi hotspot settings can be displayed
     */
    public static boolean canShowWifiHotspot(Context context) {
        if (sCanShowWifiHotspotCached == null) {
            sCanShowWifiHotspotCached = checkShowWifiHotspot(context);
        }
        return sCanShowWifiHotspotCached;
    }

    /**
     * Sets the sCanShowWifiHotspotCached for testing purposes.
     *
     * @param cached Cached value for #canShowWifiHotspot()
     */
    @VisibleForTesting
    public static void setCanShowWifiHotspotCached(Boolean cached) {
        sCanShowWifiHotspotCached = cached;
    }
}
Loading