From: snickersun Date: Sat, 23 Nov 2019 09:28:22 +0000 (+0800) Subject: 在SIM卡检测环节加入信号强度Dbm显示及Level显示。 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=ed29bc3e1b5ba65a32d312de8a1c51c6ea6110da;p=factoryMode.git 在SIM卡检测环节加入信号强度Dbm显示及Level显示。 --- diff --git a/app/build.gradle b/app/build.gradle index 11a4213..eae8e65 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,13 +13,13 @@ android { checkReleaseBuilds false abortOnError false } - compileSdkVersion 20 + compileSdkVersion 27 defaultConfig { applicationId "mobile.miki" - minSdkVersion 18 - targetSdkVersion 20 - versionCode 2 - versionName "20191120-2030" + minSdkVersion 19 + targetSdkVersion 19 + versionCode 3 + versionName '20191123-1715' } buildTypes { release { @@ -44,14 +44,38 @@ android { jni.srcDirs = [] } } + compileOptions { + sourceCompatibility = 1.7 + targetCompatibility = 1.7 + } } dependencies { implementation 'com.android.support:support-v4:20.0.0' - compileOnly files('libs/watch_framework.jar') + // compileOnly files('libs/framework.jar') + provided files('libs/framework.jar') implementation 'com.squareup.okhttp3:okhttp:3.4.1' implementation 'io.reactivex:rxandroid:1.2.1' implementation 'com.liulishuo.filedownloader:library:1.6.3' compileOnly files('libs/IAtChannel_classes.jar') implementation files('libs/LineWrapContainer.aar') } +preBuild { + + doLast { + def imlFile = file( project.name + ".iml") + println 'Change ' + project.name + '.iml order' + try { + def parsedXml = (new XmlParser()).parse(imlFile) + def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } + parsedXml.component[1].remove(jdkNode) + def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" + println 'what' + sdkString + new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) + groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) + } catch (FileNotFoundException e) { + // nop, iml not found + println "no iml found" + } + } +} \ No newline at end of file diff --git a/app/libs/framework.jar b/app/libs/framework.jar new file mode 100644 index 0000000..82607b8 Binary files /dev/null and b/app/libs/framework.jar differ diff --git a/app/libs/watch_framework.jar b/app/libs/watch_framework.jar deleted file mode 100644 index 71aaa3f..0000000 Binary files a/app/libs/watch_framework.jar and /dev/null differ diff --git a/app/release/FactoryMode.apk b/app/release/FactoryMode.apk index deac242..c977c29 100644 Binary files a/app/release/FactoryMode.apk and b/app/release/FactoryMode.apk differ diff --git a/app/release/output.json b/app/release/output.json index e38fc25..53cf1f5 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":2,"versionName":"20191120-2030","enabled":true,"outputFile":"FactoryMode.apk","fullName":"release","baseName":"release"},"path":"FactoryMode.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":3,"versionName":"20191123-1715","enabled":true,"outputFile":"FactoryMode.apk","fullName":"release","baseName":"release"},"path":"FactoryMode.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/mobile/miki/SimDetectActivity.java b/app/src/main/java/mobile/miki/SimDetectActivity.java index 1352651..5b83cb1 100644 --- a/app/src/main/java/mobile/miki/SimDetectActivity.java +++ b/app/src/main/java/mobile/miki/SimDetectActivity.java @@ -1,21 +1,30 @@ package mobile.miki; +import android.annotation.SuppressLint; import android.app.Service; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.os.SystemProperties; import android.preference.PreferenceManager; +import android.telephony.PhoneStateListener; +import android.telephony.SignalStrength; import android.telephony.TelephonyManager; import android.util.Log; +import android.util.SparseArray; import android.view.Display; import android.view.View; +import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import mobile.miki.mainui.ButtonViewTwo; import mobile.miki.mainui.TestMainActivity; @@ -26,17 +35,25 @@ public class SimDetectActivity extends BaseActivity implements private static String imsiSim0; private static String imsiSim1; private static String aaa; + private TextView signalstrenth; + private TextView operator; private ButtonViewTwo buttonView; boolean running; boolean pcbatest; + private static String TAG="SimDetectActivity"; String result = null; private PingThread pingThread; + //dxc mod + private MyPhoneStateListener myListener; + private static TelephonyManager mTelephonyManager; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyApplication.getInstance().addActivity(this); setContentView(R.layout.sim_detect_layout); + signalstrenth =(TextView)findViewById(R.id.signal_strenth); + operator=(TextView)findViewById(R.id.opertator); imsiSim0 = getResources().getString(R.string.nothing); imsiSim1 = getResources().getString(R.string.nothing); aaa = getResources().getString(R.string.ok); @@ -59,6 +76,11 @@ public class SimDetectActivity extends BaseActivity implements detectSim1(null); // detectSim2(null); detectNetwork(null); + //sim卡信号 + myListener = new MyPhoneStateListener( this, operator,signalstrenth); + mTelephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); + mTelephonyManager.listen(myListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); + } @Override @@ -286,6 +308,138 @@ public class SimDetectActivity extends BaseActivity implements buttonView.btn_left.setClickable(true); } + } + //sim卡信号强度 + public static class MyPhoneStateListener extends PhoneStateListener { +// static final int SIGNAL_STRENGTH_GREAT = 5; +// static final int SIGNAL_STRENGTH_GOOD = 4; +// static final int SIGNAL_STRENGTH_MODERATE = 3; +// static final int SIGNAL_STRENGTH_POOR = 2; +// static final int SIGNAL_STRENGTH_VERYPOOR = 1; +// static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; + + TextView tvOperatorName; + TextView tvSignal; + Context context; + + int mSignalStrengthLevel = 0; + int mSignalStrengthDbm = 0; + + + String getNetworktypeName(int networktype){ + String ntype=""; + switch(networktype){ + case TelephonyManager.NETWORK_TYPE_GPRS: + ntype="GPRS"; + break; + case TelephonyManager.NETWORK_TYPE_EVDO_0: + ntype="EVDO_0"; + break; + case TelephonyManager.NETWORK_TYPE_EVDO_A: + ntype="EVDO_A"; + break; + case TelephonyManager.NETWORK_TYPE_EVDO_B: + ntype="EVDO_B"; + break; + case TelephonyManager.NETWORK_TYPE_EHRPD: + ntype="EHRPD"; + break; + case TelephonyManager.NETWORK_TYPE_UMTS: + ntype="UMTS"; + break; + case TelephonyManager.NETWORK_TYPE_HSDPA: + ntype="HSDPA"; + break; + case TelephonyManager.NETWORK_TYPE_HSUPA: + ntype="HSUPA"; + break; + case TelephonyManager.NETWORK_TYPE_HSPA: + ntype="HSPA"; + break; + case TelephonyManager.NETWORK_TYPE_HSPAP: + ntype="HSPAP"; + break; + case TelephonyManager.NETWORK_TYPE_EDGE: + ntype="EDGE"; + break; + case TelephonyManager.NETWORK_TYPE_CDMA: + ntype="CDMA"; + break; + case TelephonyManager.NETWORK_TYPE_1xRTT: + ntype="1X"; + break; + case TelephonyManager.NETWORK_TYPE_LTE: + ntype="LTE"; + break; + default: + ntype="-"; + break; + } + + return ntype; + } + + + int getSignalStrength(SignalStrength signalStrength ){ + int signal=0; + + + return signal; + } + MyPhoneStateListener(Context context, TextView tvOperatorName,TextView tvsignal) { + + this.tvOperatorName = tvOperatorName; + this.tvSignal = tvsignal; + this.context = context; + + } + + @Override + public void onSignalStrengthsChanged(SignalStrength signalStrength) { + super.onSignalStrengthsChanged(signalStrength); + + int level = signalStrength.getLevel() + 1; + int signDbm = signalStrength.getDbm(); + + setSignalStrengthDbm(signDbm); + setSignalStrengthLevel(level); + updateUI(); + } + + void updateUI() { + if (mTelephonyManager == null) { + mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + } + String operatorName = mTelephonyManager.getSimOperatorName(); // SIM卡运营商的名字 + + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(mTelephonyManager.getSimOperatorName()).append("\n"); + stringBuffer.append(mTelephonyManager.getSimOperator()).append("\n"); + Log.d(TAG,"网络运营商:" + stringBuffer.toString()); + + + + int mNetworkType = mTelephonyManager.getNetworkType(); + // int mSimState = mTelephonyManager.getSimState(); + + // if (mSimState != TelephonyManager.SIM_STATE_READY) { +// mSignalStrengthLevel = 0; + // setSignalStrengthLevel(0); + // } + tvOperatorName.setText(operatorName); + tvSignal.setText(getNetworktypeName(mNetworkType)+" ("+mSignalStrengthDbm+" Dbm) "+mSignalStrengthLevel+" "); + + } + + void setSignalStrengthLevel(int level) { + mSignalStrengthLevel = level; + } + void setSignalStrengthDbm(int strengthDbm) { + mSignalStrengthDbm = strengthDbm; + } + + + } } diff --git a/app/src/main/res/layout/sim_detect_layout.xml b/app/src/main/res/layout/sim_detect_layout.xml index 086944d..1211fff 100644 --- a/app/src/main/res/layout/sim_detect_layout.xml +++ b/app/src/main/res/layout/sim_detect_layout.xml @@ -1,12 +1,12 @@ + @@ -179,7 +180,101 @@ android:textSize="20dp" android:visibility="gone" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 9ce1e5d..44057af 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -363,6 +363,8 @@ 背光 点击开始背光测试 网络 + 信号强度 + 运营商 点击进入网络电话测试 点击进入蓝牙测试 点击进入雷达测试 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 336922c..a9b0944 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -414,6 +414,8 @@ FAIL SUCCESS network + signal + operator Pass Rule: one satellite SNR > 30 Pass Rule: 3 satellites SNR > 30 Pass Rule: GPS Must Fixed diff --git a/build.gradle b/build.gradle index 638c3d9..232f30a 100644 --- a/build.gradle +++ b/build.gradle @@ -14,4 +14,11 @@ allprojects { jcenter() google() } + + gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\framework.jar') + } + } + } diff --git a/factorymode.iml b/factorymode.iml index 0258691..6bbc01d 100644 --- a/factorymode.iml +++ b/factorymode.iml @@ -8,7 +8,7 @@ - + diff --git a/watchlibrary/watchlibrary.iml b/watchlibrary/watchlibrary.iml index d91f97e..36172a0 100644 --- a/watchlibrary/watchlibrary.iml +++ b/watchlibrary/watchlibrary.iml @@ -15,7 +15,7 @@ - +