Commit 88684efc by sikang

添加SIM卡信息

parent af29cc8b
...@@ -30,6 +30,8 @@ import tech.starwin.base.BasePresenter; ...@@ -30,6 +30,8 @@ import tech.starwin.base.BasePresenter;
import tech.starwin.mvp.IView; import tech.starwin.mvp.IView;
import tech.starwin.mvp.presenter.UserPresenter;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.context_utils.AppLanguageUtils; import tech.starwin.utils.context_utils.AppLanguageUtils;
import tech.starwin.utils.PresenterHoler; import tech.starwin.utils.PresenterHoler;
import tech.starwin.utils.context_utils.FragmentLauncher; import tech.starwin.utils.context_utils.FragmentLauncher;
...@@ -92,6 +94,13 @@ public abstract class BaseActivity extends AppCompatActivity implements IView { ...@@ -92,6 +94,13 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
presenterHelper = new PresenterHoler(this); presenterHelper = new PresenterHoler(this);
initRootLayout(); initRootLayout();
/**
* display接口更新,需要在首页访问接口,为避免改动APP代码,这里在lib_base中添加功能
* */
if ("HomeActivity".equals(TAG)) {
getPresenter(UserPresenter.class).getCustomerMsg("");
}
} }
@Override @Override
...@@ -273,7 +282,7 @@ public abstract class BaseActivity extends AppCompatActivity implements IView { ...@@ -273,7 +282,7 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
// } // }
// }); // });
//bug fix:每个客户单独定制初始化动作 //bug fix:每个客户单独定制初始化动作
QMUIHelper.getTopbarCustomizer2().initTopBar(topBar,this); QMUIHelper.getTopbarCustomizer2().initTopBar(topBar, this);
} }
public void setTopBarTitle(String title) { public void setTopBarTitle(String title) {
......
...@@ -19,6 +19,7 @@ import com.common.bean.LatestLoanAppBean; ...@@ -19,6 +19,7 @@ import com.common.bean.LatestLoanAppBean;
import com.common.bean.ProductBean; import com.common.bean.ProductBean;
import tech.starwin.utils.LoginManager; import tech.starwin.utils.LoginManager;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.TrackEventHelper; import tech.starwin.utils.TrackEventHelper;
/** /**
......
...@@ -83,7 +83,6 @@ public class UserPresenter extends BasePresenter<UserApi> { ...@@ -83,7 +83,6 @@ public class UserPresenter extends BasePresenter<UserApi> {
public void accept(GatewayInfoBean gatewayInfoBean) throws Exception { public void accept(GatewayInfoBean gatewayInfoBean) throws Exception {
Gateway.setGatewayInfoBean(gatewayInfoBean); Gateway.setGatewayInfoBean(gatewayInfoBean);
EventBus.getDefault().post(ActionEnum.GATEWAY_UPDATED); EventBus.getDefault().post(ActionEnum.GATEWAY_UPDATED);
getCustomerMsg("action_getCustomerMsg");
} }
}); });
} }
......
...@@ -17,6 +17,7 @@ import okhttp3.Response; ...@@ -17,6 +17,7 @@ import okhttp3.Response;
import okhttp3.internal.Util; import okhttp3.internal.Util;
import tech.starwin.LibConfig; import tech.starwin.LibConfig;
import tech.starwin.utils.LoginManager; import tech.starwin.utils.LoginManager;
import tech.starwin.utils.context_utils.AppInfoUtils;
/** /**
* Created by XLEO on 2018/1/30. * Created by XLEO on 2018/1/30.
...@@ -24,6 +25,8 @@ import tech.starwin.utils.LoginManager; ...@@ -24,6 +25,8 @@ import tech.starwin.utils.LoginManager;
class DefaultHeaderAddInterceptor implements Interceptor { class DefaultHeaderAddInterceptor implements Interceptor {
public static String GA_ID = ""; public static String GA_ID = "";
public static String SIM_INFO = "";
public static String ROOT_STATUS = "";
@Override @Override
public Response intercept(Chain chain) throws IOException { public Response intercept(Chain chain) throws IOException {
...@@ -72,12 +75,31 @@ class DefaultHeaderAddInterceptor implements Interceptor { ...@@ -72,12 +75,31 @@ class DefaultHeaderAddInterceptor implements Interceptor {
.header("X-APP-VERSION-NAME", String.valueOf(LibConfig.VERSION_NAME)) .header("X-APP-VERSION-NAME", String.valueOf(LibConfig.VERSION_NAME))
.header("X-APP-PACKAGE-NAME", LibConfig.APPLICATION_ID) .header("X-APP-PACKAGE-NAME", LibConfig.APPLICATION_ID)
.header("X-APP-NAME", LibConfig.APP_NAME) .header("X-APP-NAME", LibConfig.APP_NAME)
.header("X-APP-ROOTED", getRootStatus())
.header("X-APP-SIM-MOBILE", getSimInfo())
.header("X-AF-ID", LibConfig.APPSFLYER_DEV_KEY == null ? "" : LibConfig.APPSFLYER_DEV_KEY) .header("X-AF-ID", LibConfig.APPSFLYER_DEV_KEY == null ? "" : LibConfig.APPSFLYER_DEV_KEY)
.header("X-GA-ID", getGAId()); .header("X-GA-ID", getGAId());
return chain.proceed(requestBuilder.build()); return chain.proceed(requestBuilder.build());
} }
public String getRootStatus() {
if (TextUtils.isEmpty(ROOT_STATUS)) {
ROOT_STATUS = String.valueOf(AppInfoUtils.isRoot());
}
return ROOT_STATUS;
}
public String getSimInfo() {
if (TextUtils.isEmpty(SIM_INFO)) {
String sim_info = AppInfoUtils.getSimSerialNumber(LibConfig.getContext()) + "," + AppInfoUtils.getPhoneNumber(LibConfig.getContext());
if (sim_info.length() > 1) {
SIM_INFO = sim_info;
}
}
return SIM_INFO;
}
private String getGAId() { private String getGAId() {
if (!TextUtils.isEmpty(GA_ID)) { if (!TextUtils.isEmpty(GA_ID)) {
return GA_ID; return GA_ID;
......
...@@ -10,8 +10,10 @@ import android.support.v4.app.ActivityCompat; ...@@ -10,8 +10,10 @@ import android.support.v4.app.ActivityCompat;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.TextUtils; import android.text.TextUtils;
import java.io.File;
import java.util.UUID; import java.util.UUID;
import tech.starwin.utils.LogUtils;
import tech.starwin.utils.PreferencesManager; import tech.starwin.utils.PreferencesManager;
/** /**
...@@ -72,14 +74,55 @@ public class AppInfoUtils { ...@@ -72,14 +74,55 @@ public class AppInfoUtils {
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
public static String getPhoneNumber(Context context) { public static String getPhoneNumber(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try {
String[] permissions = new String[]{Manifest.permission.READ_SMS, Manifest.permission.READ_PHONE_STATE}; TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null && PermissionsHelper.isGranted(context, permissions)) { if (telephonyManager != null && PermissionsHelper.isGranted(context, Manifest.permission.READ_PHONE_STATE)) {
return telephonyManager.getLine1Number(); return telephonyManager.getLine1Number();
} else { }
} catch (Exception e) {
return "";
}
return "";
}
@SuppressLint("MissingPermission")
public static String getIMSI(Context context) {
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null && PermissionsHelper.isGranted(context, Manifest.permission.READ_PHONE_STATE)) {
String imsi = telephonyManager.getSubscriberId();
LogUtils.d("IMSI_INFO",imsi);
return imsi;
}
} catch (Exception e) {
return ""; return "";
} }
return "";
}
@SuppressLint("MissingPermission")
public static String getSimSerialNumber(Context context) {
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null && PermissionsHelper.isGranted(context, Manifest.permission.READ_PHONE_STATE)) {
return telephonyManager.getSimSerialNumber();
}
} catch (Exception e) {
return "";
}
return "";
}
/**
* 判断是否已ROOT
*/
public static boolean isRoot() {
try {
return new File("/system/bin/su").exists() || new File("/system/xbin/su").exists();
} catch (Exception e) {
return false;
}
} }
......
...@@ -345,7 +345,7 @@ public class PermissionsHelper { ...@@ -345,7 +345,7 @@ public class PermissionsHelper {
/** /**
* 权限是否全部获取 * 权限是否全部获取
*/ */
public static boolean isGranted(Context ctx, String[] permissions) { public static boolean isGranted(Context ctx, String... permissions) {
if (permissions == null || permissions.length == 0) { if (permissions == null || permissions.length == 0) {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment