mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1220773 - Do not run our updater if app was installed from Google Play. r=ahunt,esawin
MozReview-Commit-ID: Bz4kErHzhen --HG-- extra : rebase_source : 292887fa4de4ba604f6b966ef0296857078bba2b
This commit is contained in:
parent
483b42a995
commit
5ff7384025
@ -748,7 +748,7 @@ public class BrowserApp extends GeckoApp
|
||||
// The update service is enabled for RELEASE_BUILD, which includes the release and beta channels.
|
||||
// However, no updates are served. Therefore, we don't trust the update service directly, and
|
||||
// try to avoid prompting unnecessarily. See Bug 1232798.
|
||||
if (!AppConstants.RELEASE_BUILD && UpdateServiceHelper.isUpdaterEnabled()) {
|
||||
if (!AppConstants.RELEASE_BUILD && UpdateServiceHelper.isUpdaterEnabled(this)) {
|
||||
Permissions.from(this)
|
||||
.withPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
.doNotPrompt()
|
||||
|
@ -39,6 +39,7 @@ import org.mozilla.gecko.tabqueue.TabQueueHelper;
|
||||
import org.mozilla.gecko.tabqueue.TabQueuePrompt;
|
||||
import org.mozilla.gecko.updater.UpdateService;
|
||||
import org.mozilla.gecko.updater.UpdateServiceHelper;
|
||||
import org.mozilla.gecko.util.ContextUtils;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
@ -708,7 +709,7 @@ OnSharedPreferenceChangeListener
|
||||
|
||||
pref.setOnPreferenceChangeListener(this);
|
||||
if (PREFS_UPDATER_AUTODOWNLOAD.equals(key)) {
|
||||
if (!AppConstants.MOZ_UPDATER) {
|
||||
if (!AppConstants.MOZ_UPDATER || ContextUtils.isInstalledFromGooglePlay(this)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
|
@ -8,6 +8,7 @@ package org.mozilla.gecko.updater;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.PrefsHelper;
|
||||
import org.mozilla.gecko.util.ContextUtils;
|
||||
import org.mozilla.gecko.util.GeckoJarReader;
|
||||
|
||||
import android.content.Context;
|
||||
@ -131,8 +132,8 @@ public class UpdateServiceHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUpdaterEnabled() {
|
||||
return AppConstants.MOZ_UPDATER && isEnabled;
|
||||
public static boolean isUpdaterEnabled(final Context context) {
|
||||
return AppConstants.MOZ_UPDATER && isEnabled && !ContextUtils.isInstalledFromGooglePlay(context);
|
||||
}
|
||||
|
||||
public static void setUpdateUrl(Context context, String url) {
|
||||
@ -168,7 +169,7 @@ public class UpdateServiceHelper {
|
||||
}
|
||||
|
||||
public static void registerForUpdates(final Context context) {
|
||||
if (!isUpdaterEnabled()) {
|
||||
if (!isUpdaterEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -189,7 +190,7 @@ public class UpdateServiceHelper {
|
||||
}
|
||||
|
||||
public static void registerForUpdates(Context context, UpdateService.AutoDownloadPolicy policy, String url) {
|
||||
if (!isUpdaterEnabled()) {
|
||||
if (!isUpdaterEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,11 @@ package org.mozilla.gecko.util;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class ContextUtils {
|
||||
private static final String INSTALLER_GOOGLE_PLAY = "com.android.vending";
|
||||
|
||||
private ContextUtils() {}
|
||||
|
||||
/**
|
||||
@ -25,4 +28,14 @@ public class ContextUtils {
|
||||
throw new AssertionError("Should not happen: Can't get package info of own package");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInstalledFromGooglePlay(final Context context) {
|
||||
final String installerPackageName = context.getPackageManager().getInstallerPackageName(context.getPackageName());
|
||||
|
||||
if (TextUtils.isEmpty(installerPackageName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return INSTALLER_GOOGLE_PLAY.equals(installerPackageName);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user