From 0bce5cebe67b0a15cb2c293c65a14bf99da6bd2f Mon Sep 17 00:00:00 2001
From: Chirayu Desai <chirayudesai1@gmail.com>
Date: Wed, 29 Mar 2017 15:11:28 +0530
Subject: [PATCH] InstallerFactory: Check for privext before checking if apk to
 be installed is privext

* Move the privileged extension installed check above
  the check whether the apk to be installed is privext.
* This lets privext updates work when it is already installed.
---
 .../org/fdroid/fdroid/installer/InstallerFactory.java     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/src/main/java/org/fdroid/fdroid/installer/InstallerFactory.java b/app/src/main/java/org/fdroid/fdroid/installer/InstallerFactory.java
index fffb47fab..885d03870 100644
--- a/app/src/main/java/org/fdroid/fdroid/installer/InstallerFactory.java
+++ b/app/src/main/java/org/fdroid/fdroid/installer/InstallerFactory.java
@@ -45,12 +45,12 @@ public class InstallerFactory {
         }
 
         Installer installer;
-        if (apk.packageName.equals(PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME)) {
-            // special case for installing "Privileged Extension" with root
-            installer = new ExtensionInstaller(context, apk);
-        } else if (PrivilegedInstaller.isDefault(context)) {
+        if (PrivilegedInstaller.isDefault(context)) {
             Utils.debugLog(TAG, "privileged extension correctly installed -> PrivilegedInstaller");
             installer = new PrivilegedInstaller(context, apk);
+        } else if (apk.packageName.equals(PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME)) {
+            // special case for installing "Privileged Extension" with root
+            installer = new ExtensionInstaller(context, apk);
         } else {
             installer = new DefaultInstaller(context, apk);
         }