summaryrefslogtreecommitdiffstats
path: root/src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java
diff options
context:
space:
mode:
authorJens Trillmann <jens.trillmann@governikus.de>2023-07-05 09:33:03 +0200
committerJens Trillmann <jens.trillmann@governikus.de>2023-07-31 09:38:56 +0200
commit7012bea614fb47a07a4626c2e2e2855dba3742b4 (patch)
tree27be24d555d179e6f71315c86440d33c50dd1c59 /src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java
parentb902b152af0bf144c9c9833502e1dcfae0166620 (diff)
Improve Intent source app detection
Activity.getReferrer does not only return app IDs but also URLs if Intent.EXTRA_REFERRER is set on the Intent. In the case of Chrome the referrer is set to the website triggering the Intent. To improve the detection of the calling app we check first if the browser specific Browser.EXTRAS_APPLICATION_ID is set. If it is not set we fall back to Intent.getReferrer. Pick-to: 6.6 6.5 Change-Id: I33d1edd52de98486d9616713e531ea20ada87bcb Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java')
-rw-r--r--src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java
index 94d3c2dee1..f85218c154 100644
--- a/src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java
+++ b/src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java
@@ -16,6 +16,7 @@ import android.graphics.Canvas;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.provider.Browser;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.ActionMode.Callback;
@@ -242,10 +243,18 @@ public class QtActivity extends Activity
if (intent.getExtras() != null && intent.getExtras().getString(EXTRA_SOURCE_INFO) != null)
return;
+ String browserApplicationId = "";
+ if (intent.getExtras() != null)
+ browserApplicationId = intent.getExtras().getString(Browser.EXTRA_APPLICATION_ID);
+
String sourceInformation = "";
- Uri referrer = getReferrer();
- if (referrer != null)
- sourceInformation = referrer.toString().replaceFirst("android-app://", "");
+ if (browserApplicationId != null && !browserApplicationId.isEmpty()) {
+ sourceInformation = browserApplicationId;
+ } else {
+ Uri referrer = getReferrer();
+ if (referrer != null)
+ sourceInformation = referrer.toString().replaceFirst("android-app://", "");
+ }
intent.putExtra(EXTRA_SOURCE_INFO, sourceInformation);
}