调整Wifi满格信号的阀值 |
您所在的位置:网站首页 › 为什么wifi满格还显示网络不给力 › 调整Wifi满格信号的阀值 |
要想wifi在信号比较差的时候也显示满格信号,可参考如下方法 http://aospxref.com/android-11.0.0_r21/xref/frameworks/base/wifi/java/android/net/wifi/WifiManager.java /** Anything worse than or equal to this will show 0 bars. */ @UnsupportedAppUsage private static final int MIN_RSSI = -100; /** Anything better than or equal to this will show the max bars. */ @UnsupportedAppUsage private static final int MAX_RSSI = -55; /** * Number of RSSI levels used in the framework to initiate {@link #RSSI_CHANGED_ACTION} * broadcast, where each level corresponds to a range of RSSI values. * The {@link #RSSI_CHANGED_ACTION} broadcast will only fire if the RSSI * change is significant enough to change the RSSI signal level. * @hide */ @UnsupportedAppUsage public static final int RSSI_LEVELS = 5; /** * Calculates the level of the signal. This should be used any time a signal * is being shown. * * @param rssi The power of the signal measured in RSSI. * @param numLevels The number of levels to consider in the calculated level. * @return A level of the signal, given in the range of 0 to numLevels-1 (both inclusive). * @deprecated Callers should use {@link #calculateSignalLevel(int)} instead to get the * signal level using the system default RSSI thresholds, or otherwise compute the RSSI level * themselves using their own formula. */ @Deprecated public static int calculateSignalLevel(int rssi, int numLevels) { if (rssi = MAX_RSSI) { return numLevels - 1; } else { float inputRange = (MAX_RSSI - MIN_RSSI); float outputRange = (numLevels - 1); return (int)((float)(rssi - MIN_RSSI) * outputRange / inputRange); } }
对于Android11,接口有变化 http://aospxref.com/android-11.0.0_r21/xref/frameworks/opt/net/wifi/service/java/com/android/server/wifi/util/RssiUtil.java /* * Copyright (C) 2019 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.server.wifi.util; import android.annotation.NonNull; import android.content.Context; import com.android.wifi.resources.R; /** Utilities for computations involving RSSI. */ public class RssiUtil { private RssiUtil() {} /** Calculate RSSI level from RSSI using overlaid RSSI level thresholds. */ public static int calculateSignalLevel(Context context, int rssi) { int[] thresholds = getRssiLevelThresholds(context); for (int level = 0; level < thresholds.length; level++) { if (rssi < thresholds[level]) { return level; } } return thresholds.length; } @NonNull private static int[] getRssiLevelThresholds(Context context) { // getIntArray() will never return null, it will throw instead return context.getResources().getIntArray(R.array.config_wifiRssiLevelThresholds); } }http://aospxref.com/android-11.0.0_r21/xref/frameworks/opt/net/wifi/service/res/values/config.xml -88 -77 -66 -55如何确认修改有效,打开开发者选项,勾选开启wlan详细日记记录,然后到wifi的搜索界面上看下已连接wifi信号的rssi值,然后移动手机,看信号格数有没有符合要求。 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |