mirror of
git://f0xx.org/android_cast
synced 2026-07-29 08:57:44 +03:00
sync
This commit is contained in:
@@ -21,14 +21,18 @@ import com.foxx.androidcast.DeviceInfo;
|
||||
import com.foxx.androidcast.R;
|
||||
import com.foxx.androidcast.vpn.VpnServiceClient;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/** Jittered heartbeat type:ra polling while remote access mode is active. */
|
||||
public final class RemoteAccessService extends Service {
|
||||
private static final String TAG = "RemoteAccessSvc";
|
||||
@@ -369,9 +373,34 @@ public final class RemoteAccessService extends Service {
|
||||
abis.put(abi);
|
||||
}
|
||||
device.put("abis", abis);
|
||||
String lanIp = localLanIpV4();
|
||||
if (!lanIp.isEmpty()) {
|
||||
device.put("lan_ip", lanIp);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
private static String localLanIpV4() {
|
||||
try {
|
||||
for (NetworkInterface intf : Collections.list(NetworkInterface.getNetworkInterfaces())) {
|
||||
if (intf == null || !intf.isUp() || intf.isLoopback()) {
|
||||
continue;
|
||||
}
|
||||
for (InetAddress addr : Collections.list(intf.getInetAddresses())) {
|
||||
if (addr == null || addr.isLoopbackAddress() || !(addr instanceof Inet4Address)) {
|
||||
continue;
|
||||
}
|
||||
String host = addr.getHostAddress();
|
||||
if (host != null && !host.isEmpty()) {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user