From e15df13f4c8766c073feddb87094913597c53b14 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Mon, 29 Jan 2018 20:52:04 +0100 Subject: bypass check for unknown source settings for OERO --- .../java/de/pixart/messenger/ui/ConversationActivity.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index b53c56390..b7018b58c 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -1708,8 +1708,15 @@ public class ConversationActivity extends XmppActivity boolean installFromUnknownSource = false; int isUnknownAllowed = 0; if (Build.VERSION.SDK_INT >= 26) { - installFromUnknownSource = packageManager.canRequestPackageInstalls(); - } else if (Build.VERSION.SDK_INT >= 17) { + /* + * On Android 8 with applications targeting lower versions, + * it's impossible to check unknown sources enabled: using old APIs will always return true + * and using the new one will always return false, + * so in order to avoid a stuck dialog that can't be bypassed we will assume true. + */ + installFromUnknownSource = this.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.O + || packageManager.canRequestPackageInstalls(); + } else if (Build.VERSION.SDK_INT >= 17 && Build.VERSION.SDK_INT < 26) { try { isUnknownAllowed = Settings.Global.getInt(this.getApplicationContext().getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS); } catch (Settings.SettingNotFoundException e) { @@ -1726,7 +1733,7 @@ public class ConversationActivity extends XmppActivity } installFromUnknownSource = isUnknownAllowed == 1; } - Log.d(Config.LOGTAG, "Install from unknown sources for Android SDK " + Build.VERSION.SDK_INT + " allowd: " + installFromUnknownSource); + Log.d(Config.LOGTAG, "Install from unknown sources for Android SDK " + Build.VERSION.SDK_INT + " allowed: " + installFromUnknownSource); if (!installFromUnknownSource) { AlertDialog.Builder builder = new AlertDialog.Builder(this); -- cgit v1.2.3