From: TrillGates Date: Sat, 28 Aug 2021 13:09:59 +0000 (+0800) Subject: fixed phone notificaiton issues. X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=7dfc5ef0b3aa474540198ba2db21bd103fa79e8c;p=icsupport.git fixed phone notificaiton issues. --- diff --git a/app/release/ICSer_V929_2108281114_release.apk b/app/release/ICSer_V930_2108281942_release.apk similarity index 77% rename from app/release/ICSer_V929_2108281114_release.apk rename to app/release/ICSer_V930_2108281942_release.apk index e5b95733..26ce634e 100644 Binary files a/app/release/ICSer_V929_2108281114_release.apk and b/app/release/ICSer_V930_2108281942_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 6f7ce45a..07721423 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":929,"versionName":"2108281114","enabled":true,"outputFile":"ICSer_V929_2108281114_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V929_2108281114_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":930,"versionName":"2108281942","enabled":true,"outputFile":"ICSer_V930_2108281942_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V930_2108281942_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/service/PhoneCallListener.java b/app/src/main/java/com/enqualcomm/support/service/PhoneCallListener.java index 73d17f6b..3af9d657 100644 --- a/app/src/main/java/com/enqualcomm/support/service/PhoneCallListener.java +++ b/app/src/main/java/com/enqualcomm/support/service/PhoneCallListener.java @@ -6,14 +6,11 @@ import android.content.Context; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; -import android.os.SystemClock; import android.util.Log; import com.enqualcomm.support.provider.ICDatabaseHelper; import com.enqualcomm.support.provider.ICNotificationProvider; -import com.enqualcomm.support.utils.ICLogger; -import static android.telephony.TelephonyManager.CALL_STATE_IDLE; import static com.enqualcomm.support.provider.ICGlobalSettingsProvider.SETTINGS; /** @@ -35,31 +32,39 @@ public class PhoneCallListener { true, new ContentObserver(null) { @Override public void onChange(boolean selfChange) { - ICLogger.d("isSelfChange ==> " + isSelfChange); - if (!isSelfChange) { - Log.d(TAG, "on phone calls change."); - queryCallState(); - } else { - isSelfChange = false; - } + Log.d(TAG, "on phone calls change."); + queryCallState(); + } + }); + //观察通知表的变化 + mContext.getContentResolver().registerContentObserver( + Uri.parse(ICNotificationProvider.NOTIFICATIONS), + true, new ContentObserver(null) { + @Override + public void onChange(boolean selfChange) { + handleTopIcon(); } }); } - private final Object mLock = new Object(); - - public void onCallStateChanged(int state, String incomingNumber) { - ICLogger.d("state == > " + state + " incomingNumber ==> " + incomingNumber); - //挂断的时候,去查询一下是不是未接电话即可 - if (state == CALL_STATE_IDLE) { - new Thread(() -> { - synchronized (mLock) { - SystemClock.sleep(1000); - //查询整个通话记录 - queryCallState(); + private void handleTopIcon() { + new Thread(() -> { + //查询电话通知个数 + Cursor query = mContext.getContentResolver() + .query(Uri.parse(ICNotificationProvider.NOTIFICATIONS), + null, "category=? and type=?", + new String[]{"com.ic.phone", "missed_phone"}, null); + if (query != null) { + if (query.moveToNext()) { + updateSettingsState(1); + } else { + updateSettingsState(0); } - }).start(); - } + query.close(); + } else { + updateSettingsState(0); + } + }).start(); } private void queryCallState() { @@ -75,12 +80,6 @@ public class PhoneCallListener { if (c != null) { int count = c.getCount(); Log.d(TAG, "int count ==> " + count); - if (count == 0) { - updateSettingsState(0); - } else { - //修改顶部的状态 - updateSettingsState(1); - } String[] columnNames = c.getColumnNames(); while (c.moveToNext()) { StringBuffer sb = new StringBuffer(); @@ -99,7 +98,6 @@ public class PhoneCallListener { ContentValues updateValues = new ContentValues(); //更新为已读 updateValues.put("is_read", 1); - isSelfChange = true; int update = mContext.getContentResolver().update(Uri.parse("content://call_log/calls"), updateValues, where, @@ -107,8 +105,6 @@ public class PhoneCallListener { Log.d(TAG, "update ==> " + update); } - private boolean isSelfChange = false; - private void updateSettingsState(int value) { ContentResolver resolver = mContext.getContentResolver(); ContentValues values = new ContentValues(); diff --git a/app/version_code.properties b/app/version_code.properties index 14f11680..7e7767b3 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Sat Aug 28 11:14:47 CST 2021 -VERSION_CODE=929 +#Sat Aug 28 19:42:06 CST 2021 +VERSION_CODE=930