From ffcb8eed6375788faa28aaa4ca770c246065f606 Mon Sep 17 00:00:00 2001 From: skyforce Date: Wed, 25 Aug 2021 14:23:28 +0800 Subject: [PATCH] add gmaps go support --- .../garminhud/app/NotificationMonitor.java | 23 +++++++++++++------ GoogleMaps_HUD/gmaps_hud/version.properties | 4 ++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/NotificationMonitor.java b/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/NotificationMonitor.java index 0abbaac..82178d8 100644 --- a/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/NotificationMonitor.java +++ b/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/NotificationMonitor.java @@ -225,11 +225,15 @@ private void processNotification(StatusBarNotification sbn) { String packageName = sbn.getPackageName(); switch (packageName) { case GOOGLE_MAPS_PACKAGE_NAME: + mNotifySource = 0; parseGmapsNotification(notification); break; case GOOGLE_MAPS_GO_PACKAGE_NAME: - parseGmapsGoNotificationByReflection(notification); +// parseGmapsGoNotificationByReflection(notification); + mNotifySource = 1; + mParseMethod = 0; + boolean parseResult = parseGmapsNotificationByExtras(notification); break; /*case OSMAND_PACKAGE_NAME: parseOsmandNotification(notification); @@ -312,7 +316,10 @@ private void parseOsmandNotification(Notification notification) { parseOsmandNotificationByExtras(notification); } + private int mParseMethod = -1; + private int mNotifySource = -1; + private void parseGmapsNotification(Notification notification) { long currentTime = System.currentTimeMillis(); mNotifyPeriodTime = currentTime - mLastNotifyTimeMillis; @@ -337,7 +344,7 @@ private void parseGmapsNotification(Notification notification) { mPostman.addBooleanExtra(getString(R.string.is_in_navigation), false); mPostman.sendIntent2MainActivity(); - String notifyMessage = "Notify parsing failed. " +(noViewsSituation?"(non-SDK interface restrictions)":""); + String notifyMessage = "Notify parsing failed. " + (noViewsSituation ? "(non-SDK interface restrictions)" : ""); mPostman.addStringExtra(getString(R.string.notify_msg), notifyMessage); } else { mPostman.addBooleanExtra(getString(R.string.notify_parse_failed), false); @@ -592,7 +599,7 @@ else if (methodName.equals("setText")) { parcel.recycle(); indexOfActions++; } - if(validActionCount != 0) { + if (validActionCount != 0) { logParseMessage(); } //can update to garmin hud @@ -683,7 +690,7 @@ private boolean parseGmapsNotificationByJavaReflection(Notification notification textOnGmapsNotifyByJavaReflection = t; break; case 6: - textOnGmapsNotifyByJavaReflection += " "+t; + textOnGmapsNotifyByJavaReflection += " " + t; break; case 9: //time, distance, arrived time @@ -748,10 +755,10 @@ private boolean parseGmapsNotificationByJavaReflection(Notification notification } } - if(validActionCount != 0) { + if (validActionCount != 0) { logParseMessage(); mIsNavigating = true; - }else { + } else { mIsNavigating = false; } //can update to garmin hud @@ -769,13 +776,15 @@ private boolean parseGmapsNotificationByJavaReflection(Notification notification private void logParseMessage() { String arrowString = mArrowTypeV2 ? mFoundArrowV2.toString() : mFoundArrow.toString(); + String notifySourceString = mNotifySource == 0 ? "gmaps" : mNotifySource == 1 ? "gmaps go" : "unknow"; String notifyMessage = arrowString + "(" + (mArrowTypeV2 ? "v2:" : "v1:") + sArrowMinSad + ") " + mDistanceNum + "/" + mDistanceUnit + " " + (null == mRemainingHours ? 0 : mRemainingHours) + ":" + mRemainingMinutes + " " + mRemainingDistance + mRemainingDistanceUnits + " " + mArrivalHours + ":" + mArrivalMinutes + " busy: " + (mBusyTraffic ? "1" : "0") + - " parseMethod: ("+ mParseMethod + ")" + + " parseMethod: (" + mParseMethod + ")" + + " source: (" + notifySourceString + ")" + " (period: " + mNotifyPeriodTime + ")"; logi(notifyMessage); diff --git a/GoogleMaps_HUD/gmaps_hud/version.properties b/GoogleMaps_HUD/gmaps_hud/version.properties index 697ba50..098f0d4 100644 --- a/GoogleMaps_HUD/gmaps_hud/version.properties +++ b/GoogleMaps_HUD/gmaps_hud/version.properties @@ -1,3 +1,3 @@ -#Tue Aug 24 17:46:57 CST 2021 +#Wed Aug 25 14:22:13 CST 2021 VERSION_NAME=0.8.8 -VERSION_CODE=2316 +VERSION_CODE=2326