fixed phone notificaiton issues.
authorTrillGates <williamtrillgates@gmail.com>
Sat, 28 Aug 2021 13:09:59 +0000 (21:09 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Sat, 28 Aug 2021 13:09:59 +0000 (21:09 +0800)
app/release/ICSer_V930_2108281942_release.apk [moved from app/release/ICSer_V929_2108281114_release.apk with 77% similarity]
app/release/output.json
app/src/main/java/com/enqualcomm/support/service/PhoneCallListener.java
app/version_code.properties

similarity index 77%
rename from app/release/ICSer_V929_2108281114_release.apk
rename to app/release/ICSer_V930_2108281942_release.apk
index e5b9573..26ce634 100644 (file)
Binary files a/app/release/ICSer_V929_2108281114_release.apk and b/app/release/ICSer_V930_2108281942_release.apk differ
index 6f7ce45..0772142 100644 (file)
@@ -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
index 73d17f6..3af9d65 100644 (file)
@@ -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();
index 14f1168..7e7767b 100644 (file)
@@ -1,2 +1,2 @@
-#Sat Aug 28 11:14:47 CST 2021\r
-VERSION_CODE=929\r
+#Sat Aug 28 19:42:06 CST 2021\r
+VERSION_CODE=930\r