From 0ee9dbcea74ef5ef39f4c5d64eae028999fc2e24 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 3 May 2020 12:05:18 +0200 Subject: [PATCH] fixed crash when attempting to start connection for install referer --- .../utils/InstallReferrerUtils.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/conversationsPlaystore/java/eu/siacs/conversations/utils/InstallReferrerUtils.java b/src/conversationsPlaystore/java/eu/siacs/conversations/utils/InstallReferrerUtils.java index 977ee2a17..aac9b9f4a 100644 --- a/src/conversationsPlaystore/java/eu/siacs/conversations/utils/InstallReferrerUtils.java +++ b/src/conversationsPlaystore/java/eu/siacs/conversations/utils/InstallReferrerUtils.java @@ -31,7 +31,11 @@ public class InstallReferrerUtils implements InstallReferrerStateListener { return; } this.installReferrerClient = InstallReferrerClient.newBuilder(welcomeActivity).build(); - this.installReferrerClient.startConnection(this); + try { + this.installReferrerClient.startConnection(this); + } catch (SecurityException e) { + Log.e(Config.LOGTAG, "unable to start connection to InstallReferrerClient", e); + } } public static void markInstallReferrerExecuted(final Activity context) { @@ -41,18 +45,16 @@ public class InstallReferrerUtils implements InstallReferrerStateListener { @Override public void onInstallReferrerSetupFinished(int responseCode) { - switch (responseCode) { - case InstallReferrerClient.InstallReferrerResponse.OK: - try { - final ReferrerDetails referrerDetails = installReferrerClient.getInstallReferrer(); - final String referrer = referrerDetails.getInstallReferrer(); - welcomeActivity.onInstallReferrerDiscovered(referrer); - } catch (RemoteException e) { - Log.d(Config.LOGTAG, "unable to get install referrer", e); - } - break; - default: - Log.d(Config.LOGTAG, "unable to setup install referrer client. code=" + responseCode); + if (responseCode == InstallReferrerClient.InstallReferrerResponse.OK) { + try { + final ReferrerDetails referrerDetails = installReferrerClient.getInstallReferrer(); + final String referrer = referrerDetails.getInstallReferrer(); + welcomeActivity.onInstallReferrerDiscovered(referrer); + } catch (final RemoteException e) { + Log.d(Config.LOGTAG, "unable to get install referrer", e); + } + } else { + Log.d(Config.LOGTAG, "unable to setup install referrer client. code=" + responseCode); } }