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 {
@CalledByNative
/* package */ static boolean isAvailable() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|| ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(
|| ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext());
}
......
......@@ -252,7 +252,7 @@ public class ExternalAuthUtils {
protected int checkGooglePlayServicesAvailable(final Context context) {
// TODO(crbug.com/577190): Temporarily allowing disk access until more permanent fix is in.
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context);
return ChromiumPlayServicesAvailability.getGooglePlayServicesConnectionResult(context);
}
}
......
......@@ -24,7 +24,7 @@ public class BackgroundSyncGooglePlayServicesCheckerTest {
@Test
@Feature("BackgroundSync")
public void testDisableLogicWhenGooglePlayServicesReturnsSuccess() {
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(
ShadowChromiumPlayServicesAvailability.setGetGooglePlayServicesConnectionResult(
ConnectionResult.SUCCESS);
assertFalse(GooglePlayServicesChecker.shouldDisableBackgroundSync());
}
......@@ -32,7 +32,7 @@ public class BackgroundSyncGooglePlayServicesCheckerTest {
@Test
@Feature("BackgroundSync")
public void testDisableLogicWhenGooglePlayServicesReturnsError() {
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(
ShadowChromiumPlayServicesAvailability.setGetGooglePlayServicesConnectionResult(
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED);
assertTrue(GooglePlayServicesChecker.shouldDisableBackgroundSync());
}
......
......@@ -152,7 +152,7 @@ public class ChromeJUnit4ClassRunner extends ContentJUnit4ClassRunner {
protected boolean restrictionApplies(String restriction) {
if (TextUtils.equals(
restriction, ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES)
&& (!ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(
&& (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
getTargetContext()))) {
return true;
}
......
......@@ -245,7 +245,7 @@ class BackgroundTaskSchedulerGcmNetworkManager implements BackgroundTaskSchedule
}
private GcmNetworkManager getGcmNetworkManager(Context context) {
if (ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(context)) {
if (ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context)) {
return GcmNetworkManager.getInstance(context);
}
return null;
......
......@@ -56,7 +56,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest {
@Before
public void setUp() {
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(true);
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(true);
mGcmNetworkManager = (ShadowGcmNetworkManager) Shadow.extract(
GcmNetworkManager.getInstance(ContextUtils.getApplicationContext()));
BackgroundTaskSchedulerGcmNetworkManager.setClockForTesting(mClock);
......@@ -297,7 +297,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest {
@Test
@Feature("BackgroundTaskScheduler")
public void testScheduleNoGooglePlayServices() {
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(false);
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(false);
TaskInfo.TimingInfo timingInfo =
TaskInfo.OneOffInfo.create().setWindowEndTimeMs(TIME_24_H_TO_MS).build();
......@@ -327,7 +327,7 @@ public class BackgroundTaskSchedulerGcmNetworkManagerTest {
@Feature("BackgroundTaskScheduler")
public void testCancelNoGooglePlayServices() {
// This simulates situation where Google Play Services is uninstalled.
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(false);
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(false);
TaskInfo.TimingInfo timingInfo =
TaskInfo.OneOffInfo.create().setWindowEndTimeMs(TIME_24_H_TO_MS).build();
......
......@@ -63,7 +63,7 @@ public class BackgroundTaskSchedulerImplTest {
TestBackgroundTask.reset();
// Initialize Google Play Services and GCM Network Manager for upgrade testing.
ShadowChromiumPlayServicesAvailability.setChromiumIsGooglePlayServicesAvailable(true);
ShadowChromiumPlayServicesAvailability.setIsGooglePlayServicesAvailable(true);
mGcmNetworkManager = (ShadowGcmNetworkManager) Shadow.extract(
GcmNetworkManager.getInstance(ContextUtils.getApplicationContext()));
......
......@@ -91,7 +91,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
protected void checkCanUseGooglePlayServices() throws AccountManagerDelegateException {
Context context = ContextUtils.getApplicationContext();
final int resultCode =
ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context);
ChromiumPlayServicesAvailability.getGooglePlayServicesConnectionResult(context);
if (resultCode == ConnectionResult.SUCCESS) {
return;
}
......@@ -264,7 +264,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
public boolean isGooglePlayServicesAvailable() {
// TODO(http://crbug.com/577190): Remove StrictMode override.
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
return ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(
return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext());
}
}
......
......@@ -42,7 +42,7 @@ public class LocationProviderGmsCore implements ConnectionCallbacks, OnConnectio
private LocationRequest mLocationRequest;
public static boolean isGooglePlayServicesAvailable(Context context) {
return ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(context);
return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context);
}
LocationProviderGmsCore(Context context) {
......
......@@ -55,7 +55,7 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider {
public static BarcodeDetectionProvider create() {
Context ctx = ContextUtils.getApplicationContext();
if (!ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(ctx)) {
if (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(ctx)) {
Log.w(TAG, "Google Play Services not available");
return null;
}
......
......@@ -22,7 +22,7 @@ public class FaceDetectionProviderImpl implements FaceDetectionProvider {
public void createFaceDetection(
InterfaceRequest<FaceDetection> request, FaceDetectorOptions options) {
final boolean isGmsCoreSupported =
ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(
ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext());
if (isGmsCoreSupported) {
......
......@@ -87,7 +87,7 @@ public class TextDetectionImpl implements TextDetection {
}
public static TextDetection create() {
if (!ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(
if (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext())) {
Log.e(TAG, "Google Play Services not available");
return null;
......
......@@ -27,7 +27,7 @@ public class TestUtils {
public static final boolean IS_GMS_CORE_SUPPORTED = isGmsCoreSupported();
private static boolean isGmsCoreSupported() {
return ChromiumPlayServicesAvailability.chromiumIsGooglePlayServicesAvailable(
return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
ContextUtils.getApplicationContext());
}
......
......@@ -16,7 +16,7 @@ public final class ChromiumPlayServicesAvailability {
* class. To see how this number originated, see
* 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.
......@@ -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
* PM/UX.
*/
public static int isGooglePlayServicesAvailable(final Context context) {
public static int getGooglePlayServicesConnectionResult(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
context, GMS_VERSION_NUMBER);
}
......@@ -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
* PM/UX.
*/
public static boolean chromiumIsGooglePlayServicesAvailable(final Context context) {
public static boolean isGooglePlayServicesAvailable(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
context, GMS_VERSION_NUMBER)
== ConnectionResult.SUCCESS;
......
......@@ -17,20 +17,20 @@ public class ShadowChromiumPlayServicesAvailability {
private static boolean sChromiumSuccess;
private static int sConnectionResult;
public static void setChromiumIsGooglePlayServicesAvailable(boolean value) {
public static void setIsGooglePlayServicesAvailable(boolean value) {
sChromiumSuccess = value;
}
public static void setIsGooglePlayServicesAvailable(int value) {
public static void setGetGooglePlayServicesConnectionResult(int value) {
sConnectionResult = value;
}
@Implementation
public static int isGooglePlayServicesAvailable(final Context context) {
public static int getGooglePlayServicesConnectionResult(final Context context) {
return sConnectionResult;
}
@Implementation
public static boolean chromiumIsGooglePlayServicesAvailable(final Context context) {
public static boolean isGooglePlayServicesAvailable(final Context context) {
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