зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1718512 - Remove unused BundleEventListener from GeckoNetworkManager. r=geckoview-reviewers,aklotz
By bug 1697680, Gecko removes Presentation API. `Wifi:GetIPAddress` was only used on this API implementation. So now, this is unused. Differential Revision: https://phabricator.services.mozilla.com/D118911
This commit is contained in:
Родитель
5e48211fc7
Коммит
1c5c3f4ec2
|
@ -6,9 +6,6 @@
|
|||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.util.BundleEventListener;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
import org.mozilla.gecko.util.NetworkUtils;
|
||||
import org.mozilla.gecko.util.NetworkUtils.ConnectionSubType;
|
||||
import org.mozilla.gecko.util.NetworkUtils.ConnectionType;
|
||||
|
@ -21,11 +18,9 @@ import android.content.Intent;
|
|||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.DhcpInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +36,7 @@ import android.util.Log;
|
|||
* Logic is implemented as a state machine, so see the transition matrix to figure out what happens when.
|
||||
* This class depends on access to the context, so only use after GeckoAppShell has been initialized.
|
||||
*/
|
||||
public class GeckoNetworkManager extends BroadcastReceiver implements BundleEventListener {
|
||||
public class GeckoNetworkManager extends BroadcastReceiver {
|
||||
private static final String LOGTAG = "GeckoNetworkManager";
|
||||
|
||||
// If network configuration and/or status changed, we send details of what changed.
|
||||
|
@ -85,20 +80,11 @@ public class GeckoNetworkManager extends BroadcastReceiver implements BundleEven
|
|||
private NetworkStatus mCurrentNetworkStatus = NetworkStatus.UNKNOWN;
|
||||
private NetworkStatus mPreviousNetworkStatus = NetworkStatus.UNKNOWN;
|
||||
|
||||
private enum InfoType {
|
||||
MCC,
|
||||
MNC
|
||||
}
|
||||
|
||||
private GeckoNetworkManager() {
|
||||
EventDispatcher.getInstance().registerUiThreadListener(this,
|
||||
"Wifi:GetIPAddress");
|
||||
}
|
||||
|
||||
private void onDestroy() {
|
||||
handleManagerEvent(ManagerEvent.stop);
|
||||
EventDispatcher.getInstance().unregisterUiThreadListener(this,
|
||||
"Wifi:GetIPAddress");
|
||||
}
|
||||
|
||||
public static GeckoNetworkManager getInstance() {
|
||||
|
@ -406,42 +392,4 @@ public class GeckoNetworkManager extends BroadcastReceiver implements BundleEven
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override // BundleEventListener
|
||||
/**
|
||||
* Handles native messages, not part of the state machine flow.
|
||||
*/
|
||||
public void handleMessage(final String event, final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
final Context applicationContext = GeckoAppShell.getApplicationContext();
|
||||
switch (event) {
|
||||
case "Wifi:GetIPAddress":
|
||||
getWifiIPAddress(callback);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// This function only works for IPv4; not part of the state machine flow.
|
||||
private void getWifiIPAddress(final EventCallback callback) {
|
||||
final WifiManager mgr = (WifiManager) GeckoAppShell.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
|
||||
if (mgr == null) {
|
||||
callback.sendError("Cannot get WifiManager");
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission") final WifiInfo info = mgr.getConnectionInfo();
|
||||
if (info == null) {
|
||||
callback.sendError("Cannot get connection info");
|
||||
return;
|
||||
}
|
||||
|
||||
final int ip = info.getIpAddress();
|
||||
if (ip == 0) {
|
||||
callback.sendError("Cannot get IPv4 address");
|
||||
return;
|
||||
}
|
||||
callback.sendSuccess(Formatter.formatIpAddress(ip));
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче