Merge "Remove WifiManager.getTxPacketCount" into rvc-dev
This commit is contained in:
@@ -18,6 +18,7 @@ package android.net.wifi;
|
||||
|
||||
/**
|
||||
* Interface for tx packet counter callback.
|
||||
* @deprecated no longer used, remove once removed from BaseWifiService
|
||||
* @hide
|
||||
*/
|
||||
oneway interface ITxPacketCountListener
|
||||
|
||||
@@ -34,7 +34,6 @@ import android.net.wifi.IScanResultsCallback;
|
||||
import android.net.wifi.ISoftApCallback;
|
||||
import android.net.wifi.ISuggestionConnectionStatusListener;
|
||||
import android.net.wifi.ITrafficStateCallback;
|
||||
import android.net.wifi.ITxPacketCountListener;
|
||||
import android.net.wifi.IWifiConnectedNetworkScorer;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
@@ -246,8 +245,6 @@ interface IWifiManager
|
||||
|
||||
oneway void forget(int netId, in IBinder binder, in IActionListener listener, int callbackIdentifier);
|
||||
|
||||
oneway void getTxPacketCount(String packageName, in IBinder binder, in ITxPacketCountListener listener, int callbackIdentifier);
|
||||
|
||||
void registerScanResultsCallback(in IScanResultsCallback callback);
|
||||
|
||||
void unregisterScanResultsCallback(in IScanResultsCallback callback);
|
||||
|
||||
@@ -2908,28 +2908,6 @@ public class WifiManager {
|
||||
return getWifiState() == WIFI_STATE_ENABLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return TX packet counter, for CTS test of WiFi watchdog.
|
||||
* @param listener is the interface to receive result
|
||||
*
|
||||
* @hide for CTS test only
|
||||
*/
|
||||
// TODO(b/144036594): add @TestApi
|
||||
public void getTxPacketCount(@NonNull TxPacketCountListener listener) {
|
||||
if (listener == null) throw new IllegalArgumentException("listener cannot be null");
|
||||
Binder binder = new Binder();
|
||||
TxPacketCountListenerProxy listenerProxy =
|
||||
new TxPacketCountListenerProxy(mLooper, listener);
|
||||
try {
|
||||
mService.getTxPacketCount(mContext.getOpPackageName(), binder, listenerProxy,
|
||||
listener.hashCode());
|
||||
} catch (RemoteException e) {
|
||||
listenerProxy.onFailure(ERROR);
|
||||
} catch (SecurityException e) {
|
||||
listenerProxy.onFailure(NOT_AUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the level of the signal. This should be used any time a signal
|
||||
* is being shown.
|
||||
@@ -3582,56 +3560,6 @@ public class WifiManager {
|
||||
public abstract void onFailed(int reason);
|
||||
}
|
||||
|
||||
/** Interface for callback invocation on a TX packet count poll action {@hide} */
|
||||
public interface TxPacketCountListener {
|
||||
/**
|
||||
* The operation succeeded
|
||||
* @param count TX packet counter
|
||||
*/
|
||||
public void onSuccess(int count);
|
||||
/**
|
||||
* The operation failed
|
||||
* @param reason The reason for failure could be one of
|
||||
* {@link #ERROR}, {@link #IN_PROGRESS} or {@link #BUSY}
|
||||
*/
|
||||
public void onFailure(int reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback proxy for TxPacketCountListener objects.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
private class TxPacketCountListenerProxy extends ITxPacketCountListener.Stub {
|
||||
private final Handler mHandler;
|
||||
private final TxPacketCountListener mCallback;
|
||||
|
||||
TxPacketCountListenerProxy(Looper looper, TxPacketCountListener callback) {
|
||||
mHandler = new Handler(looper);
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(int count) {
|
||||
if (mVerboseLoggingEnabled) {
|
||||
Log.v(TAG, "TxPacketCounterProxy: onSuccess: count=" + count);
|
||||
}
|
||||
mHandler.post(() -> {
|
||||
mCallback.onSuccess(count);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int reason) {
|
||||
if (mVerboseLoggingEnabled) {
|
||||
Log.v(TAG, "TxPacketCounterProxy: onFailure: reason=" + reason);
|
||||
}
|
||||
mHandler.post(() -> {
|
||||
mCallback.onFailure(reason);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for soft AP callback. Should be extended by applications and set when calling
|
||||
* {@link WifiManager#registerSoftApCallback(Executor, SoftApCallback)}.
|
||||
|
||||
@@ -30,7 +30,6 @@ import static android.net.wifi.WifiManager.OnWifiActivityEnergyInfoListener;
|
||||
import static android.net.wifi.WifiManager.SAP_START_FAILURE_GENERAL;
|
||||
import static android.net.wifi.WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS;
|
||||
import static android.net.wifi.WifiManager.STATUS_SUGGESTION_CONNECTION_FAILURE_AUTHENTICATION;
|
||||
import static android.net.wifi.WifiManager.TxPacketCountListener;
|
||||
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
|
||||
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLING;
|
||||
import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;
|
||||
@@ -2050,32 +2049,6 @@ public class WifiManagerTest {
|
||||
null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test behavior of {@link WifiManager#getTxPacketCount(TxPacketCountListener)}
|
||||
*/
|
||||
@Test
|
||||
public void testGetTxPacketCount() throws Exception {
|
||||
TxPacketCountListener externalListener =
|
||||
mock(TxPacketCountListener.class);
|
||||
mWifiManager.getTxPacketCount(externalListener);
|
||||
|
||||
ArgumentCaptor<ITxPacketCountListener> binderListenerCaptor =
|
||||
ArgumentCaptor.forClass(ITxPacketCountListener.class);
|
||||
verify(mWifiService).getTxPacketCount(anyString(), any(Binder.class),
|
||||
binderListenerCaptor.capture(), anyInt());
|
||||
assertNotNull(binderListenerCaptor.getValue());
|
||||
|
||||
// Trigger on success.
|
||||
binderListenerCaptor.getValue().onSuccess(6);
|
||||
mLooper.dispatchAll();
|
||||
verify(externalListener).onSuccess(6);
|
||||
|
||||
// Trigger on failure.
|
||||
binderListenerCaptor.getValue().onFailure(BUSY);
|
||||
mLooper.dispatchAll();
|
||||
verify(externalListener).onFailure(BUSY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify an IllegalArgumentException is thrown if callback is not provided.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user