opt
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package com.mogo.commons;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -20,7 +18,6 @@ import com.mogo.commons.network.X509TrustManagerImpl;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.NetConfig;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
import com.zhidao.account.sdk.AccountClientManager;
|
||||
@@ -100,7 +97,6 @@ public class AbsMogoApplication extends Application {
|
||||
private void asyncInit() {
|
||||
ThreadPoolService.execute( () -> {
|
||||
initNetConfig();
|
||||
initAccountSdk();
|
||||
// 初始化toast
|
||||
// 初始化埋点
|
||||
Analytics.getInstance().start( sApp );
|
||||
@@ -111,37 +107,42 @@ public class AbsMogoApplication extends Application {
|
||||
AnalyticsConfig.getInstance( sApp ).shouldLog( DebugConfig.isDebug() );
|
||||
Devices.init( getApp() );
|
||||
Devices.checkBindState();
|
||||
asyncInitImpl();
|
||||
} );
|
||||
}
|
||||
|
||||
private static void initAccountSdk() {
|
||||
int mode = DebugConfig.getNetMode();
|
||||
if ( mode == DebugConfig.NET_MODE_DEMO ) {
|
||||
// 演示环境用 qa 的
|
||||
mode = DebugConfig.NET_MODE_QA;
|
||||
}
|
||||
AccountClientManager.init( sApp, mode, NetEnvironManager.OS_2C, "os2.0-launcher" );
|
||||
getTicket( new TicketInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess( String ticket ) {
|
||||
SpStorage.setTicket( ticket );
|
||||
Logger.w( TAG, "request ticket success" );
|
||||
}
|
||||
protected void asyncInitImpl(){
|
||||
|
||||
@Override
|
||||
public void onFailure( int code, String msg ) {
|
||||
Logger.w( TAG, "request ticket error code = %d, msg = %s", code, msg );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void getTicket( TicketInfoCallback callback ) {
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
AccountClientManager.getTicket( callback );
|
||||
} else {
|
||||
AccountClientManager.getAppTicket( callback );
|
||||
}
|
||||
}
|
||||
// private static void initAccountSdk() {
|
||||
// int mode = DebugConfig.getNetMode();
|
||||
// if ( mode == DebugConfig.NET_MODE_DEMO ) {
|
||||
// // 演示环境用 qa 的
|
||||
// mode = DebugConfig.NET_MODE_QA;
|
||||
// }
|
||||
// AccountClientManager.init( sApp, mode, NetEnvironManager.OS_2C, "os2.0-launcher" );
|
||||
// getTicket( new TicketInfoCallback() {
|
||||
// @Override
|
||||
// public void onSuccess( String ticket ) {
|
||||
// SpStorage.setTicket( ticket );
|
||||
// Logger.w( TAG, "request ticket success" );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure( int code, String msg ) {
|
||||
// Logger.w( TAG, "request ticket error code = %d, msg = %s", code, msg );
|
||||
// }
|
||||
// } );
|
||||
// }
|
||||
//
|
||||
// private static void getTicket( TicketInfoCallback callback ) {
|
||||
// if ( DebugConfig.isLauncher() ) {
|
||||
// AccountClientManager.getTicket( callback );
|
||||
// } else {
|
||||
// AccountClientManager.getAppTicket( callback );
|
||||
// }
|
||||
// }
|
||||
|
||||
private static void initNetConfig() {
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.mogo.utils.logger.Logger;
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 各个模块递调试信息控制接口
|
||||
* <p>
|
||||
* 注:该类已经不再是简单的调试配置,已经涉及到功能逻辑了 囧
|
||||
*/
|
||||
public class DebugConfig {
|
||||
|
||||
@@ -53,6 +55,11 @@ public class DebugConfig {
|
||||
|
||||
private static int sNetMode = NET_MODE_RELEASE;
|
||||
|
||||
/**
|
||||
* 不使用语音助手
|
||||
*/
|
||||
public static final int AI_TYPE_NOOP = 0;
|
||||
|
||||
/**
|
||||
* 语音使用同行者
|
||||
*/
|
||||
@@ -64,6 +71,18 @@ public class DebugConfig {
|
||||
|
||||
private static int sAIType = AI_TYPE_TXZ;
|
||||
|
||||
/**
|
||||
* 自研车机
|
||||
*/
|
||||
public static final int CAR_MACHINE_TYPE_SELF_INNOVATE = 0;
|
||||
|
||||
/**
|
||||
* 比亚迪的车机
|
||||
*/
|
||||
public static final int CAR_MACHINE_TYPE_BYD = 1;
|
||||
|
||||
private static int sCarMachineType = CAR_MACHINE_TYPE_SELF_INNOVATE;
|
||||
|
||||
/**
|
||||
* 获取网络环境类型
|
||||
*
|
||||
@@ -115,20 +134,39 @@ public class DebugConfig {
|
||||
|
||||
/**
|
||||
* 设置使用哪个语音助手
|
||||
* @param aiType {@link #AI_TYPE_TXZ} {@link #AI_TYPE_SPEECH}
|
||||
*
|
||||
* @param aiType {@link #AI_TYPE_NOOP} {@link #AI_TYPE_TXZ} {@link #AI_TYPE_SPEECH}
|
||||
*/
|
||||
public static void setAIType(int aiType){
|
||||
Logger.d("DebugConfig", "setAiType: " + aiType);
|
||||
public static void setAIType( int aiType ) {
|
||||
Logger.d( "DebugConfig", "setAiType: " + aiType );
|
||||
sAIType = aiType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用哪个语音助手 {@link #AI_TYPE_TXZ} {@link #AI_TYPE_SPEECH}
|
||||
* 使用哪个语音助手 {@link #AI_TYPE_NOOP} {@link #AI_TYPE_TXZ} {@link #AI_TYPE_SPEECH}
|
||||
*/
|
||||
public static int getAIType(){
|
||||
public static int getAIType() {
|
||||
return sAIType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前车机类型
|
||||
*
|
||||
* @param type {@link #CAR_MACHINE_TYPE_SELF_INNOVATE} {@link #CAR_MACHINE_TYPE_BYD}
|
||||
*/
|
||||
public static void setCarMachineType( int type ) {
|
||||
sCarMachineType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前车机类型
|
||||
*
|
||||
* @return {@link #CAR_MACHINE_TYPE_SELF_INNOVATE} {@link #CAR_MACHINE_TYPE_BYD}
|
||||
*/
|
||||
public static int getCarMachineType() {
|
||||
return sCarMachineType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否作为launcher运行
|
||||
*/
|
||||
@@ -173,4 +211,39 @@ public class DebugConfig {
|
||||
public static void setActiveAIAssistFlag( boolean sActiveAIAssistFlag ) {
|
||||
DebugConfig.sActiveAIAssistFlag = sActiveAIAssistFlag;
|
||||
}
|
||||
|
||||
private static boolean useMockObuData;
|
||||
|
||||
public static void setUseMockObuData( boolean use ) {
|
||||
useMockObuData = use;
|
||||
}
|
||||
|
||||
public static boolean isUseMockObuData() {
|
||||
return useMockObuData;
|
||||
}
|
||||
|
||||
private static String sProductFlavor;
|
||||
|
||||
public static String getProductFlavor() {
|
||||
return sProductFlavor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品线
|
||||
*
|
||||
* @param sProductFlavor
|
||||
*/
|
||||
public static void setProductFlavor( String sProductFlavor ) {
|
||||
DebugConfig.sProductFlavor = sProductFlavor;
|
||||
}
|
||||
|
||||
private static String sSocketAppId;
|
||||
|
||||
public static void setSocketAppId( String sSocketAppId ) {
|
||||
DebugConfig.sSocketAppId = sSocketAppId;
|
||||
}
|
||||
|
||||
public static String getSocketAppId() {
|
||||
return sSocketAppId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,14 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.utils.SoftKeyBoardJobber;
|
||||
|
||||
/**
|
||||
@@ -23,6 +28,10 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD) {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
setContentView( getLayoutId() );
|
||||
initViews();
|
||||
mPresenter = createPresenter();
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.mogo.commons.network;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.network.utils.Util;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
|
||||
@@ -2,11 +2,17 @@ package com.mogo.commons.network;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.telephony.CellLocation;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.cdma.CdmaCellLocation;
|
||||
import android.telephony.gsm.GsmCellLocation;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -55,10 +61,15 @@ public class Utils {
|
||||
|
||||
public static final String GET = "get";
|
||||
public static final String GSM_SERIAL = "gsm.serial";
|
||||
public static final String BYD_SERIAL = "ro.serialno";
|
||||
public static final String FOTA_VERSION = "ro.fota.version";
|
||||
public static final String PROPERTIES = "android.os.SystemProperties";
|
||||
|
||||
public static String getSn() {
|
||||
|
||||
if ( DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE ) {
|
||||
return SharedPrefsMgr.getInstance( AbsMogoApplication.getApp() ).getString( "allocated_sn" );
|
||||
}
|
||||
return getSystemProperties( GSM_SERIAL );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user