From 685b2cfe0bfe26c6bc29925f9fdabac055731ed9 Mon Sep 17 00:00:00 2001 From: TrillGates Date: Thu, 21 Oct 2021 19:56:11 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=94=B5=E8=AF=9D?= =?utf8?q?=E7=8A=B6=E6=80=81=E7=9B=91=E5=90=AC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .idea/vcs.xml | 6 + app/EQC_G5.jks | Bin 0 -> 4688 bytes app/build.gradle | 81 ++++++++++ app/proguard-rules.pro | 40 ++++- app/src/main/AndroidManifest.xml | 8 + .../internal/telephony/ITelephony.aidl | 5 + .../main/java/com/ic/sos/SOSPresenter.java | 143 +++++++++++++++++- app/version_code.properties | 2 + 8 files changed, 279 insertions(+), 6 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 app/EQC_G5.jks create mode 100644 app/src/main/aidl/com/android/internal/telephony/ITelephony.aidl create mode 100644 app/version_code.properties diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/EQC_G5.jks b/app/EQC_G5.jks new file mode 100644 index 0000000000000000000000000000000000000000..2229d46ba5935ac0f52c19d953a9cdcb2069dcae GIT binary patch literal 4688 zcmd6pWmr^gx5uZbAq0j{l$Nd;7+T^X2ara(LrOXXshI&u2~iMf96%+Mj-f*Y9*~fb zEu7o0P#Z`Uppr& zM^OL(Xx?2M*9QO)0N_~28JvO;%0~!<0C_=FKp+7Cf`zP3?REG))>6cW(u==fLn$@( zd*YB_?waBPEW14})w@h6xBq#0a8=rzha-}MxmAFcVg;Tsa3Vx} zF)g;0 zA#jtZyRxO<`dl9csr7oEUa~F)UWa;z&6{6Wlr!2lW#b^3!d0zY;GvMUte$Xt-T-m0 zd8I(UM3-qI>pe-DQS*6Fpn56A#}Atk8g;c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;oXDsr+SVg zyEutl!w24te@rM>2}d7U4L7Ed76d9=Ez8{hlv7h(=0!kpbA2mmCC??zpW|XiftyP` zZKRCS%{#0mA1@-dHN1Qj|E>`FQL+)gk9~a8MQVdvzZcl%Iuvh%R~;$R_ymkfM^Xo- z^Hs&P_06piXR+{jF=lq~InYZ}x7E@=U~GL*+NM)tV~?NPi*_Gwp(O=*9+2JA7jENQ z9&6y%TiA2F%fD)98|5=`I?G-{F`^s)Dx)V+IGTz__DeNp*{Pl%H^y9ko9AU@U%Taa yc!wQL@>GyEE+vd+EajtTtTK9ZV#?b)@M+zHd + variant.outputs.all { + if (variant.buildType.name == "release") { + outputFileName = "${getApkBaseName()}_V${currentVersionCode}_${currentVersionName}_release.apk" + } else { + outputFileName = "${getApkBaseName()}_V${currentVersionCode}_${currentVersionName}_debug.apk" + } + } + } + } + } +} + +def getVersionCode() { + def versionCodeFile = file('version_code.properties') + if (versionCodeFile.canRead()) { + Properties properties = new Properties() + properties.load(new FileInputStream(versionCodeFile)) + def versionCode = properties['VERSION_CODE'].toInteger() +//读取version_code.properties文件存放的版本号。 + def runTasks = gradle.startParameter.taskNames + def task = ':app:assembleRelease' + if (task in runTasks) { + properties['VERSION_CODE'] = (++versionCode).toString() + properties.store(versionCodeFile.newWriter(), null) + } + return versionCode + } else { + throw new GradleException("无法读取version_code.properties文件!") + } } +def releaseTime() { + + return new Date().format("yyMMddHHmm", TimeZone.getTimeZone("GMT+08:00")) + +} + + dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..ee7a614 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -18,4 +18,42 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + + +-keep class com.ic.iclooger.CrashHandler +-keep class com.ic.iclooger.ICLogger + +-keepclassmembers class com.ic.iclooger.StorageUtils { + public static ; + public static ; + public ; +} + +-keepclassmembers class com.ic.iclooger.SystemUtils { + public static ; + public static ; + public ; +} + +-keep class com.facebook.** { *; } +-keep class com.mediatek.** { *; } +-keep class org.apache.** { *; } +-keep class okio.Okio.** { *; } +-keep class java.nio.** { *; } +-keep class com.android.** { *; } +-keep class android.** { *; } +-keep class android.ddm.** { *; } +-keep class com.alibaba.fastjson.** { *; } +-keep class com.eqc.watch.launcher.WatchApplication { *; } +#-keep class com.enqualcomm.support.EqcAlgorithmNative { *; } + +-dontwarn com.facebook.** +-dontwarn com.mediatek.** +-dontwarn java.nio.** +-dontwarn com.alibaba.fastjson.** +-dontwarn android.** +-dontwarn com.android.** +-dontwarn rx.internal.** + +-keep class com.ic.** { *; } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8f8ff8f..98d6a3b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,15 @@ + + + + + + + " + loopTime + " callWay ==> " + callWay + " callDuration ==> " + callDuration); - executorService.execute(this::sosTask); + handler.post(this::sosTask); } + + //是否有接听 + private boolean isActive = false; + + //通话结束 + public static final int STATE_END = 9; + //正在挂断 + public static final int STATE_HAND_UP_ING = 8; + //正在拨号 + public static final int STATE_CALLING = 5; + //正在通话 + public static final int STATE_TALKING = 2; + //来电 + public static final int STATE_INCOME = 3; + + + private class PhoneStateReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + int state = intent.getIntExtra("state", -1); + String callStateLabel = intent.getStringExtra("callStateLabel"); + ICLogger.d("callStateLabel ==> " + callStateLabel); + ICLogger.d("state ==> " + state); + //判断case + switch (state) { + case STATE_END: + ICLogger.d("通话结束"); + break; + case STATE_HAND_UP_ING: + ICLogger.d("正在挂断"); + break; + case STATE_TALKING: + ICLogger.d("正在通话中..."); + break; + case STATE_CALLING: + ICLogger.d("正在呼叫"); + break; + case STATE_INCOME: + ICLogger.d("来电..."); + break; + } + } + } + + + /** + * 根据条件进行下一轮拨号 + */ + private void checkNextCall() { + + } + + /** * 以下内容都在子线程执行了,注意安全 */ @@ -72,7 +149,6 @@ public class SOSPresenter { public boolean isHasSimCard() { - TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); int simState = telephonyManager.getSimState(); boolean result = true; switch (simState) { @@ -105,11 +181,68 @@ public class SOSPresenter { } } + + //这个拨号到哪里的下标,从第1个开始 + private int currentCallIndex = 0; + + private int currentLoopGroupTime = 0; + /** * 根据策略去拨号 */ private void doSosCall() { + //策略因素有: + //轮询组的次数(判断在此次通话结束以后) + //拨号策略(判断在此次通话结束以后,不管是挂断还是超时) + //拨号超时时长(完成) + //先监听电话的状态,这个在类创建的时候就已经监听的了 + if (phoneNumList.size() > currentCallIndex) { + String targetPhoneNum = phoneNumList.get(currentCallIndex); + callPhone(targetPhoneNum); + //开始准备超时 + if (callDuration != -1) { + //需要按时挂断 + handler.removeCallbacks(endCallTask); + handler.postDelayed(endCallTask, callDuration * 1000); + } + } + if (currentCallIndex == phoneNumList.size() - 1) { + //拨号当前组最后一个号码了 + currentLoopGroupTime++; + } + } + //挂断电话,在挂断电话回调的地方,判断有没有必要进行下一次轮询 + private final Runnable endCallTask = this::endCall; + + private void endCall() { + try { + Method method = Class.forName("android.os.ServiceManager") + .getMethod("getService", String.class); + IBinder binder = (IBinder) method.invoke(null, new Object[]{Context.TELEPHONY_SERVICE}); + ITelephony telephony = ITelephony.Stub.asInterface(binder); + telephony.endCall(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void callPhone(String phone) { + if (telephonyManager.getCallState() != CALL_STATE_IDLE) { + return; + } + if (TextUtils.isEmpty(phone) || phone.length() <= 1) { + return; + } + if (!PhoneNumberUtils.isEmergencyNumber(phone)) { + if (!isHasSimCard()) { + return; + } + } + Uri callUri = Uri.parse("tel://" + phone); + Intent callIntent = new Intent("android.intent.action.CALL_PRIVILEGED", callUri); + callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); + mContext.startActivity(callIntent); } /** @@ -158,7 +291,7 @@ public class SOSPresenter { public void cleared() { - executorService.shutdown(); phoneNumList.clear(); + mContext.unregisterReceiver(stateReceiver); } } diff --git a/app/version_code.properties b/app/version_code.properties new file mode 100644 index 0000000..d8f639d --- /dev/null +++ b/app/version_code.properties @@ -0,0 +1,2 @@ +#Thu Jul 30 17:39:35 CST 2020 +VERSION_CODE=41 -- 2.17.1