opt traffic light panel
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package="com.mogo.launcher">
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:name=".MogoApplication"
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.mogo.utils;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -107,4 +111,17 @@ public class NetworkUtils {
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public static int netStrengthLevel = 0;
|
||||
|
||||
public static void listenNetStrength(Context context) {
|
||||
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
manager.listen(new PhoneStateListener() {
|
||||
@Override
|
||||
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
|
||||
super.onSignalStrengthsChanged(signalStrength);
|
||||
netStrengthLevel = signalStrength.getLevel();
|
||||
}
|
||||
}, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.module.extensions.net;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/**
|
||||
* 时延验证相关接口
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public interface DelayCheckApiServices {
|
||||
|
||||
@GET("/")
|
||||
Observable<BaseData> emptyInterface();
|
||||
|
||||
@POST("/")
|
||||
@FormUrlEncoded
|
||||
Observable<BaseData> uploadDelayCheckData(@FieldMap Map<String, String> params);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.extensions.net.DelayCheckApiServices;
|
||||
import com.mogo.module.extensions.net.DztHttpConstant;
|
||||
import com.mogo.utils.NetworkUtils;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* 延时验证工具类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class DelayCheckUtil implements Handler.Callback {
|
||||
|
||||
private final Handler handler = new Handler(this);
|
||||
|
||||
private static final int MSG_CHECK_NET_CONNECT_STATUS = 1001;
|
||||
private static final long CHECK_NET_CONNECT_STATUS_DELAY = 5000L;
|
||||
|
||||
private static final int MSG_START_DELAY_CHECK = 1002;
|
||||
private static final long DELAY_CHECK_DELAY = 10 * 60 * 1000;
|
||||
|
||||
private Context context;
|
||||
|
||||
public DelayCheckUtil(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每5s检查一下网络状态,网络状态为连接状态时,开始空接口请求以及后续的参数上报
|
||||
*/
|
||||
public void waitingForCheck() {
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
|
||||
private long requestTime, netDelay;
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_CHECK_NET_CONNECT_STATUS:
|
||||
if (NetworkUtils.isConnected(context)) {
|
||||
handler.sendEmptyMessage(MSG_START_DELAY_CHECK);
|
||||
} else {
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
return true;
|
||||
case MSG_START_DELAY_CHECK:
|
||||
// 请求空接口
|
||||
startEmptyRequest();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void startEmptyRequest() {
|
||||
requestTime = SystemClock.elapsedRealtime();
|
||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||
.create(DelayCheckApiServices.class, DztHttpConstant.getBaseUrl())
|
||||
.emptyInterface().subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
netDelay = SystemClock.elapsedRealtime() - requestTime;
|
||||
|
||||
startUpload();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startUpload(){
|
||||
Map<String, String> params = new HashMap<>();
|
||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||
.create(DelayCheckApiServices.class, DztHttpConstant.getBaseUrl())
|
||||
.uploadDelayCheckData(params).observeOn(Schedulers.io()).subscribeOn(Schedulers.io())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
|
||||
handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, DELAY_CHECK_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,5 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/groupDebugPanel"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
app:constraint_referenced_ids="btnCloseLog,btnOpenLog,btnOpenV2xPanel,tvObuSetTitle,tvLogSetTitle,tvV2xSetTitle,rgObuSet,ibDebugPanelClose,debugPanelBg" />
|
||||
</merge>
|
||||
@@ -214,8 +214,8 @@
|
||||
<!-- 仅在vr模式下有此内容,仅增加了xhdpi对应的大小 -->
|
||||
<dimen name="module_ext_navi_in_vr_width">464px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_height">304px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_margin_start">20px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_margin_top">8px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_margin_start">40px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_margin_top">28px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_navi_icon_size">100px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_next_info_txt_size">60px</dimen>
|
||||
<dimen name="module_ext_navi_in_vr_next_info_unit_size">48px</dimen>
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.skin.support.SkinMode;
|
||||
import com.mogo.utils.NetworkUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.adasconfig.api.AdasConfigApiController;
|
||||
@@ -140,6 +141,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
super.onCreate( savedInstanceState );
|
||||
ContextHolderUtil.holdContext(this);
|
||||
mPresenter.postLoadModuleMsg();
|
||||
|
||||
NetworkUtils.listenNetStrength(this);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
Reference in New Issue
Block a user