Commit e71fb8ad authored by Igor Oliveira's avatar Igor Oliveira Committed by Georg Koppen
Browse files

Bug 26528 - Don't allow Fennec to use UpdateService when installed through the app store

App stores such as Google Play or F-Droid have their own update service.

The Fennec UpdateService should be used just when the user installs it
by themselves.
parent e6d88f37
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -663,7 +663,7 @@ public class GeckoPreferences

                pref.setOnPreferenceChangeListener(this);
                if (PREFS_UPDATER_AUTODOWNLOAD.equals(key)) {
                    if (!AppConstants.MOZ_UPDATER || ContextUtils.isInstalledFromGooglePlay(this)) {
                    if (!AppConstants.MOZ_UPDATER || ContextUtils.isInstalledFromAppStore(this)) {
                        preferences.removePreference(pref);
                        i--;
                        continue;
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class UpdateServiceHelper {
    }

    public static boolean isUpdaterEnabled(final Context context) {
        return AppConstants.MOZ_UPDATER && isEnabled && !ContextUtils.isInstalledFromGooglePlay(context);
        return AppConstants.MOZ_UPDATER && isEnabled && !ContextUtils.isInstalledFromAppStore(context);
    }

    public static void setUpdateUrl(Context context, String url) {
+3 −2
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ import android.text.TextUtils;

public class ContextUtils {
    private static final String INSTALLER_GOOGLE_PLAY = "com.android.vending";
    private static final String INSTALLER_FDROID = "org.fdroid.fdroid";

    private ContextUtils() {}

@@ -37,13 +38,13 @@ public class ContextUtils {
        }
    }

    public static boolean isInstalledFromGooglePlay(final Context context) {
    public static boolean isInstalledFromAppStore(final Context context) {
        final String installerPackageName = context.getPackageManager().getInstallerPackageName(context.getPackageName());

        if (TextUtils.isEmpty(installerPackageName)) {
            return false;
        }

        return INSTALLER_GOOGLE_PLAY.equals(installerPackageName);
        return INSTALLER_GOOGLE_PLAY.equals(installerPackageName) || INSTALLER_FDROID.equals(installerPackageName);
    }
}