Commit 530a7c8e authored by Sam Maier's avatar Sam Maier Committed by Commit Bot

Renaming ChromiumPlayServicesAvailability methods

This is in response to bsazonov@'s request on the prior review. This CL
also makes the version number public so that other users can reference
it if they want to do their own checks.

TBR: bsazonov
Bug: 1145211
Change-Id: Ia0c2d62593f792fee7000e670b8b100e34253544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519099
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824090}
parent 62150ee4
...@@ -35,7 +35,7 @@ public class UpdateScheduler { ...@@ -35,7 +35,7 @@ public class UpdateScheduler {
@CalledByNative @CalledByNative
/* package */ static boolean isAvailable() { /* package */ static boolean isAvailable() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|| ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable( || ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext()); ContextUtils.getApplicationContext());
} }
......
...@@ -252,7 +252,7 @@ public class ExternalAuthUtils { ...@@ -252,7 +252,7 @@ public class ExternalAuthUtils {
protected int checkGooglePlayServicesAvailable(final Context context) { protected int checkGooglePlayServicesAvailable(final Context context) {
// TODO(crbug.com/577190): Temporarily allowing disk access until more permanent fix is in. // TODO(crbug.com/577190): Temporarily allowing disk access until more permanent fix is in.
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) { try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context); return ChromiumPlayServicesAvailability.getGooglePlayServicesConnectionResult(context);
} }
} }
......
...@@ -24,7 +24,7 @@ public class BackgroundSyncGooglePlayServicesCheckerTest { ...@@ -24,7 +24,7 @@ public class BackgroundSyncGooglePlayServicesCheckerTest {
@Test @Test
@Feature("BackgroundSync") @Feature("BackgroundSync")
public void testDisableLogicWhenGooglePlayServicesReturnsSuccess() { public void testDisableLogicWhenGooglePlayServicesReturnsSuccess() {
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable( ShadowChromiumPlayServicesAvailability.setGetGooglePlayServicesConnectionResult(
ConnectionResult.SUCCESS); ConnectionResult.SUCCESS);
assertFalse(GooglePlayServicesChecker.shouldDisableBackgroundSync()); assertFalse(GooglePlayServicesChecker.shouldDisableBackgroundSync());
} }
...@@ -32,7 +32,7 @@ public class BackgroundSyncGooglePlayServicesCheckerTest { ...@@ -32,7 +32,7 @@ public class BackgroundSyncGooglePlayServicesCheckerTest {
@Test @Test
@Feature("BackgroundSync") @Feature("BackgroundSync")
public void testDisableLogicWhenGooglePlayServicesReturnsError() { public void testDisableLogicWhenGooglePlayServicesReturnsError() {
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable( ShadowChromiumPlayServicesAvailability.setGetGooglePlayServicesConnectionResult(
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED); ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED);
assertTrue(GooglePlayServicesChecker.shouldDisableBackgroundSync()); assertTrue(GooglePlayServicesChecker.shouldDisableBackgroundSync());
} }
......
...@@ -152,7 +152,7 @@ public class ChromeJUnit4ClassRunner extends ContentJUnit4ClassRunner { ...@@ -152,7 +152,7 @@ public class ChromeJUnit4ClassRunner extends ContentJUnit4ClassRunner {
protected boolean restrictionApplies(String restriction) { protected boolean restrictionApplies(String restriction) {
if (TextUtils.equals( if (TextUtils.equals(
restriction, ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) restriction, ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES)
&& (!ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable( && (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
getTargetContext()))) { getTargetContext()))) {
return true; return true;
} }
......
...@@ -245,7 +245,7 @@ class BackgroundTaskSchedulerGcmNetworkManager implements BackgroundTaskSchedule ...@@ -245,7 +245,7 @@ class BackgroundTaskSchedulerGcmNetworkManager implements BackgroundTaskSchedule
} }
private GcmNetworkManager getGcmNetworkManager(Context context) { private GcmNetworkManager getGcmNetworkManager(Context context) {
if (ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(context)) { if (ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context)) {
return GcmNetworkManager.getInstance(context); return GcmNetworkManager.getInstance(context);
} }
return null; return null;
......
...@@ -56,7 +56,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest { ...@@ -56,7 +56,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest {
@Before @Before
public void setUp() { public void setUp() {
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(true); ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(true);
mGcmNetworkManager = (ShadowGcmNetworkManager) Shadow.extract( mGcmNetworkManager = (ShadowGcmNetworkManager) Shadow.extract(
GcmNetworkManager.getInstance(ContextUtils.getApplicationContext())); GcmNetworkManager.getInstance(ContextUtils.getApplicationContext()));
BackgroundTaskSchedulerGcmNetworkManager.setClockForTesting(mClock); BackgroundTaskSchedulerGcmNetworkManager.setClockForTesting(mClock);
...@@ -297,7 +297,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest { ...@@ -297,7 +297,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest {
@Test @Test
@Feature("BackgroundTaskScheduler") @Feature("BackgroundTaskScheduler")
public void testScheduleNoGooglePlayServices() { public void testScheduleNoGooglePlayServices() {
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(false); ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(false);
TaskInfo.TimingInfo timingInfo = TaskInfo.TimingInfo timingInfo =
TaskInfo.OneOffInfo.create().setWindowEndTimeMs(TIME_24_H_TO_MS).build(); TaskInfo.OneOffInfo.create().setWindowEndTimeMs(TIME_24_H_TO_MS).build();
...@@ -327,7 +327,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest { ...@@ -327,7 +327,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest {
@Feature("BackgroundTaskScheduler") @Feature("BackgroundTaskScheduler")
public void testCancelNoGooglePlayServices() { public void testCancelNoGooglePlayServices() {
// This simulates situation where Google Play Services is uninstalled. // This simulates situation where Google Play Services is uninstalled.
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(false); ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(false);
TaskInfo.TimingInfo timingInfo = TaskInfo.TimingInfo timingInfo =
TaskInfo.OneOffInfo.create().setWindowEndTimeMs(TIME_24_H_TO_MS).build(); TaskInfo.OneOffInfo.create().setWindowEndTimeMs(TIME_24_H_TO_MS).build();
......
...@@ -63,7 +63,7 @@ public class BackgroundTaskSchedulerImplTest { ...@@ -63,7 +63,7 @@ public class BackgroundTaskSchedulerImplTest {
TestBackgroundTask.reset(); TestBackgroundTask.reset();
// Initialize Google Play Services and GCM Network Manager for upgrade testing. // Initialize Google Play Services and GCM Network Manager for upgrade testing.
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(true); ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(true);
mGcmNetworkManager = (ShadowGcmNetworkManager) Shadow.extract( mGcmNetworkManager = (ShadowGcmNetworkManager) Shadow.extract(
GcmNetworkManager.getInstance(ContextUtils.getApplicationContext())); GcmNetworkManager.getInstance(ContextUtils.getApplicationContext()));
......
...@@ -91,7 +91,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate { ...@@ -91,7 +91,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
protected void checkCanUseGooglePlayServices() throws AccountManagerDelegateException { protected void checkCanUseGooglePlayServices() throws AccountManagerDelegateException {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
final int resultCode = final int resultCode =
ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context); ChromiumPlayServicesAvailability.getGooglePlayServicesConnectionResult(context);
if (resultCode == ConnectionResult.SUCCESS) { if (resultCode == ConnectionResult.SUCCESS) {
return; return;
} }
...@@ -264,7 +264,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate { ...@@ -264,7 +264,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
public boolean isGooglePlayServicesAvailable() { public boolean isGooglePlayServicesAvailable() {
// TODO(http://crbug.com/577190): Remove StrictMode override. // TODO(http://crbug.com/577190): Remove StrictMode override.
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) { try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
return ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable( return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext()); ContextUtils.getApplicationContext());
} }
} }
......
...@@ -42,7 +42,7 @@ public class LocationProviderGmsCore implements ConnectionCallbacks, OnConnectio ...@@ -42,7 +42,7 @@ public class LocationProviderGmsCore implements ConnectionCallbacks, OnConnectio
private LocationRequest mLocationRequest; private LocationRequest mLocationRequest;
public static boolean isGooglePlayServicesAvailable(Context context) { public static boolean isGooglePlayServicesAvailable(Context context) {
return ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(context); return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context);
} }
LocationProviderGmsCore(Context context) { LocationProviderGmsCore(Context context) {
......
...@@ -55,7 +55,7 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider { ...@@ -55,7 +55,7 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider {
public static BarcodeDetectionProvider create() { public static BarcodeDetectionProvider create() {
Context ctx = ContextUtils.getApplicationContext(); Context ctx = ContextUtils.getApplicationContext();
if (!ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(ctx)) { if (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(ctx)) {
Log.w(TAG, "Google Play Services not available"); Log.w(TAG, "Google Play Services not available");
return null; return null;
} }
......
...@@ -22,7 +22,7 @@ public class FaceDetectionProviderImpl implements FaceDetectionProvider { ...@@ -22,7 +22,7 @@ public class FaceDetectionProviderImpl implements FaceDetectionProvider {
public void createFaceDetection( public void createFaceDetection(
InterfaceRequest<FaceDetection> request, FaceDetectorOptions options) { InterfaceRequest<FaceDetection> request, FaceDetectorOptions options) {
final boolean isGmsCoreSupported = final boolean isGmsCoreSupported =
ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable( ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext()); ContextUtils.getApplicationContext());
if (isGmsCoreSupported) { if (isGmsCoreSupported) {
......
...@@ -87,7 +87,7 @@ public class TextDetectionImpl implements TextDetection { ...@@ -87,7 +87,7 @@ public class TextDetectionImpl implements TextDetection {
} }
public static TextDetection create() { public static TextDetection create() {
if (!ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable( if (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext())) { ContextUtils.getApplicationContext())) {
Log.e(TAG, "Google Play Services not available"); Log.e(TAG, "Google Play Services not available");
return null; return null;
......
...@@ -27,7 +27,7 @@ public class TestUtils { ...@@ -27,7 +27,7 @@ public class TestUtils {
public static final boolean IS_GMS_CORE_SUPPORTED = isGmsCoreSupported(); public static final boolean IS_GMS_CORE_SUPPORTED = isGmsCoreSupported();
private static boolean isGmsCoreSupported() { private static boolean isGmsCoreSupported() {
return ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable( return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext()); ContextUtils.getApplicationContext());
} }
......
...@@ -16,7 +16,7 @@ public final class ChromiumPlayServicesAvailability { ...@@ -16,7 +16,7 @@ public final class ChromiumPlayServicesAvailability {
* class. To see how this number originated, see * class. To see how this number originated, see
* https://bugs.chromium.org/p/chromium/issues/detail?id=1145211#c3. * https://bugs.chromium.org/p/chromium/issues/detail?id=1145211#c3.
*/ */
private static final int GMS_VERSION_NUMBER = 20415000; public static final int GMS_VERSION_NUMBER = 20415000;
/** /**
* Checks, with an appropriate version number, if Play Services is available in this context. * Checks, with an appropriate version number, if Play Services is available in this context.
...@@ -29,7 +29,7 @@ public final class ChromiumPlayServicesAvailability { ...@@ -29,7 +29,7 @@ public final class ChromiumPlayServicesAvailability {
* the user to update GMS Core or fail with exception." If in doubt, please consult with your * the user to update GMS Core or fail with exception." If in doubt, please consult with your
* PM/UX. * PM/UX.
*/ */
public static int isGooglePlayServicesAvailable(final Context context) { public static int getGooglePlayServicesConnectionResult(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
context, GMS_VERSION_NUMBER); context, GMS_VERSION_NUMBER);
} }
...@@ -43,7 +43,7 @@ public final class ChromiumPlayServicesAvailability { ...@@ -43,7 +43,7 @@ public final class ChromiumPlayServicesAvailability {
* the user to update GMS Core or fail with exception." If in doubt, please consult with your * the user to update GMS Core or fail with exception." If in doubt, please consult with your
* PM/UX. * PM/UX.
*/ */
public static boolean chromiumIsGooglePlayServicesAvailable(final Context context) { public static boolean isGooglePlayServicesAvailable(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
context, GMS_VERSION_NUMBER) context, GMS_VERSION_NUMBER)
== ConnectionResult.SUCCESS; == ConnectionResult.SUCCESS;
......
...@@ -17,20 +17,20 @@ public class ShadowChromiumPlayServicesAvailability { ...@@ -17,20 +17,20 @@ public class ShadowChromiumPlayServicesAvailability {
private static boolean sChromiumSuccess; private static boolean sChromiumSuccess;
private static int sConnectionResult; private static int sConnectionResult;
public static void setChromiumIsGooglePlayServicesAvailable(boolean value) { public static void setIsGooglePlayServicesAvailable(boolean value) {
sChromiumSuccess = value; sChromiumSuccess = value;
} }
public static void setIsGooglePlayServicesAvailable(int value) { public static void setGetGooglePlayServicesConnectionResult(int value) {
sConnectionResult = value; sConnectionResult = value;
} }
@Implementation @Implementation
public static int isGooglePlayServicesAvailable(final Context context) { public static int getGooglePlayServicesConnectionResult(final Context context) {
return sConnectionResult; return sConnectionResult;
} }
@Implementation @Implementation
public static boolean chromiumIsGooglePlayServicesAvailable(final Context context) { public static boolean isGooglePlayServicesAvailable(final Context context) {
return sChromiumSuccess; return sChromiumSuccess;
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment