Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><strong>Note</strong>: This answer was true for the API level 14, I don't know if it still applies to the latest Android versions.</p> </blockquote> <p>A non documented file named WifiP2pPeer exists in the Android code source. It contains some "interesting" lines.</p> <p>We can see that a RSSI value is hard-coded (<code>mRssi = 60; //TODO: fix</code>), so the feature may not be implemented yet... (Like others in Android 14 regarding WifiP2p).</p> <pre><code>public class WifiP2pPeer extends Preference { private static final int[] STATE_SECURED = {R.attr.state_encrypted}; public WifiP2pDevice device; private int mRssi; private ImageView mSignal; private static final int SIGNAL_LEVELS = 4; public WifiP2pPeer(Context context, WifiP2pDevice dev) { super(context); device = dev; setWidgetLayoutResource(R.layout.preference_widget_wifi_signal); mRssi = 60; //TODO: fix } @Override protected void onBindView(View view) { if (TextUtils.isEmpty(device.deviceName)) { setTitle(device.deviceAddress); } else { setTitle(device.deviceName); } mSignal = (ImageView) view.findViewById(R.id.signal); if (mRssi == Integer.MAX_VALUE) { mSignal.setImageDrawable(null); } else { mSignal.setImageResource(R.drawable.wifi_signal); mSignal.setImageState(STATE_SECURED, true); } refresh(); super.onBindView(view); } @Override public int compareTo(Preference preference) { if (!(preference instanceof WifiP2pPeer)) { return 1; } WifiP2pPeer other = (WifiP2pPeer) preference; // devices go in the order of the status if (device.status != other.device.status) { return device.status &lt; other.device.status ? -1 : 1; } // Sort by name/address if (device.deviceName != null) { return device.deviceName.compareToIgnoreCase(other.device.deviceName); } return device.deviceAddress.compareToIgnoreCase(other.device.deviceAddress); } int getLevel() { if (mRssi == Integer.MAX_VALUE) { return -1; } return WifiManager.calculateSignalLevel(mRssi, SIGNAL_LEVELS); } private void refresh() { if (mSignal == null) { return; } Context context = getContext(); mSignal.setImageLevel(getLevel()); String[] statusArray = context.getResources().getStringArray(R.array.wifi_p2p_status); setSummary(statusArray[device.status]); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload