From e6854121d579ac51c1d5759095d4fdb4f12eaa2b Mon Sep 17 00:00:00 2001 From: huangjian Date: Tue, 15 Dec 2020 18:02:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=8F=B3=E6=8E=A8?= =?UTF-8?q?=E5=B9=BF=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erban/application/XChatApplication.java | 2 + .../channel_page/model/ChannelPageModel.java | 34 +++++++++++++ .../channel_page/model/IChannelPageModel.java | 2 + gradle.properties | 4 +- .../utils/NetworkUtils.java | 48 ++++++++++++++----- 5 files changed, 75 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/yizhuan/erban/application/XChatApplication.java b/app/src/main/java/com/yizhuan/erban/application/XChatApplication.java index 9910feebd..d00820f3e 100644 --- a/app/src/main/java/com/yizhuan/erban/application/XChatApplication.java +++ b/app/src/main/java/com/yizhuan/erban/application/XChatApplication.java @@ -67,6 +67,7 @@ import com.yizhuan.xchat_android_core.Env; import com.yizhuan.xchat_android_core.UriProvider; import com.yizhuan.xchat_android_core.auth.AuthModel; import com.yizhuan.xchat_android_core.channel.ChannelModel; +import com.yizhuan.xchat_android_core.channel_page.model.ChannelPageModel; import com.yizhuan.xchat_android_core.customer_server.CustomerServerModel; import com.yizhuan.xchat_android_core.family.model.FamilyModel; import com.yizhuan.xchat_android_core.gift.GiftModel; @@ -741,6 +742,7 @@ public class XChatApplication extends Application { GlobalHandleManager.get().init(); InitialModel.get().init(true).subscribe(); + ChannelPageModel.get().checkZuiyouAd(oaid); } diff --git a/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/ChannelPageModel.java b/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/ChannelPageModel.java index 126641504..16238d6d5 100644 --- a/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/ChannelPageModel.java +++ b/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/ChannelPageModel.java @@ -6,9 +6,16 @@ import com.yizhuan.xchat_android_core.channel_page.bean.ChannelPageInfo; import com.yizhuan.xchat_android_core.user.bean.InviteUserInfo; import com.yizhuan.xchat_android_core.utils.net.RxHelper; import com.yizhuan.xchat_android_library.net.rxnet.RxNet; +import com.yizhuan.xchat_android_library.utils.DeviceUuidFactory; +import com.yizhuan.xchat_android_library.utils.NetworkUtils; +import com.yizhuan.xchat_android_library.utils.codec.MD5Utils; +import com.yizhuan.xchat_android_library.utils.config.BasicConfig; import io.reactivex.Single; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; +import retrofit2.http.POST; import retrofit2.http.Query; /** @@ -61,6 +68,21 @@ public class ChannelPageModel extends BaseModel implements IChannelPageModel { .compose(RxHelper.handleSchAndExce()); } + @Override + public void checkZuiyouAd(String oaid) { + try { + api.checkZuiyouAd(DeviceUuidFactory.getDeviceId(BasicConfig.INSTANCE.getAppContext()), + NetworkUtils.getIPAddress(BasicConfig.INSTANCE.getAppContext()), + "0", + System.getProperty("http.agent")) + .compose(RxHelper.handleSchedulers()) + .subscribe(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + private interface Api { /** @@ -74,6 +96,18 @@ public class ChannelPageModel extends BaseModel implements IChannelPageModel { */ @GET("/user/v2/checkInviteUserInRoom") Single> checkInviteUserInRoom(@Query("inviteCode") String inviteCode); + + /** + * 最右推广接口 + */ + @FormUrlEncoded + @POST("/zuiyouAd/activeTrack") + Single> checkZuiyouAd(@Field("adroidId") String adroidId, + @Field("ip") String ip, + @Field("platformOs") String platformOs, + @Field("ua") String ua); + + } } diff --git a/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/IChannelPageModel.java b/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/IChannelPageModel.java index 5ce0c2817..89a413647 100644 --- a/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/IChannelPageModel.java +++ b/core/src/model_channel_page/java/com/yizhuan/xchat_android_core/channel_page/model/IChannelPageModel.java @@ -14,4 +14,6 @@ public interface IChannelPageModel { Single getChannelPage(); Single checkInviteUserInRoom(String inviteCode); + + void checkZuiyouAd(String oaid); } diff --git a/gradle.properties b/gradle.properties index 6c0f5682e..1ac8b5d5f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,5 +21,5 @@ with_jenkins=false #\u6253\u652F\u6301x86\u7684\u6A21\u62DF\u5668\u5305\u4F7F\u7528 ndk_abi_filters=arm -version_name=2.0.0 -version_code=200 \ No newline at end of file +version_name=2.0.3 +version_code=203 \ No newline at end of file diff --git a/library/src/main/java/com/yizhuan/xchat_android_library/utils/NetworkUtils.java b/library/src/main/java/com/yizhuan/xchat_android_library/utils/NetworkUtils.java index 1722a0f56..837168eff 100644 --- a/library/src/main/java/com/yizhuan/xchat_android_library/utils/NetworkUtils.java +++ b/library/src/main/java/com/yizhuan/xchat_android_library/utils/NetworkUtils.java @@ -39,6 +39,30 @@ public class NetworkUtils { return sWifiLocker; } + public String getLocalHostIp() { + String ipaddress = ""; + try { + Enumeration en = NetworkInterface + .getNetworkInterfaces(); + // 遍历所用的网络接口 + while (en.hasMoreElements()) { + NetworkInterface nif = en.nextElement();// 得到每一个网络接口绑定的所有ip + Enumeration inet = nif.getInetAddresses(); + // 遍历每一个接口绑定的所有ip + while (inet.hasMoreElements()) { + InetAddress ip = inet.nextElement(); + if (!ip.isLoopbackAddress()) { + return ip.getHostAddress(); + } + } + } + } catch (SocketException e) { + e.printStackTrace(); + } + return ipaddress; + + } + public static void lockWifi(Context c) { Log.d(TAG, "lock wifi"); if (!wifiLocker(c).isHeld()) @@ -52,7 +76,7 @@ public class NetworkUtils { } public static boolean isWifiActive(Context c) { - if(c == null){ + if (c == null) { Log.e("xuwakao", "isWifiActive is NULL"); return false; } @@ -63,7 +87,7 @@ public class NetworkUtils { } public static boolean isMobileActive(Context c) { - if(c == null){ + if (c == null) { Log.e("xuwakao", "isWifiActive is NULL"); return false; } @@ -74,7 +98,7 @@ public class NetworkUtils { } public static boolean isNetworkStrictlyAvailable(Context c) { - if(c == null){ + if (c == null) { Log.e("xuwakao", "isNetworkStrictlyAvailable context is NULL"); return false; } @@ -309,7 +333,7 @@ public class NetworkUtils { return "Unknown"; } - public static final int NET_INVALID = 0 ; // 无网络 + public static final int NET_INVALID = 0; // 无网络 public static final int NET_WIFI = 1; public static final int NET_2G = 2; public static final int NET_3G = 3; @@ -423,17 +447,16 @@ public class NetworkUtils { public static String getOperator(Context c) { String sim = getSimOperator(c); - if(FP.empty(sim)) + if (FP.empty(sim)) return ChinaOperator.UNKNOWN; if (sim.startsWith("46003") || sim.startsWith("46005")) { return ChinaOperator.CTL; } else if (sim.startsWith("46001") || sim.startsWith("46006")) { return ChinaOperator.UNICOM; } else if (sim.startsWith("46000") || sim.startsWith("46002") - || sim.startsWith("46007") || sim.startsWith("46020")){ + || sim.startsWith("46007") || sim.startsWith("46020")) { return ChinaOperator.CMCC; - } - else { + } else { return ChinaOperator.UNKNOWN; } } @@ -447,17 +470,16 @@ public class NetworkUtils { public static String getLocalIpAddress() { try { - for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { + for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { NetworkInterface intf = en.nextElement(); - for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { + for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) { InetAddress inetAddress = enumIpAddr.nextElement(); - if (!inetAddress.isLoopbackAddress()) { - return inetAddress.getHostAddress().toString(); + if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) { + return inetAddress.getHostAddress(); } } } } catch (SocketException ex) { - Log.e("NetworkUtils getLocalIpAddress:", ex.toString()); } return null; }