|
@@ -0,0 +1,4968 @@
|
|
|
+From: Wengling Chen <feiyu2817@gmail.com>
|
|
|
+Date: Sat, 2 Nov 2019 09:22:31 +0100
|
|
|
+Subject: Remove binary blob integrations
|
|
|
+
|
|
|
+Remove dependency on com.google.android.gms.auth
|
|
|
+kill GCM
|
|
|
+Remove dependency on com.google.android.gcm
|
|
|
+Remove dependency on com.google.android.gms.gcm
|
|
|
+It also disables Snippets, auto-update of offline pages and launching browser from background service.
|
|
|
+The snippets are already disabled in native codes, this will disable it on Java level.
|
|
|
+
|
|
|
+Remove dependency on com.google.android.play
|
|
|
+Remove dependency on vision, clearcut and phenotype
|
|
|
+Remove dependency on flags, places and stats
|
|
|
+Remove dependency on fido, iid, instantapps, location
|
|
|
+Remove dependency on com.google.android.gms.cast
|
|
|
+Remove dependency on auth, signin, dynamic and tasks
|
|
|
+Remove google_services_gcm
|
|
|
+
|
|
|
+Parts of this patch were developed by csagan5, uazo and others.
|
|
|
+---
|
|
|
+ ...em_webview_bundle.AndroidManifest.expected | 6 -
|
|
|
+ chrome/android/BUILD.gn | 36 --
|
|
|
+ chrome/android/chrome_java_sources.gni | 8 -
|
|
|
+ chrome/android/java/AndroidManifest.xml | 78 ----
|
|
|
+ .../org/chromium/chrome/browser/AppHooks.java | 14 +-
|
|
|
+ .../browser/PlayServicesVersionInfo.java | 12 +-
|
|
|
+ .../ChromeBackgroundTaskFactory.java | 3 -
|
|
|
+ .../component_updater/UpdateScheduler.java | 1 -
|
|
|
+ .../ExternalNavigationDelegateImpl.java | 8 +-
|
|
|
+ .../gcore/ChromeGoogleApiClientImpl.java | 25 +-
|
|
|
+ .../browser/gcore/GoogleApiClientHelper.java | 82 +----
|
|
|
+ .../instantapps/InstantAppsHandler.java | 56 ---
|
|
|
+ .../browser/language/AppLocaleUtils.java | 32 +-
|
|
|
+ .../browser/omaha/UpdateStatusProvider.java | 10 +-
|
|
|
+ .../inline/FakeAppUpdateManagerWrapper.java | 60 +--
|
|
|
+ .../inline/InlineUpdateControllerFactory.java | 16 -
|
|
|
+ .../inline/PlayInlineUpdateController.java | 226 +-----------
|
|
|
+ .../settings/PasswordSettings.java | 14 -
|
|
|
+ .../services/gcm/GCMBackgroundTask.java | 1 -
|
|
|
+ .../browser/webauth/AuthenticatorImpl.java | 29 +-
|
|
|
+ .../modules/chrome_feature_modules.gni | 3 -
|
|
|
+ .../browser/signin/services/android/BUILD.gn | 1 -
|
|
|
+ chrome/test/android/BUILD.gn | 2 -
|
|
|
+ components/background_task_scheduler/BUILD.gn | 6 -
|
|
|
+ .../internal/BUILD.gn | 10 -
|
|
|
+ .../BackgroundTaskGcmTaskService.java | 160 --------
|
|
|
+ ...ackgroundTaskSchedulerFactoryInternal.java | 6 +-
|
|
|
+ ...kgroundTaskSchedulerGcmNetworkManager.java | 257 -------------
|
|
|
+ components/externalauth/android/BUILD.gn | 3 -
|
|
|
+ .../externalauth/ExternalAuthUtils.java | 18 +-
|
|
|
+ .../UserRecoverableErrorHandler.java | 7 -
|
|
|
+ components/gcm_driver/android/BUILD.gn | 1 -
|
|
|
+ .../gcm_driver/instance_id/android/BUILD.gn | 3 -
|
|
|
+ .../instance_id/InstanceIDBridge.java | 49 +--
|
|
|
+ .../instance_id/InstanceIDWithSubtype.java | 26 +-
|
|
|
+ .../media_router/browser/android/BUILD.gn | 9 -
|
|
|
+ .../media_router/BrowserMediaRouter.java | 18 +-
|
|
|
+ .../media_router/CastSessionUtil.java | 35 --
|
|
|
+ .../components/media_router/MediaSink.java | 44 +--
|
|
|
+ .../media_router/MediaStatusBridge.java | 40 +-
|
|
|
+ .../caf/BaseNotificationController.java | 46 ---
|
|
|
+ .../caf/BaseSessionController.java | 100 +----
|
|
|
+ .../caf/CafBaseMediaRouteProvider.java | 103 +-----
|
|
|
+ .../caf/CafMediaRouteProvider.java | 16 -
|
|
|
+ .../media_router/caf/CafMessageHandler.java | 97 +----
|
|
|
+ .../media_router/caf/CastMediaSource.java | 10 +-
|
|
|
+ .../media_router/caf/CastOptionsProvider.java | 22 +-
|
|
|
+ .../caf/CastSessionController.java | 84 -----
|
|
|
+ .../media_router/caf/CastUtils.java | 8 -
|
|
|
+ .../CafExpandedControllerActivity.java | 33 +-
|
|
|
+ .../CafRemotingMediaRouteProvider.java | 2 +-
|
|
|
+ .../remoting/FlingingControllerAdapter.java | 74 ----
|
|
|
+ .../caf/remoting/RemotingMediaSource.java | 8 +-
|
|
|
+ .../remoting/RemotingSessionController.java | 26 --
|
|
|
+ .../test/android/cast_emulator/BUILD.gn | 1 -
|
|
|
+ components/module_installer/android/BUILD.gn | 2 -
|
|
|
+ .../signin/core/browser/android/BUILD.gn | 3 -
|
|
|
+ .../signin/GmsAvailabilityException.java | 4 +-
|
|
|
+ .../signin/SystemAccountManagerDelegate.java | 21 +-
|
|
|
+ components/sync/android/BUILD.gn | 1 -
|
|
|
+ content/public/android/BUILD.gn | 4 -
|
|
|
+ content/public/common/content_features.cc | 2 +-
|
|
|
+ content/test/BUILD.gn | 4 -
|
|
|
+ device/BUILD.gn | 3 -
|
|
|
+ remoting/android/client_java_tmpl.gni | 3 -
|
|
|
+ services/BUILD.gn | 9 -
|
|
|
+ services/device/geolocation/BUILD.gn | 3 -
|
|
|
+ .../geolocation/LocationProviderGmsCore.java | 102 +-----
|
|
|
+ services/shape_detection/BUILD.gn | 4 -
|
|
|
+ .../shape_detection/BarcodeDetectionImpl.java | 114 +-----
|
|
|
+ .../BarcodeDetectionProviderImpl.java | 31 +-
|
|
|
+ .../FaceDetectionImplGmsCore.java | 30 +-
|
|
|
+ .../shape_detection/TextDetectionImpl.java | 24 +-
|
|
|
+ third_party/android_deps/BUILD.gn | 344 +-----------------
|
|
|
+ .../gms/ChromiumPlayServicesAvailability.java | 10 +-
|
|
|
+ third_party/android_sdk/BUILD.gn | 3 -
|
|
|
+ third_party/google_android_play_core/BUILD.gn | 5 -
|
|
|
+ 77 files changed, 85 insertions(+), 2686 deletions(-)
|
|
|
+ delete mode 100644 components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskGcmTaskService.java
|
|
|
+ delete mode 100644 components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerGcmNetworkManager.java
|
|
|
+
|
|
|
+diff --git a/android_webview/expectations/system_webview_bundle.AndroidManifest.expected b/android_webview/expectations/system_webview_bundle.AndroidManifest.expected
|
|
|
+--- a/android_webview/expectations/system_webview_bundle.AndroidManifest.expected
|
|
|
++++ b/android_webview/expectations/system_webview_bundle.AndroidManifest.expected
|
|
|
+@@ -25,11 +25,6 @@
|
|
|
+ android:multiArch="true"
|
|
|
+ android:name="org.chromium.android_webview.nonembedded.WebViewApkApplication"
|
|
|
+ android:use32bitAbi="true">
|
|
|
+- <activity # DIFF-ANCHOR: ea1a94af
|
|
|
+- android:exported="false"
|
|
|
+- android:name="com.google.android.gms.common.api.GoogleApiActivity"
|
|
|
+- android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
|
|
+- </activity> # DIFF-ANCHOR: ea1a94af
|
|
|
+ <activity # DIFF-ANCHOR: a4438884
|
|
|
+ android:exported="true"
|
|
|
+ android:icon="@drawable/icon_webview"
|
|
|
+@@ -65,7 +60,6 @@
|
|
|
+ android:visibleToInstantApps="true">
|
|
|
+ </activity-alias> # DIFF-ANCHOR: b7cc06e9
|
|
|
+ <meta-data android:name="$PACKAGE.WebViewLibrary" android:value="libwebviewchromium.so"/>
|
|
|
+- <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
|
|
|
+ <meta-data android:name="org.chromium.content.browser.NUM_PRIVILEGED_SERVICES" android:value="0"/>
|
|
|
+ <meta-data android:name="org.chromium.content.browser.NUM_SANDBOXED_SERVICES" android:value="40"/>
|
|
|
+ <provider # DIFF-ANCHOR: a5e78e63
|
|
|
+diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
|
|
|
+--- a/chrome/android/BUILD.gn
|
|
|
++++ b/chrome/android/BUILD.gn
|
|
|
+@@ -276,20 +276,10 @@ android_library("chrome_java") {
|
|
|
+ ":partner_location_descriptor_proto_java",
|
|
|
+ ":update_proto_java",
|
|
|
+ ":usage_stats_proto_java",
|
|
|
+- "$google_play_services_package:google_play_services_auth_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_framework_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_java",
|
|
|
+- "$google_play_services_package:google_play_services_fido_java",
|
|
|
+- "$google_play_services_package:google_play_services_gcm_java",
|
|
|
+- "$google_play_services_package:google_play_services_iid_java",
|
|
|
+- "$google_play_services_package:google_play_services_tasks_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//cc:cc_java",
|
|
|
+ "//chrome/android/features/keyboard_accessory:public_java",
|
|
|
+- "//chrome/android/modules/cablev2_authenticator/public:java",
|
|
|
+ "//chrome/android/modules/image_editor/provider:java",
|
|
|
+ "//chrome/android/modules/stack_unwinder/provider:java",
|
|
|
+ "//chrome/android/webapk/libs/client:client_java",
|
|
|
+@@ -522,14 +512,12 @@ android_library("chrome_java") {
|
|
|
+ "//third_party/android_deps:material_design_java",
|
|
|
+ "//third_party/android_deps:protobuf_lite_runtime_java",
|
|
|
+ "//third_party/android_media:android_media_java",
|
|
|
+- "//third_party/android_sdk:android_gcm_java",
|
|
|
+ "//third_party/android_sdk/androidx_browser:androidx_browser_java",
|
|
|
+ "//third_party/android_swipe_refresh:android_swipe_refresh_java",
|
|
|
+ "//third_party/blink/public:blink_headers_java",
|
|
|
+ "//third_party/blink/public/mojom:android_mojo_bindings_java",
|
|
|
+ "//third_party/blink/public/mojom:mojom_platform_java",
|
|
|
+ "//third_party/gif_player:gif_player_java",
|
|
|
+- "//third_party/google_android_play_core:com_google_android_play_core_java",
|
|
|
+ "//third_party/metrics_proto:metrics_proto_java",
|
|
|
+ "//ui/android:ui_java",
|
|
|
+ "//ui/base/mojom:mojom_java",
|
|
|
+@@ -785,11 +773,6 @@ junit_binary("chrome_junit_tests") {
|
|
|
+ ":chrome_app_java_resources",
|
|
|
+ ":chrome_java",
|
|
|
+ ":partner_location_descriptor_proto_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_framework_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_java",
|
|
|
+- "$google_play_services_package:google_play_services_fido_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//base:base_junit_test_support",
|
|
|
+@@ -1030,14 +1013,6 @@ android_library("chrome_test_java") {
|
|
|
+ ":chrome_app_java_resources",
|
|
|
+ ":chrome_test_util_java",
|
|
|
+ ":partner_location_descriptor_proto_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_framework_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_java",
|
|
|
+- "$google_play_services_package:google_play_services_fido_java",
|
|
|
+- "$google_play_services_package:google_play_services_gcm_java",
|
|
|
+- "$google_play_services_package:google_play_services_iid_java",
|
|
|
+- "$google_play_services_package:google_play_services_tasks_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//base:jni_java",
|
|
|
+@@ -2014,7 +1989,6 @@ android_library("browser_java_test_support") {
|
|
|
+ ]
|
|
|
+ deps = [
|
|
|
+ ":chrome_java",
|
|
|
+- "$google_play_services_package:google_play_services_gcm_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//chrome/browser/profiles/android:java",
|
|
|
+@@ -2154,8 +2128,6 @@ android_library("base_monochrome_module_java") {
|
|
|
+ # enable_chrome_module is true and //chrome code is in a DFM.
|
|
|
+ android_library("base_module_java") {
|
|
|
+ sources = [
|
|
|
+- "java/src/com/google/ipc/invalidation/ticl/android2/channel/GcmRegistrationTaskService.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/ChromeBackgroundService.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/ChromeBackupAgent.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/DeferredStartupHandler.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/base/DexFixer.java",
|
|
|
+@@ -2166,8 +2138,6 @@ android_library("base_module_java") {
|
|
|
+ "java/src/org/chromium/chrome/browser/base/SplitCompatBackupAgent.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/base/SplitCompatContentProvider.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/base/SplitCompatCustomTabsService.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/base/SplitCompatGcmListenerService.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/base/SplitCompatGcmTaskService.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/base/SplitCompatIntentService.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/base/SplitCompatJobService.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/base/SplitCompatMinidumpUploadJobService.java",
|
|
|
+@@ -2196,14 +2166,10 @@ android_library("base_module_java") {
|
|
|
+ "java/src/org/chromium/chrome/browser/photo_picker/DecoderService.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/prerender/ChromePrerenderService.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/provider/ChromeBrowserProvider.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/services/gcm/ChromeGcmListenerService.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/services/gcm/GCMBackgroundService.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/services/gcm/InvalidationGcmUpstreamSender.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/tracing/TracingNotificationService.java",
|
|
|
+ ]
|
|
|
+ deps = [
|
|
|
+ ":chrome_base_module_resources",
|
|
|
+- "$google_play_services_package:google_play_services_gcm_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//chrome/browser/download/android:file_provider_java",
|
|
|
+@@ -2219,7 +2185,6 @@ android_library("base_module_java") {
|
|
|
+ "//third_party/android_deps:androidx_annotation_annotation_java",
|
|
|
+ "//third_party/android_deps:androidx_collection_collection_java",
|
|
|
+ "//third_party/android_deps:androidx_fragment_fragment_java",
|
|
|
+- "//third_party/google_android_play_core:com_google_android_play_core_java",
|
|
|
+ "//ui/android:ui_no_recycler_view_java",
|
|
|
+
|
|
|
+ # Deps needed for child processes.
|
|
|
+@@ -2238,7 +2203,6 @@ android_library("base_module_java") {
|
|
|
+ # Deps to pull services into base module.
|
|
|
+ # TODO(crbug.com/1126301): Consider moving these to the chrome module to
|
|
|
+ # reduce base dex size.
|
|
|
+- "$google_play_services_package:google_play_services_cast_framework_java",
|
|
|
+ "//components/background_task_scheduler:background_task_scheduler_java",
|
|
|
+ "//components/payments/content/android:service_java",
|
|
|
+ "//third_party/android_sdk/androidx_browser:androidx_browser_java",
|
|
|
+diff --git a/chrome/android/chrome_java_sources.gni b/chrome/android/chrome_java_sources.gni
|
|
|
+--- a/chrome/android/chrome_java_sources.gni
|
|
|
++++ b/chrome/android/chrome_java_sources.gni
|
|
|
+@@ -16,7 +16,6 @@ chrome_java_sources = [
|
|
|
+ "java/src/org/chromium/chrome/browser/ChromeActionModeHandler.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/ChromeActivitySessionTracker.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/ChromeApplication.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/ChromeBackgroundServiceImpl.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/ChromeBackupAgentImpl.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/ChromeBackupWatcher.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/ChromeBaseAppCompatActivity.java",
|
|
|
+@@ -1218,10 +1217,6 @@ chrome_java_sources = [
|
|
|
+ "java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfShareActivity.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/services/AccountsChangedReceiver.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/services/gcm/ChromeGcmListenerServiceImpl.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/services/gcm/GCMBackgroundServiceImpl.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/services/gcm/GCMBackgroundTask.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/services/gcm/GcmUma.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/settings/MainSettings.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/settings/SettingsActivity.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/settings/SettingsLauncherImpl.java",
|
|
|
+@@ -1510,9 +1505,6 @@ chrome_java_sources = [
|
|
|
+ "java/src/org/chromium/chrome/browser/webapps/addtohomescreen/AddToHomescreenViewBinder.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/webauth/AuthenticatorFactory.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/webauth/Fido2ApiHandler.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/webauth/Fido2CredentialRequest.java",
|
|
|
+- "java/src/org/chromium/chrome/browser/webauth/Fido2Helper.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/webauth/HandlerResponseCallback.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/webauth/authenticator/CableAuthenticatorActivity.java",
|
|
|
+ "java/src/org/chromium/chrome/browser/webshare/ShareServiceImplementationFactory.java",
|
|
|
+diff --git a/chrome/android/java/AndroidManifest.xml b/chrome/android/java/AndroidManifest.xml
|
|
|
+--- a/chrome/android/java/AndroidManifest.xml
|
|
|
++++ b/chrome/android/java/AndroidManifest.xml
|
|
|
+@@ -80,23 +80,18 @@ by a child template that "extends" this file.
|
|
|
+ <permission android:name="{{ manifest_package }}.permission.CHILD_SERVICE" android:protectionLevel="signature" />
|
|
|
+ <permission android:name="{{ manifest_package }}.permission.READ_WRITE_BOOKMARK_FOLDERS" android:protectionLevel="signatureOrSystem" />
|
|
|
+ <permission android:name="{{ manifest_package }}.TOS_ACKED" android:protectionLevel="signatureOrSystem" />
|
|
|
+- <!-- Only chrome can receive the messages and registration result -->
|
|
|
+- <permission android:name="{{ manifest_package }}.permission.C2D_MESSAGE"
|
|
|
+- android:protectionLevel="signature" />
|
|
|
+ <permission android:name="{{ manifest_package }}.permission.DEBUG"
|
|
|
+ android:label="Debug web pages"
|
|
|
+ android:protectionLevel="signature" />
|
|
|
+ <permission android:name="{{ manifest_package }}.permission.TRANSLATE"
|
|
|
+ android:protectionLevel="signature" />
|
|
|
+
|
|
|
+- <uses-permission android:name="{{ manifest_package }}.permission.C2D_MESSAGE" />
|
|
|
+ <uses-permission android:name="{{ manifest_package }}.permission.READ_WRITE_BOOKMARK_FOLDERS" />
|
|
|
+ <uses-permission android:name="{{ manifest_package }}.TOS_ACKED" />
|
|
|
+
|
|
|
+ <uses-permission android:name="com.chrome.permission.DEVICE_EXTRAS" />
|
|
|
+ <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
|
|
|
+ <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
|
|
|
+- <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
|
|
+ <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
|
|
|
+
|
|
|
+ {% block extra_uses_permissions %}
|
|
|
+@@ -706,16 +701,6 @@ by a child template that "extends" this file.
|
|
|
+ </intent-filter>
|
|
|
+ </activity>
|
|
|
+
|
|
|
+- <activity android:name="org.chromium.components.media_router.caf.remoting.CafExpandedControllerActivity"
|
|
|
+- android:theme="@style/Theme.Chromium.Activity"
|
|
|
+- android:label="Chrome.CafExpandedControllerActivity"
|
|
|
+- android:hardwareAccelerated="true"
|
|
|
+- android:launchMode="singleTask"
|
|
|
+- android:noHistory="true"
|
|
|
+- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
|
|
|
+- android:excludeFromRecents="true">
|
|
|
+- </activity>
|
|
|
+-
|
|
|
+ <!-- This activity is used to restart the main Chrome process. Should never be exported. -->
|
|
|
+ <activity android:name="org.chromium.chrome.browser.BrowserRestartActivity"
|
|
|
+ android:launchMode="singleInstance"
|
|
|
+@@ -779,15 +764,6 @@ by a child template that "extends" this file.
|
|
|
+ </intent-filter>
|
|
|
+ </activity>
|
|
|
+
|
|
|
+- <!-- Activity for dispatching intents to Instant Apps. -->
|
|
|
+- <activity
|
|
|
+- android:name="org.chromium.chrome.browser.instantapps.AuthenticatedProxyActivity"
|
|
|
+- android:exported="false"
|
|
|
+- android:theme="@android:style/Theme.NoDisplay"
|
|
|
+- android:noHistory="true"
|
|
|
+- android:excludeFromRecents="true">
|
|
|
+- </activity>
|
|
|
+-
|
|
|
+ <activity
|
|
|
+ android:name="org.chromium.chrome.browser.vr.VrCancelAnimationActivity"
|
|
|
+ android:exported="false"
|
|
|
+@@ -926,36 +902,6 @@ by a child template that "extends" this file.
|
|
|
+ android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
|
|
|
+ android:hardwareAccelerated="false" />
|
|
|
+
|
|
|
+- <!-- Receiver for GCM messages. -->
|
|
|
+- <receiver android:name="com.google.android.gms.gcm.GcmReceiver"
|
|
|
+- android:exported="true"
|
|
|
+- android:permission="com.google.android.c2dm.permission.SEND">
|
|
|
+- <intent-filter>
|
|
|
+- <action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
|
|
+- <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
|
|
|
+- <category android:name="{{ manifest_package }}"/>
|
|
|
+- </intent-filter>
|
|
|
+- </receiver>
|
|
|
+- <!-- GcmTaskService for registration for Invalidations. Not actually implemented anymore. -->
|
|
|
+- <service android:name="com.google.ipc.invalidation.ticl.android2.channel.GcmRegistrationTaskService"
|
|
|
+- android:exported="true"
|
|
|
+- android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE" >
|
|
|
+- <intent-filter>
|
|
|
+- <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
|
|
|
+- </intent-filter>
|
|
|
+- </service>
|
|
|
+- <!-- GcmListenerService for messages from GCM. -->
|
|
|
+- <service android:name="org.chromium.chrome.browser.services.gcm.ChromeGcmListenerService"
|
|
|
+- android:exported="false" >
|
|
|
+- <intent-filter>
|
|
|
+- <action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
|
|
+- </intent-filter>
|
|
|
+- </service>
|
|
|
+- <service android:name="org.chromium.chrome.browser.services.gcm.GCMBackgroundService"
|
|
|
+- android:exported="false"/>
|
|
|
+- <service android:name="org.chromium.chrome.browser.services.gcm.InvalidationGcmUpstreamSender"
|
|
|
+- android:exported="false"/>
|
|
|
+-
|
|
|
+ <!-- Android Notification service listener -->
|
|
|
+ <service android:name="org.chromium.chrome.browser.notifications.NotificationService"
|
|
|
+ android:exported="false"/>
|
|
|
+@@ -979,28 +925,10 @@ by a child template that "extends" this file.
|
|
|
+ android:exported="false"
|
|
|
+ android:permission="android.permission.BIND_JOB_SERVICE"/>
|
|
|
+
|
|
|
+- <!-- Background Task Scheduler GCM task service -->
|
|
|
+- <service android:name="org.chromium.components.background_task_scheduler.internal.BackgroundTaskGcmTaskService"
|
|
|
+- android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"
|
|
|
+- android:exported="true">
|
|
|
+- <intent-filter>
|
|
|
+- <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY" />
|
|
|
+- </intent-filter>
|
|
|
+- </service>
|
|
|
+-
|
|
|
+ <!-- Background Task Scheduler alarm receiver -->
|
|
|
+ <receiver android:name="org.chromium.components.background_task_scheduler.internal.BackgroundTaskBroadcastReceiver"
|
|
|
+ android:exported="false" />
|
|
|
+
|
|
|
+- <!-- GcmTaskService implementation to wake Chrome on scheduled events -->
|
|
|
+- <service android:name="org.chromium.chrome.browser.ChromeBackgroundService"
|
|
|
+- android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"
|
|
|
+- android:exported="true">
|
|
|
+- <intent-filter>
|
|
|
+- <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY" />
|
|
|
+- </intent-filter>
|
|
|
+- </service>
|
|
|
+-
|
|
|
+ <service android:name="org.chromium.chrome.browser.prerender.ChromePrerenderService"
|
|
|
+ android:exported="true"
|
|
|
+ tools:ignore="ExportedService" />
|
|
|
+@@ -1197,12 +1125,6 @@ by a child template that "extends" this file.
|
|
|
+ <meta-data android:name="com.google.ar.core" android:value="optional" />
|
|
|
+ {% endif %}
|
|
|
+
|
|
|
+- <!-- Cast support -->
|
|
|
+- <meta-data
|
|
|
+- android:name=
|
|
|
+- "com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
|
|
+- android:value="org.chromium.components.media_router.caf.CastOptionsProvider"/>
|
|
|
+-
|
|
|
+ <!-- These providers are declared in the base module to give the chrome
|
|
|
+ split preloader more time to work. -->
|
|
|
+ <provider android:name="org.chromium.chrome.browser.util.ChromeFileProvider"
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java b/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java
|
|
|
+@@ -10,9 +10,6 @@ import android.content.pm.PackageManager;
|
|
|
+ import androidx.annotation.Nullable;
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.annotations.CalledByNative;
|
|
|
+ import org.chromium.chrome.browser.banners.AppDetailsDelegate;
|
|
|
+@@ -294,16 +291,7 @@ public abstract class AppHooks {
|
|
|
+ * same as {@link GoogleApiAvailability#isGooglePlayServicesAvailable()}.
|
|
|
+ */
|
|
|
+ public int isGoogleApiAvailableWithMinApkVersion(int minApkVersion) {
|
|
|
+- try {
|
|
|
+- PackageInfo gmsPackageInfo =
|
|
|
+- ContextUtils.getApplicationContext().getPackageManager().getPackageInfo(
|
|
|
+- GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, /* flags= */ 0);
|
|
|
+- int apkVersion = gmsPackageInfo.versionCode;
|
|
|
+- if (apkVersion >= minApkVersion) return ConnectionResult.SUCCESS;
|
|
|
+- } catch (PackageManager.NameNotFoundException e) {
|
|
|
+- return ConnectionResult.SERVICE_MISSING;
|
|
|
+- }
|
|
|
+- return ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED;
|
|
|
++ return 1; /* SERVICE_MISSING*/
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/PlayServicesVersionInfo.java b/chrome/android/java/src/org/chromium/chrome/browser/PlayServicesVersionInfo.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/PlayServicesVersionInfo.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/PlayServicesVersionInfo.java
|
|
|
+@@ -7,8 +7,6 @@ package org.chromium.chrome.browser;
|
|
|
+ import android.content.Context;
|
|
|
+ import android.content.pm.PackageManager;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.annotations.CalledByNative;
|
|
|
+ import org.chromium.components.externalauth.ExternalAuthUtils;
|
|
|
+@@ -29,7 +27,7 @@ public class PlayServicesVersionInfo {
|
|
|
+ public static String getGmsInfo() {
|
|
|
+ Context context = ContextUtils.getApplicationContext();
|
|
|
+
|
|
|
+- final long sdkVersion = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE;
|
|
|
++ final long sdkVersion = 12600000;
|
|
|
+ final long installedGmsVersion = getApkVersionNumber(context);
|
|
|
+
|
|
|
+ final String accessType;
|
|
|
+@@ -53,12 +51,6 @@ public class PlayServicesVersionInfo {
|
|
|
+ * package is not found.
|
|
|
+ */
|
|
|
+ public static int getApkVersionNumber(Context context) {
|
|
|
+- try {
|
|
|
+- return context.getPackageManager()
|
|
|
+- .getPackageInfo(GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0)
|
|
|
+- .versionCode;
|
|
|
+- } catch (PackageManager.NameNotFoundException e) {
|
|
|
+- return 0;
|
|
|
+- }
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/background_task_scheduler/ChromeBackgroundTaskFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/background_task_scheduler/ChromeBackgroundTaskFactory.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/background_task_scheduler/ChromeBackgroundTaskFactory.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/background_task_scheduler/ChromeBackgroundTaskFactory.java
|
|
|
+@@ -20,7 +20,6 @@ import org.chromium.chrome.browser.offlinepages.OfflineBackgroundTask;
|
|
|
+ import org.chromium.chrome.browser.offlinepages.prefetch.OfflineNotificationBackgroundTask;
|
|
|
+ import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchBackgroundTask;
|
|
|
+ import org.chromium.chrome.browser.omaha.OmahaService;
|
|
|
+-import org.chromium.chrome.browser.services.gcm.GCMBackgroundTask;
|
|
|
+ import org.chromium.chrome.browser.webapps.WebApkUpdateTask;
|
|
|
+ import org.chromium.components.background_task_scheduler.BackgroundTask;
|
|
|
+ import org.chromium.components.background_task_scheduler.BackgroundTaskFactory;
|
|
|
+@@ -60,8 +59,6 @@ public class ChromeBackgroundTaskFactory implements BackgroundTaskFactory {
|
|
|
+ switch (taskId) {
|
|
|
+ case TaskIds.OMAHA_JOB_ID:
|
|
|
+ return new OmahaService();
|
|
|
+- case TaskIds.GCM_BACKGROUND_TASK_JOB_ID:
|
|
|
+- return new GCMBackgroundTask();
|
|
|
+ case TaskIds.OFFLINE_PAGES_BACKGROUND_JOB_ID:
|
|
|
+ return new OfflineBackgroundTask();
|
|
|
+ case TaskIds.OFFLINE_PAGES_PREFETCH_JOB_ID:
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/component_updater/UpdateScheduler.java b/chrome/android/java/src/org/chromium/chrome/browser/component_updater/UpdateScheduler.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/component_updater/UpdateScheduler.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/component_updater/UpdateScheduler.java
|
|
|
+@@ -14,7 +14,6 @@ import org.chromium.components.background_task_scheduler.BackgroundTask.TaskFini
|
|
|
+ import org.chromium.components.background_task_scheduler.BackgroundTaskSchedulerFactory;
|
|
|
+ import org.chromium.components.background_task_scheduler.TaskIds;
|
|
|
+ import org.chromium.components.background_task_scheduler.TaskInfo;
|
|
|
+-import org.chromium.gms.ChromiumPlayServicesAvailability;
|
|
|
+
|
|
|
+ /** Java-side implementation of the component update scheduler using the BackgroundTaskScheduler. */
|
|
|
+ @JNINamespace("component_updater")
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
|
|
|
+@@ -216,12 +216,8 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void maybeAdjustInstantAppExtras(Intent intent, boolean isIntentToInstantApp) {
|
|
|
+- if (isIntentToInstantApp) {
|
|
|
+- intent.putExtra(InstantAppsHandler.IS_GOOGLE_SEARCH_REFERRER, true);
|
|
|
+- } else {
|
|
|
+- // Make sure this extra is not sent unless we've done the verification.
|
|
|
+- intent.removeExtra(InstantAppsHandler.IS_GOOGLE_SEARCH_REFERRER);
|
|
|
+- }
|
|
|
++ // Always remove this extra
|
|
|
++ intent.removeExtra(InstantAppsHandler.IS_GOOGLE_SEARCH_REFERRER);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java
|
|
|
+@@ -6,9 +6,6 @@ package org.chromium.chrome.browser.gcore;
|
|
|
+
|
|
|
+ import android.content.Context;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.api.GoogleApiClient;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.base.TraceEvent;
|
|
|
+ import org.chromium.components.externalauth.ExternalAuthUtils;
|
|
|
+@@ -22,7 +19,6 @@ public class ChromeGoogleApiClientImpl implements ChromeGoogleApiClient {
|
|
|
+ private static final String TAG = "Icing";
|
|
|
+
|
|
|
+ private final Context mApplicationContext;
|
|
|
+- private final GoogleApiClient mClient;
|
|
|
+ private final ExternalAuthUtils mExternalAuthUtils;
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -32,10 +28,9 @@ public class ChromeGoogleApiClientImpl implements ChromeGoogleApiClient {
|
|
|
+ * @param requireFirstPartyBuild true if the given client can only be used in a first-party
|
|
|
+ * build.
|
|
|
+ */
|
|
|
+- public ChromeGoogleApiClientImpl(Context context, GoogleApiClient client,
|
|
|
++ public ChromeGoogleApiClientImpl(Context context,
|
|
|
+ boolean requireFirstPartyBuild) {
|
|
|
+ mApplicationContext = context.getApplicationContext();
|
|
|
+- mClient = client;
|
|
|
+ mExternalAuthUtils = ExternalAuthUtils.getInstance();
|
|
|
+ if (requireFirstPartyBuild && !mExternalAuthUtils.isChromeGoogleSigned()) {
|
|
|
+ throw new IllegalStateException("GoogleApiClient requires first-party build");
|
|
|
+@@ -44,7 +39,6 @@ public class ChromeGoogleApiClientImpl implements ChromeGoogleApiClient {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void disconnect() {
|
|
|
+- mClient.disconnect();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -60,24 +54,11 @@ public class ChromeGoogleApiClientImpl implements ChromeGoogleApiClient {
|
|
|
+ @Override
|
|
|
+ public boolean connectWithTimeout(long timeout) {
|
|
|
+ TraceEvent.begin("ChromeGoogleApiClientImpl:connectWithTimeout");
|
|
|
+- try {
|
|
|
+- ConnectionResult result = mClient.blockingConnect(timeout, TimeUnit.MILLISECONDS);
|
|
|
+- if (!result.isSuccess()) {
|
|
|
+- Log.e(TAG, "Connection to GmsCore unsuccessful. Error %d", result.getErrorCode());
|
|
|
+- } else {
|
|
|
+- Log.d(TAG, "Connection to GmsCore successful.");
|
|
|
+- }
|
|
|
+- return result.isSuccess();
|
|
|
+- } finally {
|
|
|
+- TraceEvent.end("ChromeGoogleApiClientImpl:connectWithTimeout");
|
|
|
+- }
|
|
|
++ TraceEvent.end("ChromeGoogleApiClientImpl:connectWithTimeout");
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Context getApplicationContext() {
|
|
|
+ return mApplicationContext;
|
|
|
+ }
|
|
|
+-
|
|
|
+- public GoogleApiClient getApiClient() {
|
|
|
+- return mClient;
|
|
|
+- }
|
|
|
+ }
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/gcore/GoogleApiClientHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/gcore/GoogleApiClientHelper.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/gcore/GoogleApiClientHelper.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/gcore/GoogleApiClientHelper.java
|
|
|
+@@ -7,11 +7,6 @@ package org.chromium.chrome.browser.gcore;
|
|
|
+ import android.os.Bundle;
|
|
|
+ import android.os.Handler;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.api.GoogleApiClient;
|
|
|
+-import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
|
|
|
+-import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
|
|
|
+-
|
|
|
+ import org.chromium.base.ApplicationStatus;
|
|
|
+ import org.chromium.base.ApplicationStatus.ApplicationStateListener;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+@@ -67,29 +62,15 @@ import org.chromium.base.ThreadUtils;
|
|
|
+ * }
|
|
|
+ * </pre>
|
|
|
+ */
|
|
|
+-public class GoogleApiClientHelper
|
|
|
+- implements OnConnectionFailedListener, ConnectionCallbacks {
|
|
|
++public class GoogleApiClientHelper {
|
|
|
+ private static final String TAG = "GCore";
|
|
|
+
|
|
|
+ private int mResolutionAttempts;
|
|
|
+ private boolean mWasConnectedBefore;
|
|
|
+ private final Handler mHandler = new Handler(ThreadUtils.getUiThreadLooper());
|
|
|
+- private final GoogleApiClient mClient;
|
|
|
+ private long mDisconnectionDelayMs;
|
|
|
+ private Runnable mPendingDisconnect;
|
|
|
+
|
|
|
+- /**
|
|
|
+- * Creates a helper and enrolls it in the various connection management features.
|
|
|
+- * See the class documentation for {@link GoogleApiClientHelper} for more information.
|
|
|
+- *
|
|
|
+- * @param client The client to wrap.
|
|
|
+- */
|
|
|
+- public GoogleApiClientHelper(GoogleApiClient client) {
|
|
|
+- mClient = client;
|
|
|
+- enableConnectionRetrying(true);
|
|
|
+- enableLifecycleManagement(true);
|
|
|
+- }
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * Opts in or out of lifecycle management. The client's connection will be closed and reopened
|
|
|
+ * when Chrome goes in and out of background.
|
|
|
+@@ -116,13 +97,6 @@ public class GoogleApiClientHelper
|
|
|
+ * Enabling or disabling it while it is already enabled or disabled has no effect.
|
|
|
+ */
|
|
|
+ public void enableConnectionRetrying(boolean enabled) {
|
|
|
+- if (enabled) {
|
|
|
+- mClient.registerConnectionCallbacks(this);
|
|
|
+- mClient.registerConnectionFailedListener(this);
|
|
|
+- } else {
|
|
|
+- mClient.unregisterConnectionCallbacks(this);
|
|
|
+- mClient.unregisterConnectionFailedListener(this);
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -155,21 +129,11 @@ public class GoogleApiClientHelper
|
|
|
+ // Cancel and reschedule the disconnection if we are in the background. We do it early to
|
|
|
+ // avoid race conditions between a disconnect on the UI thread and the connect below.
|
|
|
+ if (!ApplicationStatus.hasVisibleActivities()) scheduleDisconnection();
|
|
|
+-
|
|
|
+- // The client might be disconnected if we were idle in the background for too long.
|
|
|
+- if (!mClient.isConnected() && !mClient.isConnecting()) {
|
|
|
+- Log.d(TAG, "Reconnecting the client.");
|
|
|
+- mClient.connect();
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ void restoreConnectedState() {
|
|
|
+ // If we go back to the foreground before a delayed disconnect happens, cancel it.
|
|
|
+ cancelPendingDisconnection();
|
|
|
+-
|
|
|
+- if (mWasConnectedBefore) {
|
|
|
+- mClient.connect();
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -192,12 +156,6 @@ public class GoogleApiClientHelper
|
|
|
+ }
|
|
|
+
|
|
|
+ private void disconnect() {
|
|
|
+- if (mClient.isConnected() || mClient.isConnecting()) {
|
|
|
+- mWasConnectedBefore = true;
|
|
|
+- }
|
|
|
+-
|
|
|
+- // We always call disconnect to abort possibly pending connection requests.
|
|
|
+- mClient.disconnect();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void cancelPendingDisconnection() {
|
|
|
+@@ -207,43 +165,7 @@ public class GoogleApiClientHelper
|
|
|
+ mPendingDisconnect = null;
|
|
|
+ }
|
|
|
+
|
|
|
+- @Override
|
|
|
+- public void onConnectionFailed(ConnectionResult result) {
|
|
|
+- if (!isErrorRecoverableByRetrying(result.getErrorCode())) {
|
|
|
+- Log.d(TAG, "Not retrying managed client connection. Unrecoverable error: %d",
|
|
|
+- result.getErrorCode());
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- if (mResolutionAttempts < ConnectedTask.RETRY_NUMBER_LIMIT) {
|
|
|
+- Log.d(TAG, "Retrying managed client connection. attempt %d/%d - errorCode: %d",
|
|
|
+- mResolutionAttempts, ConnectedTask.RETRY_NUMBER_LIMIT, result.getErrorCode());
|
|
|
+- mResolutionAttempts += 1;
|
|
|
+-
|
|
|
+- mHandler.postDelayed(new Runnable() {
|
|
|
+- @Override
|
|
|
+- public void run() {
|
|
|
+- mClient.connect();
|
|
|
+- }
|
|
|
+- }, ConnectedTask.CONNECTION_RETRY_TIME_MS);
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onConnected(Bundle connectionHint) {
|
|
|
+- mResolutionAttempts = 0;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onConnectionSuspended(int cause) {
|
|
|
+- // GoogleApiClient handles retrying on suspension itself. Logging in case it didn't succeed
|
|
|
+- // for some reason.
|
|
|
+- Log.w(TAG, "Managed client connection suspended. Cause: %d", cause);
|
|
|
+- }
|
|
|
+-
|
|
|
+ private static boolean isErrorRecoverableByRetrying(int errorCode) {
|
|
|
+- return errorCode == ConnectionResult.INTERNAL_ERROR
|
|
|
+- || errorCode == ConnectionResult.NETWORK_ERROR
|
|
|
+- || errorCode == ConnectionResult.SERVICE_UPDATING;
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/instantapps/InstantAppsHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/instantapps/InstantAppsHandler.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/instantapps/InstantAppsHandler.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/instantapps/InstantAppsHandler.java
|
|
|
+@@ -40,31 +40,9 @@ public class InstantAppsHandler {
|
|
|
+ // TODO(mariakhomenko): Use system once we roll to O SDK.
|
|
|
+ private static final int FLAG_DO_NOT_LAUNCH = 0x00000200;
|
|
|
+
|
|
|
+- // TODO(mariakhomenko): Depend directly on the constants once we roll to v8 libraries.
|
|
|
+- private static final String DO_NOT_LAUNCH_EXTRA =
|
|
|
+- "com.google.android.gms.instantapps.DO_NOT_LAUNCH_INSTANT_APP";
|
|
|
+-
|
|
|
+- protected static final String IS_REFERRER_TRUSTED_EXTRA =
|
|
|
+- "com.google.android.gms.instantapps.IS_REFERRER_TRUSTED";
|
|
|
+-
|
|
|
+- protected static final String IS_USER_CONFIRMED_LAUNCH_EXTRA =
|
|
|
+- "com.google.android.gms.instantapps.IS_USER_CONFIRMED_LAUNCH";
|
|
|
+-
|
|
|
+- protected static final String TRUSTED_REFERRER_PKG_EXTRA =
|
|
|
+- "com.google.android.gms.instantapps.TRUSTED_REFERRER_PKG";
|
|
|
+-
|
|
|
+ public static final String IS_GOOGLE_SEARCH_REFERRER =
|
|
|
+ "com.google.android.gms.instantapps.IS_GOOGLE_SEARCH_REFERRER";
|
|
|
+
|
|
|
+- private static final String BROWSER_LAUNCH_REASON =
|
|
|
+- "com.google.android.gms.instantapps.BROWSER_LAUNCH_REASON";
|
|
|
+-
|
|
|
+- private static final String SUPERVISOR_PKG = "com.google.android.instantapps.supervisor";
|
|
|
+-
|
|
|
+- private static final String[] SUPERVISOR_START_ACTIONS = {
|
|
|
+- "com.google.android.instantapps.START", "com.google.android.instantapps.nmr1.INSTALL",
|
|
|
+- "com.google.android.instantapps.nmr1.VIEW"};
|
|
|
+-
|
|
|
+ /** Finch experiment name. */
|
|
|
+ private static final String INSTANT_APPS_EXPERIMENT_NAME = "InstantApps";
|
|
|
+
|
|
|
+@@ -93,14 +71,6 @@ public class InstantAppsHandler {
|
|
|
+ * @return Whether the given intent is going to open an Instant App.
|
|
|
+ */
|
|
|
+ public static boolean isIntentToInstantApp(Intent intent) {
|
|
|
+- if (SUPERVISOR_PKG.equals(intent.getPackage())) return true;
|
|
|
+-
|
|
|
+- String intentAction = intent.getAction();
|
|
|
+- for (String action : SUPERVISOR_START_ACTIONS) {
|
|
|
+- if (action.equals(intentAction)) {
|
|
|
+- return true;
|
|
|
+- }
|
|
|
+- }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -135,20 +105,6 @@ public class InstantAppsHandler {
|
|
|
+ * @param intent The current intent.
|
|
|
+ */
|
|
|
+ private void maybeRecordFallbackStats(Intent intent) {
|
|
|
+- Long startTime = IntentUtils.safeGetLongExtra(intent, INSTANT_APP_START_TIME_EXTRA, 0);
|
|
|
+- if (startTime > 0) {
|
|
|
+- RecordHistogram.recordTimesHistogram("Android.InstantApps.FallbackDuration",
|
|
|
+- SystemClock.elapsedRealtime() - startTime);
|
|
|
+- intent.removeExtra(INSTANT_APP_START_TIME_EXTRA);
|
|
|
+- }
|
|
|
+- int callSource = IntentUtils.safeGetIntExtra(intent, BROWSER_LAUNCH_REASON, 0);
|
|
|
+- if (callSource > 0 && callSource < SOURCE_BOUNDARY) {
|
|
|
+- RecordHistogram.recordEnumeratedHistogram(
|
|
|
+- "Android.InstantApps.CallSource", callSource, SOURCE_BOUNDARY);
|
|
|
+- intent.removeExtra(BROWSER_LAUNCH_REASON);
|
|
|
+- } else if (callSource >= SOURCE_BOUNDARY) {
|
|
|
+- Log.e(TAG, "Unexpected call source constant for Instant Apps: " + callSource);
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -183,14 +139,6 @@ public class InstantAppsHandler {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IntentUtils.safeGetBooleanExtra(intent, DO_NOT_LAUNCH_EXTRA, false)
|
|
|
+- || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
|
|
+- && (intent.getFlags() & FLAG_DO_NOT_LAUNCH) != 0)) {
|
|
|
+- maybeRecordFallbackStats(intent);
|
|
|
+- Log.i(TAG, "Not handling with Instant Apps (DO_NOT_LAUNCH_EXTRA)");
|
|
|
+- return false;
|
|
|
+- }
|
|
|
+-
|
|
|
+ if (IntentUtils.safeGetBooleanExtra(
|
|
|
+ intent, IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, false)
|
|
|
+ || IntentUtils.safeHasExtra(intent, ShortcutHelper.EXTRA_SOURCE)
|
|
|
+@@ -215,7 +163,6 @@ public class InstantAppsHandler {
|
|
|
+ }
|
|
|
+
|
|
|
+ Intent callbackIntent = new Intent(intent);
|
|
|
+- callbackIntent.putExtra(DO_NOT_LAUNCH_EXTRA, true);
|
|
|
+ callbackIntent.putExtra(INSTANT_APP_START_TIME_EXTRA, startTime);
|
|
|
+
|
|
|
+ return tryLaunchingInstantApp(context, intent, isCustomTabsIntent, callbackIntent);
|
|
|
+@@ -318,12 +265,9 @@ public class InstantAppsHandler {
|
|
|
+ Intent iaIntent = data.getIntent();
|
|
|
+ if (data.getReferrer() != null) {
|
|
|
+ iaIntent.putExtra(Intent.EXTRA_REFERRER, data.getReferrer());
|
|
|
+- iaIntent.putExtra(IS_REFERRER_TRUSTED_EXTRA, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ Context appContext = ContextUtils.getApplicationContext();
|
|
|
+- iaIntent.putExtra(TRUSTED_REFERRER_PKG_EXTRA, appContext.getPackageName());
|
|
|
+- iaIntent.putExtra(IS_USER_CONFIRMED_LAUNCH_EXTRA, true);
|
|
|
+
|
|
|
+ try {
|
|
|
+ appContext.startActivity(iaIntent);
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java
|
|
|
+@@ -8,11 +8,6 @@ import android.content.Context;
|
|
|
+ import android.preference.PreferenceManager;
|
|
|
+ import android.text.TextUtils;
|
|
|
+
|
|
|
+-import com.google.android.play.core.splitcompat.SplitCompat;
|
|
|
+-import com.google.android.play.core.splitinstall.SplitInstallManager;
|
|
|
+-import com.google.android.play.core.splitinstall.SplitInstallManagerFactory;
|
|
|
+-import com.google.android.play.core.splitinstall.SplitInstallRequest;
|
|
|
+-
|
|
|
+ import org.chromium.base.BundleUtils;
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+@@ -81,31 +76,12 @@ public class AppLocaleUtils {
|
|
|
+ * @param context Activity context to enable downloaded language splits on.
|
|
|
+ */
|
|
|
+ public static void maybeInstallActivitySplitCompat(Context context) {
|
|
|
+- if (GlobalAppLocaleController.getInstance().isOverridden() && BundleUtils.isBundle()) {
|
|
|
+- Log.i(TAG, "maybeInstallActivitySplit isOverridden: %s isBundle: %s",
|
|
|
+- GlobalAppLocaleController.getInstance().isOverridden(), BundleUtils.isBundle());
|
|
|
+- Log.i(TAG, "Override Locale: %s", getAppLanguagePref());
|
|
|
+- logInstalledLanguages(context);
|
|
|
+- SplitCompat.installActivity(context);
|
|
|
+- logInstalledLanguages(context);
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * For bundle builds ensure that the language split for languageName is downloaded.
|
|
|
+ */
|
|
|
+ private static void ensureLanguageSplitInstalled(String languageName) {
|
|
|
+- SplitInstallManager splitInstallManager =
|
|
|
+- SplitInstallManagerFactory.create(ContextUtils.getApplicationContext());
|
|
|
+-
|
|
|
+- // TODO(perrier): check if languageName is already installed. https://crbug.com/1103806
|
|
|
+- if (!TextUtils.equals(languageName, SYSTEM_LANGUAGE_VALUE)) {
|
|
|
+- SplitInstallRequest installRequest =
|
|
|
+- SplitInstallRequest.newBuilder()
|
|
|
+- .addLanguage(Locale.forLanguageTag(languageName))
|
|
|
+- .build();
|
|
|
+- splitInstallManager.startInstall(installRequest);
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -113,12 +89,6 @@ public class AppLocaleUtils {
|
|
|
+ * @param context Context to log installed languages on.
|
|
|
+ */
|
|
|
+ private static void logInstalledLanguages(Context context) {
|
|
|
+- if (BundleUtils.isBundle()) {
|
|
|
+- SplitInstallManager splitInstallManager = SplitInstallManagerFactory.create(context);
|
|
|
+- Log.i(TAG, "Installed Languages: %s",
|
|
|
+- TextUtils.join(", ", splitInstallManager.getInstalledLanguages()));
|
|
|
+- } else {
|
|
|
+- Log.i(TAG, "Installed Languages: None - not a bundle");
|
|
|
+- }
|
|
|
++ Log.i(TAG, "Installed Languages: None - feature disabled");
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/UpdateStatusProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/UpdateStatusProvider.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/omaha/UpdateStatusProvider.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/UpdateStatusProvider.java
|
|
|
+@@ -19,8 +19,6 @@ import androidx.annotation.NonNull;
|
|
|
+ import androidx.annotation.Nullable;
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.GooglePlayServicesUtil;
|
|
|
+-
|
|
|
+ import org.chromium.base.ActivityState;
|
|
|
+ import org.chromium.base.ApplicationStatus;
|
|
|
+ import org.chromium.base.ApplicationStatus.ActivityStateListener;
|
|
|
+@@ -456,13 +454,7 @@ public class UpdateStatusProvider implements ActivityStateListener {
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isGooglePlayStoreAvailable(Context context) {
|
|
|
+- try {
|
|
|
+- context.getPackageManager().getPackageInfo(
|
|
|
+- GooglePlayServicesUtil.GOOGLE_PLAY_STORE_PACKAGE, 0);
|
|
|
+- } catch (PackageManager.NameNotFoundException e) {
|
|
|
+- return false;
|
|
|
+- }
|
|
|
+- return true;
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private long getSize(StatFs statFs) {
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/FakeAppUpdateManagerWrapper.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/FakeAppUpdateManagerWrapper.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/FakeAppUpdateManagerWrapper.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/FakeAppUpdateManagerWrapper.java
|
|
|
+@@ -11,11 +11,6 @@ import android.os.Message;
|
|
|
+
|
|
|
+ import androidx.annotation.IntDef;
|
|
|
+
|
|
|
+-import com.google.android.play.core.appupdate.AppUpdateInfo;
|
|
|
+-import com.google.android.play.core.appupdate.testing.FakeAppUpdateManager;
|
|
|
+-import com.google.android.play.core.install.model.AppUpdateType;
|
|
|
+-import com.google.android.play.core.tasks.Task;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.task.PostTask;
|
|
|
+ import org.chromium.chrome.browser.app.ChromeActivity;
|
|
|
+@@ -31,7 +26,7 @@ import java.lang.ref.WeakReference;
|
|
|
+ * wrapper isn't meant to be used for a full integration test, but simulating all of the possible
|
|
|
+ * error cases is a bit easier to do here.
|
|
|
+ */
|
|
|
+-public class FakeAppUpdateManagerWrapper extends FakeAppUpdateManager {
|
|
|
++public class FakeAppUpdateManagerWrapper {
|
|
|
+ private static final int RESULT_IN_APP_UPDATE_FAILED = 1;
|
|
|
+ private static final int STEP_DELAY_MS = 5000;
|
|
|
+ private static final int TOAST_DURATION_MS = 2000;
|
|
|
+@@ -108,15 +103,12 @@ public class FakeAppUpdateManagerWrapper extends FakeAppUpdateManager {
|
|
|
+ switch (event) {
|
|
|
+ case Event.UPDATE_AVAILABLE:
|
|
|
+ w.toast("Making app update available.");
|
|
|
+- w.setUpdateAvailable(10000 /* Figure out a better version? */);
|
|
|
+ return;
|
|
|
+ case Event.USER_ACCEPTS_UPDATE:
|
|
|
+ w.toast("User accepts update.");
|
|
|
+- w.userAcceptsUpdate();
|
|
|
+ return;
|
|
|
+ case Event.USER_REJECTS_UPDATE:
|
|
|
+ w.toast("User rejects update.");
|
|
|
+- w.userRejectsUpdate();
|
|
|
+ return;
|
|
|
+ case Event.TRIGGER_DOWNLOAD:
|
|
|
+ w.toast("Triggering download.");
|
|
|
+@@ -124,27 +116,21 @@ public class FakeAppUpdateManagerWrapper extends FakeAppUpdateManager {
|
|
|
+ return;
|
|
|
+ case Event.DOWNLOAD_STARTS:
|
|
|
+ w.toast("Download has started.");
|
|
|
+- w.downloadStarts();
|
|
|
+ return;
|
|
|
+ case Event.DOWNLOAD_FAILS:
|
|
|
+ w.toast("Triggering download failure.");
|
|
|
+- w.downloadFails();
|
|
|
+ return;
|
|
|
+ case Event.USER_CANCELS_DOWNLOAD:
|
|
|
+ w.toast("Triggering cancellation of download.");
|
|
|
+- w.userCancelsDownload();
|
|
|
+ return;
|
|
|
+ case Event.DOWNLOAD_COMPLETES:
|
|
|
+ w.toast("Download completes.");
|
|
|
+- w.downloadCompletes();
|
|
|
+ return;
|
|
|
+ case Event.INSTALL_FAILS:
|
|
|
+ w.toast("Triggering install failure.");
|
|
|
+- w.installFails();
|
|
|
+ return;
|
|
|
+ case Event.INSTALL_COMPLETES:
|
|
|
+ w.toast("Triggering install completion.");
|
|
|
+- w.installCompletes();
|
|
|
+ return;
|
|
|
+ default:
|
|
|
+ w.toast("Unknown event.");
|
|
|
+@@ -159,56 +145,12 @@ public class FakeAppUpdateManagerWrapper extends FakeAppUpdateManager {
|
|
|
+ * @param endState at which point should the inline update flow end.
|
|
|
+ */
|
|
|
+ FakeAppUpdateManagerWrapper(@Type int endState) {
|
|
|
+- super(ContextUtils.getApplicationContext());
|
|
|
+ mType = endState;
|
|
|
+ mEventHandler = new EventHandler(this);
|
|
|
+
|
|
|
+ if (mType != Type.NONE) execute(Event.UPDATE_AVAILABLE);
|
|
|
+ }
|
|
|
+
|
|
|
+- // FakeAppUpdateManager implementation.
|
|
|
+- @Override
|
|
|
+- public boolean startUpdateFlowForResult(AppUpdateInfo appUpdateInfo,
|
|
|
+- @AppUpdateType int appUpdateType, Activity activity, int requestCode) {
|
|
|
+- toast("Starting update flow.");
|
|
|
+- // TODO(dtrainor): Simulate exceptions being thrown or returning false from the super call.
|
|
|
+- boolean success =
|
|
|
+- super.startUpdateFlowForResult(appUpdateInfo, appUpdateType, activity, requestCode);
|
|
|
+- if (!success) return false;
|
|
|
+-
|
|
|
+- assert activity instanceof ChromeActivity : "Unexpected triggering activity.";
|
|
|
+-
|
|
|
+- final int resultCode;
|
|
|
+- if (mType == Type.FAIL_DIALOG_CANCEL) {
|
|
|
+- resultCode = Activity.RESULT_CANCELED;
|
|
|
+- } else if (mType == Type.FAIL_DIALOG_UPDATE_FAILED) {
|
|
|
+- resultCode = RESULT_IN_APP_UPDATE_FAILED;
|
|
|
+- } else {
|
|
|
+- resultCode = Activity.RESULT_OK;
|
|
|
+- }
|
|
|
+-
|
|
|
+- PostTask.postDelayedTask(UiThreadTaskTraits.DEFAULT, () -> {
|
|
|
+- triggerDialogResponse((ChromeActivity) activity, requestCode, resultCode);
|
|
|
+- }, STEP_DELAY_MS);
|
|
|
+-
|
|
|
+- return true;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public Task<Void> completeUpdate() {
|
|
|
+- toast("Completing update.");
|
|
|
+- Task<Void> result = super.completeUpdate();
|
|
|
+-
|
|
|
+- if (mType == Type.FAIL_INSTALL) {
|
|
|
+- postDelayedEvent(Event.INSTALL_FAILS);
|
|
|
+- } else {
|
|
|
+- postDelayedEvent(Event.INSTALL_COMPLETES);
|
|
|
+- // This doesn't actually restart Chrome in this case.
|
|
|
+- }
|
|
|
+-
|
|
|
+- return result;
|
|
|
+- }
|
|
|
+-
|
|
|
+ private void triggerDialogResponse(ChromeActivity activity, int requestCode, int resultCode) {
|
|
|
+ if (resultCode == Activity.RESULT_OK) {
|
|
|
+ execute(Event.USER_ACCEPTS_UPDATE);
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/InlineUpdateControllerFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/InlineUpdateControllerFactory.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/InlineUpdateControllerFactory.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/InlineUpdateControllerFactory.java
|
|
|
+@@ -4,8 +4,6 @@
|
|
|
+
|
|
|
+ package org.chromium.chrome.browser.omaha.inline;
|
|
|
+
|
|
|
+-import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.chrome.browser.flags.ChromeFeatureList;
|
|
|
+ import org.chromium.chrome.browser.omaha.UpdateConfigs;
|
|
|
+@@ -20,20 +18,6 @@ public class InlineUpdateControllerFactory {
|
|
|
+ public static InlineUpdateController create(Runnable callback) {
|
|
|
+ @FakeAppUpdateManagerWrapper.Type
|
|
|
+ int mockInlineEndState = UpdateConfigs.getMockInlineScenarioEndState();
|
|
|
+- if (mockInlineEndState != FakeAppUpdateManagerWrapper.Type.NO_SIMULATION) {
|
|
|
+- // The config requires to run through a test controller, using the
|
|
|
+- // PlayInlineUpdateController, but with a fake Google Play backend that automatically
|
|
|
+- // goes through a scenario flow.
|
|
|
+- return new PlayInlineUpdateController(
|
|
|
+- callback, new FakeAppUpdateManagerWrapper(mockInlineEndState));
|
|
|
+- }
|
|
|
+-
|
|
|
+- if (ChromeFeatureList.isEnabled(ChromeFeatureList.INLINE_UPDATE_FLOW)) {
|
|
|
+- // The application configuration requires to use the real Google Play backend for inline
|
|
|
+- // updates.
|
|
|
+- return new PlayInlineUpdateController(
|
|
|
+- callback, AppUpdateManagerFactory.create(ContextUtils.getApplicationContext()));
|
|
|
+- }
|
|
|
+
|
|
|
+ // No test scenario was in place, and the inline flow has not been enabled, so use a
|
|
|
+ // controller with no functionality.
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/PlayInlineUpdateController.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/PlayInlineUpdateController.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/PlayInlineUpdateController.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/inline/PlayInlineUpdateController.java
|
|
|
+@@ -10,15 +10,6 @@ import android.content.IntentSender.SendIntentException;
|
|
|
+ import androidx.annotation.IntDef;
|
|
|
+ import androidx.annotation.Nullable;
|
|
|
+
|
|
|
+-import com.google.android.play.core.appupdate.AppUpdateInfo;
|
|
|
+-import com.google.android.play.core.appupdate.AppUpdateManager;
|
|
|
+-import com.google.android.play.core.install.InstallState;
|
|
|
+-import com.google.android.play.core.install.InstallStateUpdatedListener;
|
|
|
+-import com.google.android.play.core.install.model.AppUpdateType;
|
|
|
+-import com.google.android.play.core.install.model.InstallErrorCode;
|
|
|
+-import com.google.android.play.core.install.model.InstallStatus;
|
|
|
+-import com.google.android.play.core.install.model.UpdateAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.base.metrics.RecordHistogram;
|
|
|
+ import org.chromium.chrome.browser.omaha.UpdateStatusProvider.UpdateState;
|
|
|
+@@ -32,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
|
|
|
+ * in the foreground.
|
|
|
+ */
|
|
|
+ public class PlayInlineUpdateController
|
|
|
+- implements InlineUpdateController, InstallStateUpdatedListener {
|
|
|
++ implements InlineUpdateController {
|
|
|
+ /**
|
|
|
+ * Converts Play's InstallErrorCode enum to a stable monotomically incrementing Chrome enum.
|
|
|
+ * This is used for metric stability.
|
|
|
+@@ -127,26 +118,9 @@ public class PlayInlineUpdateController
|
|
|
+ private static final int RESULT_IN_APP_UPDATE_FAILED = 1;
|
|
|
+ private static final int REQUEST_CODE = 8123;
|
|
|
+
|
|
|
+- private final Runnable mCallback;
|
|
|
+- private final AppUpdateManager mAppUpdateManager;
|
|
|
+-
|
|
|
+ private boolean mEnabled;
|
|
|
+ private @Nullable @UpdateState Integer mUpdateState;
|
|
|
+
|
|
|
+- private AppUpdateInfo mAppUpdateInfo;
|
|
|
+- private @Nullable @UpdateAvailability Integer mUpdateAvailability;
|
|
|
+- private @Nullable @InstallStatus Integer mInstallStatus;
|
|
|
+-
|
|
|
+- /**
|
|
|
+- * Builds an instance of {@link PlayInlineUpdateController}.
|
|
|
+- * @param callback The {@link Runnable} to notify when an inline update state change occurs.
|
|
|
+- */
|
|
|
+- PlayInlineUpdateController(Runnable callback, AppUpdateManager appUpdateManager) {
|
|
|
+- mCallback = callback;
|
|
|
+- mAppUpdateManager = appUpdateManager;
|
|
|
+- setEnabled(true);
|
|
|
+- }
|
|
|
+-
|
|
|
+ // InlineUpdateController implementation.
|
|
|
+ @Override
|
|
|
+ public void setEnabled(boolean enabled) {
|
|
|
+@@ -155,10 +129,8 @@ public class PlayInlineUpdateController
|
|
|
+
|
|
|
+ if (mEnabled) {
|
|
|
+ mUpdateState = UpdateState.NONE;
|
|
|
+- mAppUpdateManager.registerListener(this);
|
|
|
+ pullCurrentState();
|
|
|
+ } else {
|
|
|
+- mAppUpdateManager.unregisterListener(this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -169,220 +141,26 @@ public class PlayInlineUpdateController
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void startUpdate(Activity activity) {
|
|
|
+- try {
|
|
|
+- boolean success = mAppUpdateManager.startUpdateFlowForResult(
|
|
|
+- mAppUpdateInfo, AppUpdateType.FLEXIBLE, activity, REQUEST_CODE);
|
|
|
+- Log.i(TAG, "startUpdateFlowForResult() returned " + success);
|
|
|
+-
|
|
|
+- if (!success) recordCallFailure(CallFailure.START_FAILED);
|
|
|
+- } catch (SendIntentException exception) {
|
|
|
+- mInstallStatus = InstallStatus.FAILED;
|
|
|
+- Log.i(TAG, "startUpdateFlowForResult() threw an exception.");
|
|
|
+- recordCallFailure(CallFailure.START_EXCEPTION);
|
|
|
+- }
|
|
|
+- // TODO(dtrainor): Use success.
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void completeUpdate() {
|
|
|
+- mAppUpdateManager.completeUpdate()
|
|
|
+- .addOnSuccessListener(unused -> {
|
|
|
+- Log.i(TAG, "completeUpdate() success.");
|
|
|
+- pushStatus();
|
|
|
+- })
|
|
|
+- .addOnFailureListener(exception -> {
|
|
|
+- Log.i(TAG, "completeUpdate() failed.");
|
|
|
+- recordCallFailure(CallFailure.COMPLETE_FAILED);
|
|
|
+- mInstallStatus = InstallStatus.FAILED;
|
|
|
+- pushStatus();
|
|
|
+- });
|
|
|
+- }
|
|
|
+-
|
|
|
+- // InstallStateUpdatedListener implementation.
|
|
|
+- @Override
|
|
|
+- public void onStateUpdate(InstallState state) {
|
|
|
+- Log.i(TAG,
|
|
|
+- "onStateUpdate(" + state.installStatus() + ", " + state.installErrorCode() + ")");
|
|
|
+-
|
|
|
+- if (state.installStatus() != mInstallStatus) {
|
|
|
+- RecordHistogram.recordEnumeratedHistogram("GoogleUpdate.Inline.StateChange.Error."
|
|
|
+- + installStatusToEnumSuffix(state.installStatus()),
|
|
|
+- installErrorCodeToMetrics(state.installErrorCode()),
|
|
|
+- InstallErrorCodeMetrics.NUM_ENTRIES);
|
|
|
+- }
|
|
|
+-
|
|
|
+- mInstallStatus = state.installStatus();
|
|
|
+- pushStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pullCurrentState() {
|
|
|
+- mAppUpdateManager.getAppUpdateInfo()
|
|
|
+- .addOnSuccessListener(info -> {
|
|
|
+- mAppUpdateInfo = info;
|
|
|
+- mUpdateAvailability = info.updateAvailability();
|
|
|
+- mInstallStatus = info.installStatus();
|
|
|
+- Log.i(TAG,
|
|
|
+- "pullCurrentState(" + mUpdateAvailability + ", " + mInstallStatus
|
|
|
+- + ") success.");
|
|
|
+- recordOnAppUpdateInfo(info);
|
|
|
+- pushStatus();
|
|
|
+- })
|
|
|
+- .addOnFailureListener(exception -> {
|
|
|
+- mAppUpdateInfo = null;
|
|
|
+- mUpdateAvailability = UpdateAvailability.UNKNOWN;
|
|
|
+- mInstallStatus = InstallStatus.UNKNOWN;
|
|
|
+- Log.i(TAG, "pullCurrentState() failed.");
|
|
|
+- recordCallFailure(CallFailure.QUERY_FAILED);
|
|
|
+- pushStatus();
|
|
|
+- });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushStatus() {
|
|
|
+- if (!mEnabled || mUpdateAvailability == null || mInstallStatus == null) return;
|
|
|
+-
|
|
|
+- @UpdateState
|
|
|
+- int newState = toUpdateState(mUpdateAvailability, mInstallStatus);
|
|
|
+- if (mUpdateState != null && mUpdateState == newState) return;
|
|
|
+-
|
|
|
+- Log.i(TAG, "Pushing inline update state to " + newState);
|
|
|
+- mUpdateState = newState;
|
|
|
+- mCallback.run();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static @UpdateState int toUpdateState(
|
|
|
+- @UpdateAvailability int updateAvailability, @InstallStatus int installStatus) {
|
|
|
++ int updateAvailability, int installStatus) {
|
|
|
+ @UpdateState
|
|
|
+ int newStatus = UpdateState.NONE;
|
|
|
+
|
|
|
+- // Note, use InstallStatus first then UpdateAvailability if InstallStatus doesn't indicate
|
|
|
+- // a currently active install.
|
|
|
+- switch (installStatus) {
|
|
|
+- case InstallStatus.PENDING:
|
|
|
+- // Intentional fall through.
|
|
|
+- case InstallStatus.DOWNLOADING:
|
|
|
+- newStatus = UpdateState.INLINE_UPDATE_DOWNLOADING;
|
|
|
+- break;
|
|
|
+- case InstallStatus.DOWNLOADED:
|
|
|
+- newStatus = UpdateState.INLINE_UPDATE_READY;
|
|
|
+- break;
|
|
|
+- case InstallStatus.FAILED:
|
|
|
+- newStatus = UpdateState.INLINE_UPDATE_FAILED;
|
|
|
+- break;
|
|
|
+- }
|
|
|
+-
|
|
|
+- if (newStatus == UpdateState.NONE) {
|
|
|
+- switch (updateAvailability) {
|
|
|
+- case UpdateAvailability.UPDATE_AVAILABLE:
|
|
|
+- newStatus = UpdateState.INLINE_UPDATE_AVAILABLE;
|
|
|
+- break;
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+ return newStatus;
|
|
|
+ }
|
|
|
+
|
|
|
+- private static String installStatusToEnumSuffix(@InstallStatus int status) {
|
|
|
+- switch (status) {
|
|
|
+- case InstallStatus.UNKNOWN:
|
|
|
+- return "Unknown";
|
|
|
+- case InstallStatus.REQUIRES_UI_INTENT:
|
|
|
+- return "RequiresUiIntent";
|
|
|
+- case InstallStatus.PENDING:
|
|
|
+- return "Pending";
|
|
|
+- case InstallStatus.DOWNLOADING:
|
|
|
+- return "Downloading";
|
|
|
+- case InstallStatus.DOWNLOADED:
|
|
|
+- return "Downloaded";
|
|
|
+- case InstallStatus.INSTALLING:
|
|
|
+- return "Installing";
|
|
|
+- case InstallStatus.INSTALLED:
|
|
|
+- return "Installed";
|
|
|
+- case InstallStatus.FAILED:
|
|
|
+- return "Failed";
|
|
|
+- case InstallStatus.CANCELED:
|
|
|
+- return "Canceled";
|
|
|
+- default:
|
|
|
+- return "Untracked";
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static @InstallErrorCodeMetrics int installErrorCodeToMetrics(
|
|
|
+- @InstallErrorCode int error) {
|
|
|
+- switch (error) {
|
|
|
+- case InstallErrorCode.NO_ERROR:
|
|
|
+- return InstallErrorCodeMetrics.NO_ERROR;
|
|
|
+- case InstallErrorCode.NO_ERROR_PARTIALLY_ALLOWED:
|
|
|
+- return InstallErrorCodeMetrics.NO_ERROR_PARTIALLY_ALLOWED;
|
|
|
+- case InstallErrorCode.ERROR_UNKNOWN:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_UNKNOWN;
|
|
|
+- case InstallErrorCode.ERROR_API_NOT_AVAILABLE:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_API_NOT_AVAILABLE;
|
|
|
+- case InstallErrorCode.ERROR_INVALID_REQUEST:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_INVALID_REQUEST;
|
|
|
+- case InstallErrorCode.ERROR_INSTALL_UNAVAILABLE:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_INSTALL_UNAVAILABLE;
|
|
|
+- case InstallErrorCode.ERROR_INSTALL_NOT_ALLOWED:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_INSTALL_NOT_ALLOWED;
|
|
|
+- case InstallErrorCode.ERROR_DOWNLOAD_NOT_PRESENT:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_DOWNLOAD_NOT_PRESENT;
|
|
|
+- case InstallErrorCode.ERROR_INTERNAL_ERROR:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_INTERNAL_ERROR;
|
|
|
+- default:
|
|
|
+- return InstallErrorCodeMetrics.ERROR_UNTRACKED;
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static @UpdateAvailabilityMetric int updateAvailabilityToMetrics(
|
|
|
+- @UpdateAvailability int updateAvailability) {
|
|
|
+- switch (updateAvailability) {
|
|
|
+- case UpdateAvailability.UNKNOWN:
|
|
|
+- return UpdateAvailabilityMetric.UNKNOWN;
|
|
|
+- case UpdateAvailability.UPDATE_NOT_AVAILABLE:
|
|
|
+- return UpdateAvailabilityMetric.UPDATE_NOT_AVAILABLE;
|
|
|
+- case UpdateAvailability.UPDATE_AVAILABLE:
|
|
|
+- return UpdateAvailabilityMetric.UPDATE_AVAILABLE;
|
|
|
+- case UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS:
|
|
|
+- return UpdateAvailabilityMetric.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS;
|
|
|
+- default:
|
|
|
+- return UpdateAvailabilityMetric.UNTRACKED;
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static @InstallStatusMetric int installStatusToMetrics(
|
|
|
+- @InstallStatus int installStatus) {
|
|
|
+- switch (installStatus) {
|
|
|
+- case InstallStatus.UNKNOWN:
|
|
|
+- return InstallStatusMetric.UNKNOWN;
|
|
|
+- case InstallStatus.REQUIRES_UI_INTENT:
|
|
|
+- return InstallStatusMetric.REQUIRES_UI_INTENT;
|
|
|
+- case InstallStatus.PENDING:
|
|
|
+- return InstallStatusMetric.PENDING;
|
|
|
+- case InstallStatus.DOWNLOADING:
|
|
|
+- return InstallStatusMetric.DOWNLOADING;
|
|
|
+- case InstallStatus.DOWNLOADED:
|
|
|
+- return InstallStatusMetric.DOWNLOADED;
|
|
|
+- case InstallStatus.INSTALLING:
|
|
|
+- return InstallStatusMetric.INSTALLING;
|
|
|
+- case InstallStatus.INSTALLED:
|
|
|
+- return InstallStatusMetric.INSTALLED;
|
|
|
+- case InstallStatus.FAILED:
|
|
|
+- return InstallStatusMetric.FAILED;
|
|
|
+- case InstallStatus.CANCELED:
|
|
|
+- return InstallStatusMetric.CANCELED;
|
|
|
+- default:
|
|
|
+- return InstallStatusMetric.UNTRACKED;
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static void recordOnAppUpdateInfo(AppUpdateInfo info) {
|
|
|
+- RecordHistogram.recordEnumeratedHistogram(
|
|
|
+- "GoogleUpdate.Inline.AppUpdateInfo.UpdateAvailability",
|
|
|
+- updateAvailabilityToMetrics(info.updateAvailability()),
|
|
|
+- UpdateAvailabilityMetric.NUM_ENTRIES);
|
|
|
+- RecordHistogram.recordEnumeratedHistogram("GoogleUpdate.Inline.AppUpdateInfo.InstallStatus",
|
|
|
+- installStatusToMetrics(info.installStatus()), InstallStatusMetric.NUM_ENTRIES);
|
|
|
+- }
|
|
|
+-
|
|
|
+ private static void recordCallFailure(@CallFailure int failure) {
|
|
|
+ RecordHistogram.recordEnumeratedHistogram(
|
|
|
+ "GoogleUpdate.Inline.CallFailure", failure, CallFailure.NUM_ENTRIES);
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java
|
|
|
+@@ -40,7 +40,6 @@ import org.chromium.chrome.browser.preferences.Pref;
|
|
|
+ import org.chromium.chrome.browser.profiles.Profile;
|
|
|
+ import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate;
|
|
|
+ import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
|
|
|
+-import org.chromium.chrome.browser.webauthn.CableAuthenticatorModuleProvider;
|
|
|
+ import org.chromium.components.browser_ui.settings.ChromeBasePreference;
|
|
|
+ import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
|
|
|
+ import org.chromium.components.browser_ui.settings.SearchUtils;
|
|
|
+@@ -559,19 +558,6 @@ public class PasswordSettings
|
|
|
+ }
|
|
|
+
|
|
|
+ private void displaySecurityKeyLink() {
|
|
|
+- if (mSecurityKey == null) {
|
|
|
+- mSecurityKey = new ChromeBasePreference(getStyledContext());
|
|
|
+- mSecurityKey.setKey(PREF_KEY_SECURITY_KEY_LINK);
|
|
|
+- mSecurityKey.setTitle(R.string.phone_as_security_key_text);
|
|
|
+- mSecurityKey.setOnPreferenceClickListener(preference -> {
|
|
|
+- SettingsLauncher settingsLauncher = new SettingsLauncherImpl();
|
|
|
+- settingsLauncher.launchSettingsActivity(
|
|
|
+- getActivity(), CableAuthenticatorModuleProvider.class, null);
|
|
|
+- return true;
|
|
|
+- });
|
|
|
+- mSecurityKey.setOrder(ORDER_SECURITY_KEY);
|
|
|
+- }
|
|
|
+- getPreferenceScreen().addPreference(mSecurityKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Context getStyledContext() {
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GCMBackgroundTask.java b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GCMBackgroundTask.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GCMBackgroundTask.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GCMBackgroundTask.java
|
|
|
+@@ -42,7 +42,6 @@ public class GCMBackgroundTask implements BackgroundTask {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+- ChromeGcmListenerServiceImpl.dispatchMessageToDriver(message);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java
|
|
|
+--- a/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java
|
|
|
++++ b/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java
|
|
|
+@@ -102,14 +102,7 @@ public class AuthenticatorImpl extends HandlerResponseCallback implements Authen
|
|
|
+
|
|
|
+ mMakeCredentialCallback = callback;
|
|
|
+ Context context = ContextUtils.getApplicationContext();
|
|
|
+- if (PackageUtils.getPackageVersion(context, GMSCORE_PACKAGE_NAME)
|
|
|
+- < Fido2ApiHandler.GMSCORE_MIN_VERSION) {
|
|
|
+- onError(AuthenticatorStatus.NOT_IMPLEMENTED);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- mIsOperationPending = true;
|
|
|
+- Fido2ApiHandler.getInstance().makeCredential(options, mRenderFrameHost, mOrigin, this);
|
|
|
++ onError(AuthenticatorStatus.NOT_IMPLEMENTED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -137,14 +130,7 @@ public class AuthenticatorImpl extends HandlerResponseCallback implements Authen
|
|
|
+ mGetAssertionCallback = callback;
|
|
|
+ Context context = ContextUtils.getApplicationContext();
|
|
|
+
|
|
|
+- if (PackageUtils.getPackageVersion(context, GMSCORE_PACKAGE_NAME)
|
|
|
+- < Fido2ApiHandler.GMSCORE_MIN_VERSION) {
|
|
|
+- onError(AuthenticatorStatus.NOT_IMPLEMENTED);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- mIsOperationPending = true;
|
|
|
+- Fido2ApiHandler.getInstance().getAssertion(options, mRenderFrameHost, mOrigin, this);
|
|
|
++ onError(AuthenticatorStatus.NOT_IMPLEMENTED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -177,15 +163,8 @@ public class AuthenticatorImpl extends HandlerResponseCallback implements Authen
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+- if (PackageUtils.getPackageVersion(context, GMSCORE_PACKAGE_NAME)
|
|
|
+- < Fido2ApiHandler.GMSCORE_MIN_VERSION) {
|
|
|
+- callback.call(false);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- mIsUserVerifyingPlatformAuthenticatorAvailableCallbackQueue.add(callback);
|
|
|
+- Fido2ApiHandler.getInstance().isUserVerifyingPlatformAuthenticatorAvailable(
|
|
|
+- mRenderFrameHost, this);
|
|
|
++ callback.call(false);
|
|
|
++ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/chrome/android/modules/chrome_feature_modules.gni b/chrome/android/modules/chrome_feature_modules.gni
|
|
|
+--- a/chrome/android/modules/chrome_feature_modules.gni
|
|
|
++++ b/chrome/android/modules/chrome_feature_modules.gni
|
|
|
+@@ -8,8 +8,6 @@ import(
|
|
|
+ import("//chrome/android/features/dev_ui/dev_ui_module.gni")
|
|
|
+ import("//chrome/android/features/tab_ui/tab_ui_module.gni")
|
|
|
+ import("//chrome/android/modules/buildflags.gni")
|
|
|
+-import(
|
|
|
+- "//chrome/android/modules/cablev2_authenticator/cablev2_authenticator_module.gni")
|
|
|
+ import("//chrome/android/modules/extra_icu/extra_icu_module.gni")
|
|
|
+ import("//chrome/android/modules/stack_unwinder/stack_unwinder_module.gni")
|
|
|
+ import("//chrome/android/modules/test_dummy/test_dummy_module.gni")
|
|
|
+@@ -63,7 +61,6 @@ if (false) { # AR DFM is currently disabled
|
|
|
+ if (!disable_tab_ui_dfm) {
|
|
|
+ monochrome_module_descs += [ tab_ui_module_desc ]
|
|
|
+ }
|
|
|
+-monochrome_module_descs += [ cablev2_authenticator_module_desc ]
|
|
|
+
|
|
|
+ # Modules shipped in Trichrome (Android Q+).
|
|
|
+ trichrome_module_descs = monochrome_module_descs
|
|
|
+diff --git a/chrome/browser/signin/services/android/BUILD.gn b/chrome/browser/signin/services/android/BUILD.gn
|
|
|
+--- a/chrome/browser/signin/services/android/BUILD.gn
|
|
|
++++ b/chrome/browser/signin/services/android/BUILD.gn
|
|
|
+@@ -27,7 +27,6 @@ android_library("java") {
|
|
|
+ ]
|
|
|
+ deps = [
|
|
|
+ ":java_resources",
|
|
|
+- "$google_play_services_package:google_play_services_auth_base_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//chrome/browser/preferences:java",
|
|
|
+diff --git a/chrome/test/android/BUILD.gn b/chrome/test/android/BUILD.gn
|
|
|
+--- a/chrome/test/android/BUILD.gn
|
|
|
++++ b/chrome/test/android/BUILD.gn
|
|
|
+@@ -260,8 +260,6 @@ android_library("chrome_java_test_support") {
|
|
|
+ ]
|
|
|
+
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//chrome/android:base_module_java",
|
|
|
+diff --git a/components/background_task_scheduler/BUILD.gn b/components/background_task_scheduler/BUILD.gn
|
|
|
+--- a/components/background_task_scheduler/BUILD.gn
|
|
|
++++ b/components/background_task_scheduler/BUILD.gn
|
|
|
+@@ -104,7 +104,6 @@ if (is_android) {
|
|
|
+ bypass_platform_checks = true
|
|
|
+ testonly = true
|
|
|
+ sources = [
|
|
|
+- "internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskGcmTaskServiceTest.java",
|
|
|
+ "internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskJobServiceTest.java",
|
|
|
+ "internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerAlarmManagerTest.java",
|
|
|
+ "internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerGcmNetworkManagerTest.java",
|
|
|
+@@ -121,11 +120,6 @@ if (is_android) {
|
|
|
+
|
|
|
+ deps = [
|
|
|
+ ":background_task_scheduler_task_ids_java",
|
|
|
+- "$google_play_services_package:google_play_services_auth_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_gcm_java",
|
|
|
+- "$google_play_services_package:google_play_services_tasks_java",
|
|
|
+ "internal:internal_java",
|
|
|
+ "internal:proto_java",
|
|
|
+ "//base:base_java",
|
|
|
+diff --git a/components/background_task_scheduler/internal/BUILD.gn b/components/background_task_scheduler/internal/BUILD.gn
|
|
|
+--- a/components/background_task_scheduler/internal/BUILD.gn
|
|
|
++++ b/components/background_task_scheduler/internal/BUILD.gn
|
|
|
+@@ -11,12 +11,10 @@ if (is_android) {
|
|
|
+ android_library("internal_java") {
|
|
|
+ sources = [
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskBroadcastReceiver.java",
|
|
|
+- "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskGcmTaskService.java",
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskJobService.java",
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerAlarmManager.java",
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerDelegate.java",
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerFactoryInternal.java",
|
|
|
+- "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerGcmNetworkManager.java",
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerImpl.java",
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerJobService.java",
|
|
|
+ "android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerPrefs.java",
|
|
|
+@@ -27,10 +25,6 @@ if (is_android) {
|
|
|
+
|
|
|
+ deps = [
|
|
|
+ ":proto_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_gcm_java",
|
|
|
+- "$google_play_services_package:google_play_services_tasks_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//components/background_task_scheduler:background_task_scheduler_task_ids_java",
|
|
|
+ "//components/background_task_scheduler:public_java",
|
|
|
+@@ -99,10 +93,6 @@ if (is_android) {
|
|
|
+
|
|
|
+ deps = [
|
|
|
+ ":internal_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_gcm_java",
|
|
|
+- "$google_play_services_package:google_play_services_tasks_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//components/background_task_scheduler:background_task_scheduler_task_ids_java",
|
|
|
+diff --git a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskGcmTaskService.java b/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskGcmTaskService.java
|
|
|
+deleted file mode 100644
|
|
|
+--- a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskGcmTaskService.java
|
|
|
++++ /dev/null
|
|
|
+@@ -1,160 +0,0 @@
|
|
|
+-// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
|
+-// Use of this source code is governed by a BSD-style license that can be
|
|
|
+-// found in the LICENSE file.
|
|
|
+-
|
|
|
+-package org.chromium.components.background_task_scheduler.internal;
|
|
|
+-
|
|
|
+-import android.os.Build;
|
|
|
+-
|
|
|
+-import androidx.annotation.VisibleForTesting;
|
|
|
+-
|
|
|
+-import com.google.android.gms.gcm.GcmNetworkManager;
|
|
|
+-import com.google.android.gms.gcm.GcmTaskService;
|
|
|
+-import com.google.android.gms.gcm.TaskParams;
|
|
|
+-
|
|
|
+-import org.chromium.base.ContextUtils;
|
|
|
+-import org.chromium.base.Log;
|
|
|
+-import org.chromium.base.ThreadUtils;
|
|
|
+-import org.chromium.components.background_task_scheduler.BackgroundTask;
|
|
|
+-import org.chromium.components.background_task_scheduler.TaskParameters;
|
|
|
+-
|
|
|
+-import java.util.concurrent.CountDownLatch;
|
|
|
+-import java.util.concurrent.TimeUnit;
|
|
|
+-import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
+-
|
|
|
+-/** Delegates calls out to various tasks that need to run in the background. */
|
|
|
+-public class BackgroundTaskGcmTaskService extends GcmTaskService {
|
|
|
+- private static final String TAG = "BkgrdTaskGcmTS";
|
|
|
+-
|
|
|
+- private BackgroundTaskSchedulerGcmNetworkManager.Clock mClock = System::currentTimeMillis;
|
|
|
+-
|
|
|
+- @VisibleForTesting
|
|
|
+- void setClockForTesting(BackgroundTaskSchedulerGcmNetworkManager.Clock clock) {
|
|
|
+- mClock = clock;
|
|
|
+- }
|
|
|
+-
|
|
|
+- /** Class that waits for the processing to be done. */
|
|
|
+- private static class Waiter {
|
|
|
+- // Wakelock is only held for 3 minutes by default for GcmTaskService.
|
|
|
+- private static final long MAX_TIMEOUT_SECONDS = 179;
|
|
|
+- private final CountDownLatch mLatch;
|
|
|
+- private long mWaiterTimeoutSeconds;
|
|
|
+- private boolean mIsRescheduleNeeded;
|
|
|
+- private boolean mHasTaskTimedOut;
|
|
|
+-
|
|
|
+- public Waiter(long waiterTimeoutSeconds) {
|
|
|
+- mLatch = new CountDownLatch(1);
|
|
|
+- mWaiterTimeoutSeconds = Math.min(waiterTimeoutSeconds, MAX_TIMEOUT_SECONDS);
|
|
|
+- }
|
|
|
+-
|
|
|
+- /** Start waiting for the processing to finish. */
|
|
|
+- public void startWaiting() {
|
|
|
+- try {
|
|
|
+- mHasTaskTimedOut = !mLatch.await(mWaiterTimeoutSeconds, TimeUnit.SECONDS);
|
|
|
+- } catch (InterruptedException e) {
|
|
|
+- Log.d(TAG, "Waiter interrupted while waiting.");
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- /** Called to finish waiting. */
|
|
|
+- public void onWaitDone(boolean needsRescheduling) {
|
|
|
+- mIsRescheduleNeeded = needsRescheduling;
|
|
|
+- mLatch.countDown();
|
|
|
+- }
|
|
|
+-
|
|
|
+- /** @return Whether last task timed out. */
|
|
|
+- public boolean hasTaskTimedOut() {
|
|
|
+- return mHasTaskTimedOut;
|
|
|
+- }
|
|
|
+-
|
|
|
+- /** @return Whether task needs to be rescheduled. */
|
|
|
+- public boolean isRescheduleNeeded() {
|
|
|
+- return mIsRescheduleNeeded;
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static class TaskFinishedCallbackGcmTaskService
|
|
|
+- implements BackgroundTask.TaskFinishedCallback {
|
|
|
+- private final Waiter mWaiter;
|
|
|
+-
|
|
|
+- public TaskFinishedCallbackGcmTaskService(Waiter waiter) {
|
|
|
+- mWaiter = waiter;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void taskFinished(final boolean needsReschedule) {
|
|
|
+- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
|
|
+- @Override
|
|
|
+- public void run() {
|
|
|
+- mWaiter.onWaitDone(needsReschedule);
|
|
|
+- }
|
|
|
+- });
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public int onRunTask(TaskParams params) {
|
|
|
+- final TaskParameters taskParams =
|
|
|
+- BackgroundTaskSchedulerGcmNetworkManager.getTaskParametersFromTaskParams(params);
|
|
|
+-
|
|
|
+- final BackgroundTask backgroundTask =
|
|
|
+- BackgroundTaskSchedulerFactoryInternal.getBackgroundTaskFromTaskId(
|
|
|
+- taskParams.getTaskId());
|
|
|
+- if (backgroundTask == null) {
|
|
|
+- Log.w(TAG, "Failed to start task. Could not instantiate BackgroundTask class.");
|
|
|
+- // Cancel task if the BackgroundTask class is not found anymore. We assume this means
|
|
|
+- // that the task has been deprecated.
|
|
|
+- BackgroundTaskSchedulerFactoryInternal.getScheduler().cancel(
|
|
|
+- ContextUtils.getApplicationContext(), taskParams.getTaskId());
|
|
|
+- return GcmNetworkManager.RESULT_FAILURE;
|
|
|
+- }
|
|
|
+-
|
|
|
+- if (BackgroundTaskSchedulerGcmNetworkManager.didTaskExpire(
|
|
|
+- params, mClock.currentTimeMillis())) {
|
|
|
+- BackgroundTaskSchedulerUma.getInstance().reportTaskExpired(taskParams.getTaskId());
|
|
|
+- return GcmNetworkManager.RESULT_FAILURE;
|
|
|
+- }
|
|
|
+-
|
|
|
+- final Waiter waiter = new Waiter(Waiter.MAX_TIMEOUT_SECONDS);
|
|
|
+-
|
|
|
+- final AtomicBoolean taskNeedsBackgroundProcessing = new AtomicBoolean();
|
|
|
+- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
|
|
+- @Override
|
|
|
+- public void run() {
|
|
|
+- BackgroundTaskSchedulerUma.getInstance().reportTaskStarted(taskParams.getTaskId());
|
|
|
+- taskNeedsBackgroundProcessing.set(
|
|
|
+- backgroundTask.onStartTask(ContextUtils.getApplicationContext(), taskParams,
|
|
|
+- new TaskFinishedCallbackGcmTaskService(waiter)));
|
|
|
+- }
|
|
|
+- });
|
|
|
+-
|
|
|
+- if (!taskNeedsBackgroundProcessing.get()) return GcmNetworkManager.RESULT_SUCCESS;
|
|
|
+-
|
|
|
+- waiter.startWaiting();
|
|
|
+-
|
|
|
+- if (waiter.isRescheduleNeeded()) return GcmNetworkManager.RESULT_RESCHEDULE;
|
|
|
+- if (!waiter.hasTaskTimedOut()) return GcmNetworkManager.RESULT_SUCCESS;
|
|
|
+-
|
|
|
+- final AtomicBoolean taskNeedsRescheduling = new AtomicBoolean();
|
|
|
+- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
|
|
+- @Override
|
|
|
+- public void run() {
|
|
|
+- BackgroundTaskSchedulerUma.getInstance().reportTaskStopped(taskParams.getTaskId());
|
|
|
+- taskNeedsRescheduling.set(backgroundTask.onStopTask(
|
|
|
+- ContextUtils.getApplicationContext(), taskParams));
|
|
|
+- }
|
|
|
+- });
|
|
|
+-
|
|
|
+- if (taskNeedsRescheduling.get()) return GcmNetworkManager.RESULT_RESCHEDULE;
|
|
|
+-
|
|
|
+- return GcmNetworkManager.RESULT_SUCCESS;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onInitializeTasks() {
|
|
|
+- // Ignore the event on OSs supporting JobScheduler.
|
|
|
+- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return;
|
|
|
+- BackgroundTaskSchedulerFactoryInternal.getScheduler().reschedule(
|
|
|
+- ContextUtils.getApplicationContext());
|
|
|
+- }
|
|
|
+-}
|
|
|
+diff --git a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerFactoryInternal.java b/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerFactoryInternal.java
|
|
|
+--- a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerFactoryInternal.java
|
|
|
++++ b/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerFactoryInternal.java
|
|
|
+@@ -21,11 +21,7 @@ public final class BackgroundTaskSchedulerFactoryInternal {
|
|
|
+ private static BackgroundTaskFactory sBackgroundTaskFactory;
|
|
|
+
|
|
|
+ static BackgroundTaskSchedulerDelegate getSchedulerDelegateForSdk(int sdkInt) {
|
|
|
+- if (sdkInt >= Build.VERSION_CODES.M) {
|
|
|
+- return new BackgroundTaskSchedulerJobService();
|
|
|
+- } else {
|
|
|
+- return new BackgroundTaskSchedulerGcmNetworkManager();
|
|
|
+- }
|
|
|
++ return new BackgroundTaskSchedulerJobService();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerGcmNetworkManager.java b/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerGcmNetworkManager.java
|
|
|
+deleted file mode 100644
|
|
|
+--- a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerGcmNetworkManager.java
|
|
|
++++ /dev/null
|
|
|
+@@ -1,257 +0,0 @@
|
|
|
+-// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
|
+-// Use of this source code is governed by a BSD-style license that can be
|
|
|
+-// found in the LICENSE file.
|
|
|
+-
|
|
|
+-package org.chromium.components.background_task_scheduler.internal;
|
|
|
+-
|
|
|
+-import android.content.Context;
|
|
|
+-import android.os.Bundle;
|
|
|
+-
|
|
|
+-import androidx.annotation.NonNull;
|
|
|
+-import androidx.annotation.VisibleForTesting;
|
|
|
+-
|
|
|
+-import com.google.android.gms.gcm.GcmNetworkManager;
|
|
|
+-import com.google.android.gms.gcm.OneoffTask;
|
|
|
+-import com.google.android.gms.gcm.PeriodicTask;
|
|
|
+-import com.google.android.gms.gcm.Task;
|
|
|
+-import com.google.android.gms.gcm.TaskParams;
|
|
|
+-
|
|
|
+-import org.chromium.base.Log;
|
|
|
+-import org.chromium.base.ThreadUtils;
|
|
|
+-import org.chromium.components.background_task_scheduler.TaskInfo;
|
|
|
+-import org.chromium.components.background_task_scheduler.TaskParameters;
|
|
|
+-import org.chromium.gms.ChromiumPlayServicesAvailability;
|
|
|
+-
|
|
|
+-import java.util.concurrent.TimeUnit;
|
|
|
+-
|
|
|
+-/**
|
|
|
+- * An implementation of {@link BackgroundTaskSchedulerDelegate} that uses the Play Services
|
|
|
+- * {@link GcmNetworkManager} to schedule jobs.
|
|
|
+- */
|
|
|
+-class BackgroundTaskSchedulerGcmNetworkManager implements BackgroundTaskSchedulerDelegate {
|
|
|
+- private static final String TAG = "BkgrdTaskSchedGcmNM";
|
|
|
+-
|
|
|
+- /** Delta time for expiration checks, after the end time. */
|
|
|
+- static final long DEADLINE_DELTA_MS = 1000;
|
|
|
+-
|
|
|
+- /** Clock to use so we can mock time in tests. */
|
|
|
+- public interface Clock { long currentTimeMillis(); }
|
|
|
+-
|
|
|
+- private static Clock sClock = System::currentTimeMillis;
|
|
|
+-
|
|
|
+- @VisibleForTesting
|
|
|
+- static void setClockForTesting(Clock clock) {
|
|
|
+- sClock = clock;
|
|
|
+- }
|
|
|
+-
|
|
|
+- /**
|
|
|
+- * Checks if a task expired, based on the current time of the service.
|
|
|
+- *
|
|
|
+- * @param taskParams parameters sent to the service, which contain the scheduling information
|
|
|
+- * regarding expiration.
|
|
|
+- * @param currentTimeMs the current time of the service.
|
|
|
+- * @return true if the task expired and false otherwise.
|
|
|
+- */
|
|
|
+- static boolean didTaskExpire(TaskParams taskParams, long currentTimeMs) {
|
|
|
+- Bundle extras = taskParams.getExtras();
|
|
|
+- if (extras == null || !extras.containsKey(BACKGROUND_TASK_SCHEDULE_TIME_KEY)) {
|
|
|
+- return false;
|
|
|
+- }
|
|
|
+-
|
|
|
+- long scheduleTimeMs = extras.getLong(BACKGROUND_TASK_SCHEDULE_TIME_KEY);
|
|
|
+- if (extras.containsKey(BACKGROUND_TASK_END_TIME_KEY)) {
|
|
|
+- long endTimeMs =
|
|
|
+- extras.getLong(BackgroundTaskSchedulerDelegate.BACKGROUND_TASK_END_TIME_KEY);
|
|
|
+- return TaskInfo.OneOffInfo.getExpirationStatus(
|
|
|
+- scheduleTimeMs, endTimeMs, currentTimeMs);
|
|
|
+- } else {
|
|
|
+- long intervalTimeMs = extras.getLong(BACKGROUND_TASK_INTERVAL_TIME_KEY);
|
|
|
+-
|
|
|
+- // If flex is never set, it is given a default value of 10% of the period time, as
|
|
|
+- // per the GcmNetworkManager behaviour. This default value is set in
|
|
|
+- // https://developers.google.com/android/reference/com/google/android/gms/gcm/PeriodicTask.
|
|
|
+- double defaultFlexAsFractionOfInterval = 0.1f;
|
|
|
+-
|
|
|
+- long flexTimeMs = extras.getLong(BACKGROUND_TASK_FLEX_TIME_KEY,
|
|
|
+- /*defaultValue=*/(long) (defaultFlexAsFractionOfInterval * intervalTimeMs));
|
|
|
+-
|
|
|
+- return TaskInfo.PeriodicInfo.getExpirationStatus(
|
|
|
+- scheduleTimeMs, intervalTimeMs, flexTimeMs, currentTimeMs);
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- /**
|
|
|
+- * Retrieves the {@link TaskParameters} from the {@link TaskParams}, which are passed as
|
|
|
+- * one of the keys. Only values valid for {@link android.os.BaseBundle} are supported, and other
|
|
|
+- * values are stripped at the time when the task is scheduled.
|
|
|
+- *
|
|
|
+- * @param taskParams the {@link TaskParams} to extract the {@link TaskParameters} from.
|
|
|
+- * @return the {@link TaskParameters} for the current job.
|
|
|
+- */
|
|
|
+- static TaskParameters getTaskParametersFromTaskParams(@NonNull TaskParams taskParams) {
|
|
|
+- int taskId;
|
|
|
+- try {
|
|
|
+- taskId = Integer.parseInt(taskParams.getTag());
|
|
|
+- } catch (NumberFormatException e) {
|
|
|
+- Log.e(TAG, "Cound not parse task ID from task tag: " + taskParams.getTag());
|
|
|
+- return null;
|
|
|
+- }
|
|
|
+-
|
|
|
+- TaskParameters.Builder builder = TaskParameters.create(taskId);
|
|
|
+-
|
|
|
+- Bundle extras = taskParams.getExtras();
|
|
|
+- Bundle taskExtras = extras.getBundle(BACKGROUND_TASK_EXTRAS_KEY);
|
|
|
+- builder.addExtras(taskExtras);
|
|
|
+-
|
|
|
+- return builder.build();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @VisibleForTesting
|
|
|
+- static Task createTaskFromTaskInfo(@NonNull TaskInfo taskInfo) {
|
|
|
+- Bundle taskExtras = new Bundle();
|
|
|
+- taskExtras.putBundle(BACKGROUND_TASK_EXTRAS_KEY, taskInfo.getExtras());
|
|
|
+-
|
|
|
+- TaskBuilderVisitor taskBuilderVisitor = new TaskBuilderVisitor(taskExtras);
|
|
|
+- taskInfo.getTimingInfo().accept(taskBuilderVisitor);
|
|
|
+- Task.Builder builder = taskBuilderVisitor.getBuilder();
|
|
|
+-
|
|
|
+- builder.setPersisted(taskInfo.isPersisted())
|
|
|
+- .setRequiredNetwork(getGcmNetworkManagerNetworkTypeFromTypeFromTaskNetworkType(
|
|
|
+- taskInfo.getRequiredNetworkType()))
|
|
|
+- .setRequiresCharging(taskInfo.requiresCharging())
|
|
|
+- .setService(BackgroundTaskGcmTaskService.class)
|
|
|
+- .setTag(taskIdToTaskTag(taskInfo.getTaskId()))
|
|
|
+- .setUpdateCurrent(taskInfo.shouldUpdateCurrent());
|
|
|
+-
|
|
|
+- return builder.build();
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static class TaskBuilderVisitor implements TaskInfo.TimingInfoVisitor {
|
|
|
+- private Task.Builder mBuilder;
|
|
|
+- private final Bundle mTaskExtras;
|
|
|
+-
|
|
|
+- TaskBuilderVisitor(Bundle taskExtras) {
|
|
|
+- mTaskExtras = taskExtras;
|
|
|
+- }
|
|
|
+-
|
|
|
+- // Only valid after a TimingInfo object was visited.
|
|
|
+- Task.Builder getBuilder() {
|
|
|
+- return mBuilder;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void visit(TaskInfo.OneOffInfo oneOffInfo) {
|
|
|
+- if (oneOffInfo.expiresAfterWindowEndTime()) {
|
|
|
+- mTaskExtras.putLong(BACKGROUND_TASK_SCHEDULE_TIME_KEY, sClock.currentTimeMillis());
|
|
|
+- mTaskExtras.putLong(BACKGROUND_TASK_END_TIME_KEY, oneOffInfo.getWindowEndTimeMs());
|
|
|
+- }
|
|
|
+-
|
|
|
+- OneoffTask.Builder builder = new OneoffTask.Builder();
|
|
|
+- long windowStartSeconds = oneOffInfo.hasWindowStartTimeConstraint()
|
|
|
+- ? TimeUnit.MILLISECONDS.toSeconds(oneOffInfo.getWindowStartTimeMs())
|
|
|
+- : 0;
|
|
|
+- long windowEndTimeMs = oneOffInfo.getWindowEndTimeMs();
|
|
|
+- if (oneOffInfo.expiresAfterWindowEndTime()) {
|
|
|
+- windowEndTimeMs += DEADLINE_DELTA_MS;
|
|
|
+- }
|
|
|
+- builder.setExecutionWindow(
|
|
|
+- windowStartSeconds, TimeUnit.MILLISECONDS.toSeconds(windowEndTimeMs));
|
|
|
+- builder.setExtras(mTaskExtras);
|
|
|
+- mBuilder = builder;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void visit(TaskInfo.PeriodicInfo periodicInfo) {
|
|
|
+- if (periodicInfo.expiresAfterWindowEndTime()) {
|
|
|
+- mTaskExtras.putLong(BACKGROUND_TASK_SCHEDULE_TIME_KEY, sClock.currentTimeMillis());
|
|
|
+- mTaskExtras.putLong(
|
|
|
+- BACKGROUND_TASK_INTERVAL_TIME_KEY, periodicInfo.getIntervalMs());
|
|
|
+- if (periodicInfo.hasFlex()) {
|
|
|
+- mTaskExtras.putLong(BACKGROUND_TASK_FLEX_TIME_KEY, periodicInfo.getFlexMs());
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- PeriodicTask.Builder builder = new PeriodicTask.Builder();
|
|
|
+- builder.setPeriod(TimeUnit.MILLISECONDS.toSeconds(periodicInfo.getIntervalMs()));
|
|
|
+- if (periodicInfo.hasFlex()) {
|
|
|
+- builder.setFlex(TimeUnit.MILLISECONDS.toSeconds(periodicInfo.getFlexMs()));
|
|
|
+- }
|
|
|
+- builder.setExtras(mTaskExtras);
|
|
|
+- mBuilder = builder;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void visit(TaskInfo.ExactInfo exactInfo) {
|
|
|
+- throw new RuntimeException("Exact tasks should not be scheduled with "
|
|
|
+- + "GcmNetworkManager.");
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static int getGcmNetworkManagerNetworkTypeFromTypeFromTaskNetworkType(
|
|
|
+- @TaskInfo.NetworkType int networkType) {
|
|
|
+- switch (networkType) {
|
|
|
+- // This is correct: GcmNM ANY means no network is guaranteed.
|
|
|
+- case TaskInfo.NetworkType.NONE:
|
|
|
+- return Task.NETWORK_STATE_ANY;
|
|
|
+- case TaskInfo.NetworkType.ANY:
|
|
|
+- return Task.NETWORK_STATE_CONNECTED;
|
|
|
+- case TaskInfo.NetworkType.UNMETERED:
|
|
|
+- return Task.NETWORK_STATE_UNMETERED;
|
|
|
+- default:
|
|
|
+- assert false;
|
|
|
+- }
|
|
|
+- return Task.NETWORK_STATE_ANY;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public boolean schedule(Context context, @NonNull TaskInfo taskInfo) {
|
|
|
+- ThreadUtils.assertOnUiThread();
|
|
|
+-
|
|
|
+- GcmNetworkManager gcmNetworkManager = getGcmNetworkManager(context);
|
|
|
+- if (gcmNetworkManager == null) {
|
|
|
+- Log.e(TAG, "GcmNetworkManager is not available.");
|
|
|
+- return false;
|
|
|
+- }
|
|
|
+-
|
|
|
+- try {
|
|
|
+- Task task = createTaskFromTaskInfo(taskInfo);
|
|
|
+- gcmNetworkManager.schedule(task);
|
|
|
+- } catch (IllegalArgumentException e) {
|
|
|
+- String gcmErrorMessage = e.getMessage() == null ? "null." : e.getMessage();
|
|
|
+- Log.e(TAG,
|
|
|
+- "GcmNetworkManager failed to schedule task, gcm message: " + gcmErrorMessage);
|
|
|
+- return false;
|
|
|
+- }
|
|
|
+-
|
|
|
+- return true;
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void cancel(Context context, int taskId) {
|
|
|
+- ThreadUtils.assertOnUiThread();
|
|
|
+-
|
|
|
+- GcmNetworkManager gcmNetworkManager = getGcmNetworkManager(context);
|
|
|
+- if (gcmNetworkManager == null) {
|
|
|
+- Log.e(TAG, "GcmNetworkManager is not available.");
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- try {
|
|
|
+- gcmNetworkManager.cancelTask(
|
|
|
+- taskIdToTaskTag(taskId), BackgroundTaskGcmTaskService.class);
|
|
|
+- } catch (IllegalArgumentException e) {
|
|
|
+- Log.e(TAG, "GcmNetworkManager failed to cancel task.");
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private GcmNetworkManager getGcmNetworkManager(Context context) {
|
|
|
+- if (ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context)) {
|
|
|
+- return GcmNetworkManager.getInstance(context);
|
|
|
+- }
|
|
|
+- return null;
|
|
|
+- }
|
|
|
+-
|
|
|
+- private static String taskIdToTaskTag(int taskId) {
|
|
|
+- return Integer.toString(taskId);
|
|
|
+- }
|
|
|
+-}
|
|
|
+diff --git a/components/externalauth/android/BUILD.gn b/components/externalauth/android/BUILD.gn
|
|
|
+--- a/components/externalauth/android/BUILD.gn
|
|
|
++++ b/components/externalauth/android/BUILD.gn
|
|
|
+@@ -27,8 +27,6 @@ android_library("google_delegate_public_impl_java") {
|
|
|
+ android_library("java") {
|
|
|
+ deps = [
|
|
|
+ ":google_delegate_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//components/embedder_support/android:browser_context_java",
|
|
|
+ "//components/embedder_support/android:util_java",
|
|
|
+@@ -50,7 +48,6 @@ android_library("junit") {
|
|
|
+
|
|
|
+ deps = [
|
|
|
+ ":java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//base:base_junit_test_support",
|
|
|
+diff --git a/components/externalauth/android/java/src/org/chromium/components/externalauth/ExternalAuthUtils.java b/components/externalauth/android/java/src/org/chromium/components/externalauth/ExternalAuthUtils.java
|
|
|
+--- a/components/externalauth/android/java/src/org/chromium/components/externalauth/ExternalAuthUtils.java
|
|
|
++++ b/components/externalauth/android/java/src/org/chromium/components/externalauth/ExternalAuthUtils.java
|
|
|
+@@ -15,16 +15,12 @@ import android.text.TextUtils;
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+ import androidx.annotation.WorkerThread;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.base.StrictModeContext;
|
|
|
+ import org.chromium.base.task.PostTask;
|
|
|
+ import org.chromium.components.embedder_support.util.Origin;
|
|
|
+ import org.chromium.content_public.browser.UiThreadTaskTraits;
|
|
|
+-import org.chromium.gms.ChromiumPlayServicesAvailability;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Utility class for external authentication tools.
|
|
|
+@@ -170,9 +166,7 @@ public class ExternalAuthUtils {
|
|
|
+ * when it is updating.
|
|
|
+ */
|
|
|
+ public boolean isGooglePlayServicesMissing(final Context context) {
|
|
|
+- final int resultCode = checkGooglePlayServicesAvailable(context);
|
|
|
+- return (resultCode == ConnectionResult.SERVICE_MISSING
|
|
|
+- || resultCode == ConnectionResult.SERVICE_INVALID);
|
|
|
++ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -189,7 +183,6 @@ public class ExternalAuthUtils {
|
|
|
+ public boolean canUseGooglePlayServices(final UserRecoverableErrorHandler errorHandler) {
|
|
|
+ Context context = ContextUtils.getApplicationContext();
|
|
|
+ final int resultCode = checkGooglePlayServicesAvailable(context);
|
|
|
+- if (resultCode == ConnectionResult.SUCCESS) return true;
|
|
|
+ // resultCode is some kind of error.
|
|
|
+ Log.v(TAG, "Unable to use Google Play Services: %s", describeError(resultCode));
|
|
|
+ if (isUserRecoverableError(resultCode)) {
|
|
|
+@@ -260,10 +253,7 @@ public class ExternalAuthUtils {
|
|
|
+ * @return The code produced by calling the external code
|
|
|
+ */
|
|
|
+ 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.getGooglePlayServicesConnectionResult(context);
|
|
|
+- }
|
|
|
++ return 1; /*SERVICE_MISSING*/
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -274,7 +264,7 @@ public class ExternalAuthUtils {
|
|
|
+ * @return true If the code represents a user-recoverable error
|
|
|
+ */
|
|
|
+ protected boolean isUserRecoverableError(final int errorCode) {
|
|
|
+- return GoogleApiAvailability.getInstance().isUserResolvableError(errorCode);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -284,7 +274,7 @@ public class ExternalAuthUtils {
|
|
|
+ * @return a textual description of the error code
|
|
|
+ */
|
|
|
+ protected String describeError(final int errorCode) {
|
|
|
+- return GoogleApiAvailability.getInstance().getErrorString(errorCode);
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/components/externalauth/android/java/src/org/chromium/components/externalauth/UserRecoverableErrorHandler.java b/components/externalauth/android/java/src/org/chromium/components/externalauth/UserRecoverableErrorHandler.java
|
|
|
+--- a/components/externalauth/android/java/src/org/chromium/components/externalauth/UserRecoverableErrorHandler.java
|
|
|
++++ b/components/externalauth/android/java/src/org/chromium/components/externalauth/UserRecoverableErrorHandler.java
|
|
|
+@@ -9,8 +9,6 @@ import android.app.Dialog;
|
|
|
+ import android.content.Context;
|
|
|
+ import android.content.DialogInterface;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.ThreadUtils;
|
|
|
+ import org.chromium.base.metrics.RecordUserAction;
|
|
|
+
|
|
|
+@@ -89,7 +87,6 @@ public abstract class UserRecoverableErrorHandler {
|
|
|
+ if (!sNotificationShown.getAndSet(true)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+- GoogleApiAvailability.getInstance().showErrorNotification(context, errorCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -182,11 +179,7 @@ public abstract class UserRecoverableErrorHandler {
|
|
|
+ cancelDialog();
|
|
|
+ }
|
|
|
+ if (mDialog == null) {
|
|
|
+- mDialog = GoogleApiAvailability.getInstance().getErrorDialog(
|
|
|
+- mActivity, errorCode, NO_RESPONSE_REQUIRED);
|
|
|
+ mErrorCode = errorCode;
|
|
|
+-
|
|
|
+- DialogUserActionRecorder.createAndAttachToDialog(mDialog);
|
|
|
+ }
|
|
|
+ // This can happen if |errorCode| is ConnectionResult.SERVICE_INVALID.
|
|
|
+ if (mDialog != null && !mDialog.isShowing()) {
|
|
|
+diff --git a/components/gcm_driver/android/BUILD.gn b/components/gcm_driver/android/BUILD.gn
|
|
|
+--- a/components/gcm_driver/android/BUILD.gn
|
|
|
++++ b/components/gcm_driver/android/BUILD.gn
|
|
|
+@@ -15,7 +15,6 @@ android_library("gcm_driver_java") {
|
|
|
+ "//content/public/android:content_java",
|
|
|
+ "//third_party/android_deps:androidx_annotation_annotation_java",
|
|
|
+ "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
|
|
|
+- "//third_party/android_sdk:android_gcm_java",
|
|
|
+ ]
|
|
|
+ annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
|
|
|
+
|
|
|
+diff --git a/components/gcm_driver/instance_id/android/BUILD.gn b/components/gcm_driver/instance_id/android/BUILD.gn
|
|
|
+--- a/components/gcm_driver/instance_id/android/BUILD.gn
|
|
|
++++ b/components/gcm_driver/instance_id/android/BUILD.gn
|
|
|
+@@ -15,7 +15,6 @@ generate_jni("test_support_jni_headers") {
|
|
|
+
|
|
|
+ android_library("instance_id_driver_java") {
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_iid_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//components/gcm_driver/android:gcm_driver_java",
|
|
|
+@@ -28,14 +27,12 @@ android_library("instance_id_driver_java") {
|
|
|
+
|
|
|
+ sources = [
|
|
|
+ "java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDBridge.java",
|
|
|
+- "java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDWithSubtype.java",
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ android_library("instance_id_driver_test_support_java") {
|
|
|
+ deps = [
|
|
|
+ ":instance_id_driver_java",
|
|
|
+- "$google_play_services_package:google_play_services_iid_java",
|
|
|
+ "//base:base_java",
|
|
|
+ ]
|
|
|
+
|
|
|
+diff --git a/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDBridge.java b/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDBridge.java
|
|
|
+--- a/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDBridge.java
|
|
|
++++ b/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDBridge.java
|
|
|
+@@ -27,7 +27,6 @@ public class InstanceIDBridge {
|
|
|
+ * Underlying InstanceIDWithSubtype. May be shared by multiple InstanceIDBridges. Must be
|
|
|
+ * initialized on a background thread.
|
|
|
+ */
|
|
|
+- private InstanceIDWithSubtype mInstanceID;
|
|
|
+
|
|
|
+ private static boolean sBlockOnAsyncTasksForTesting;
|
|
|
+
|
|
|
+@@ -72,7 +71,7 @@ public class InstanceIDBridge {
|
|
|
+ new BridgeAsyncTask<String>() {
|
|
|
+ @Override
|
|
|
+ protected String doBackgroundWork() {
|
|
|
+- return mInstanceID.getId();
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void sendResultToNative(String id) {
|
|
|
+@@ -88,7 +87,7 @@ public class InstanceIDBridge {
|
|
|
+ new BridgeAsyncTask<Long>() {
|
|
|
+ @Override
|
|
|
+ protected Long doBackgroundWork() {
|
|
|
+- return mInstanceID.getCreationTime();
|
|
|
++ return 0L;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void sendResultToNative(Long creationTime) {
|
|
|
+@@ -110,21 +109,7 @@ public class InstanceIDBridge {
|
|
|
+ new BridgeAsyncTask<String>() {
|
|
|
+ @Override
|
|
|
+ protected String doBackgroundWork() {
|
|
|
+- try {
|
|
|
+- // TODO(knollr): Migrate stored LazySubscriptionsManager data to
|
|
|
+- // SubscriptionFlagManager.
|
|
|
+- LazySubscriptionsManager.storeLazinessInformation(
|
|
|
+- LazySubscriptionsManager.buildSubscriptionUniqueId(
|
|
|
+- mSubtype, authorizedEntity),
|
|
|
+- (flags & InstanceIDFlags.IS_LAZY) == InstanceIDFlags.IS_LAZY);
|
|
|
+- SubscriptionFlagManager.setFlags(
|
|
|
+- SubscriptionFlagManager.buildSubscriptionUniqueId(
|
|
|
+- mSubtype, authorizedEntity),
|
|
|
+- flags);
|
|
|
+- return mInstanceID.getToken(authorizedEntity, scope);
|
|
|
+- } catch (IOException ex) {
|
|
|
+- return "";
|
|
|
+- }
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void sendResultToNative(String token) {
|
|
|
+@@ -141,21 +126,7 @@ public class InstanceIDBridge {
|
|
|
+ new BridgeAsyncTask<Boolean>() {
|
|
|
+ @Override
|
|
|
+ protected Boolean doBackgroundWork() {
|
|
|
+- try {
|
|
|
+- mInstanceID.deleteToken(authorizedEntity, scope);
|
|
|
+- String subscriptionId = LazySubscriptionsManager.buildSubscriptionUniqueId(
|
|
|
+- mSubtype, authorizedEntity);
|
|
|
+- if (LazySubscriptionsManager.isSubscriptionLazy(subscriptionId)) {
|
|
|
+- LazySubscriptionsManager.deletePersistedMessagesForSubscriptionId(
|
|
|
+- subscriptionId);
|
|
|
+- }
|
|
|
+- SubscriptionFlagManager.clearFlags(
|
|
|
+- SubscriptionFlagManager.buildSubscriptionUniqueId(
|
|
|
+- mSubtype, authorizedEntity));
|
|
|
+- return true;
|
|
|
+- } catch (IOException ex) {
|
|
|
+- return false;
|
|
|
+- }
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void sendResultToNative(Boolean success) {
|
|
|
+@@ -171,12 +142,7 @@ public class InstanceIDBridge {
|
|
|
+ new BridgeAsyncTask<Boolean>() {
|
|
|
+ @Override
|
|
|
+ protected Boolean doBackgroundWork() {
|
|
|
+- try {
|
|
|
+- mInstanceID.deleteInstanceID();
|
|
|
+- return true;
|
|
|
+- } catch (IOException ex) {
|
|
|
+- return false;
|
|
|
+- }
|
|
|
++ return true;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void sendResultToNative(Boolean success) {
|
|
|
+@@ -206,11 +172,6 @@ public class InstanceIDBridge {
|
|
|
+ @Override
|
|
|
+ @SuppressWarnings("NoSynchronizedThisCheck") // Only used/accessible by native.
|
|
|
+ protected Result doInBackground() {
|
|
|
+- synchronized (InstanceIDBridge.this) {
|
|
|
+- if (mInstanceID == null) {
|
|
|
+- mInstanceID = InstanceIDWithSubtype.getInstance(mSubtype);
|
|
|
+- }
|
|
|
+- }
|
|
|
+ return doBackgroundWork();
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+diff --git a/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDWithSubtype.java b/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDWithSubtype.java
|
|
|
+--- a/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDWithSubtype.java
|
|
|
++++ b/components/gcm_driver/instance_id/android/java/src/org/chromium/components/gcm_driver/instance_id/InstanceIDWithSubtype.java
|
|
|
+@@ -10,8 +10,6 @@ import android.text.TextUtils;
|
|
|
+
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+
|
|
|
+-import com.google.android.gms.iid.InstanceID;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+
|
|
|
+ import java.io.IOException;
|
|
|
+@@ -26,8 +24,6 @@ public class InstanceIDWithSubtype {
|
|
|
+ // Must match the private InstanceID.OPTION_SUBTYPE, which is guaranteed to not change.
|
|
|
+ private static final String OPTION_SUBTYPE = "subtype";
|
|
|
+
|
|
|
+- private final InstanceID mInstanceID;
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * Cached instances. May be accessed from multiple threads; synchronize on sSubtypeInstancesLock
|
|
|
+ */
|
|
|
+@@ -39,10 +35,6 @@ public class InstanceIDWithSubtype {
|
|
|
+ @VisibleForTesting
|
|
|
+ protected static FakeFactory sFakeFactoryForTesting;
|
|
|
+
|
|
|
+- protected InstanceIDWithSubtype(InstanceID instanceID) {
|
|
|
+- mInstanceID = instanceID;
|
|
|
+- }
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * Returns an instance of this class. Unlike {@link InstanceID#getInstance(Context)}, it is not
|
|
|
+ * a singleton, but instead a different instance will be returned for each {@code subtype}.
|
|
|
+@@ -58,11 +50,6 @@ public class InstanceIDWithSubtype {
|
|
|
+ if (sFakeFactoryForTesting != null) {
|
|
|
+ existing = sFakeFactoryForTesting.create(subtype);
|
|
|
+ } else {
|
|
|
+- Bundle options = new Bundle();
|
|
|
+- options.putCharSequence(OPTION_SUBTYPE, subtype);
|
|
|
+- InstanceID instanceID =
|
|
|
+- InstanceID.getInstance(ContextUtils.getApplicationContext(), options);
|
|
|
+- existing = new InstanceIDWithSubtype(instanceID);
|
|
|
+ }
|
|
|
+ sSubtypeInstances.put(subtype, existing);
|
|
|
+ }
|
|
|
+@@ -71,30 +58,25 @@ public class InstanceIDWithSubtype {
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getSubtype() {
|
|
|
+- return mInstanceID.getSubtype();
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getId() {
|
|
|
+- return mInstanceID.getId();
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public long getCreationTime() {
|
|
|
+- return mInstanceID.getCreationTime();
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deleteInstanceID() throws IOException {
|
|
|
+- synchronized (sSubtypeInstancesLock) {
|
|
|
+- sSubtypeInstances.remove(mInstanceID.getSubtype());
|
|
|
+- mInstanceID.deleteInstanceID();
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deleteToken(String authorizedEntity, String scope) throws IOException {
|
|
|
+- mInstanceID.deleteToken(authorizedEntity, scope);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getToken(String authorizedEntity, String scope) throws IOException {
|
|
|
+- return mInstanceID.getToken(authorizedEntity, scope);
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Fake subclasses can set {@link #sFakeFactoryForTesting} to an implementation of this. */
|
|
|
+diff --git a/components/media_router/browser/android/BUILD.gn b/components/media_router/browser/android/BUILD.gn
|
|
|
+--- a/components/media_router/browser/android/BUILD.gn
|
|
|
++++ b/components/media_router/browser/android/BUILD.gn
|
|
|
+@@ -11,10 +11,6 @@ android_library("java") {
|
|
|
+ resources_package = "org.chromium.components.media_router"
|
|
|
+ deps = [
|
|
|
+ ":java_resources",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_framework_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//components/browser_ui/media/android:java",
|
|
|
+@@ -75,8 +71,6 @@ android_library("java") {
|
|
|
+ android_library("cast_options_provider_java") {
|
|
|
+ sources = [ "java/src/org/chromium/components/media_router/caf/CastOptionsProvider.java" ]
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_cast_framework_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_java",
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -142,9 +136,6 @@ java_library("junit") {
|
|
|
+ deps = [
|
|
|
+ ":java",
|
|
|
+ ":test_support_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_framework_java",
|
|
|
+- "$google_play_services_package:google_play_services_cast_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//base:base_junit_test_support",
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/BrowserMediaRouter.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/BrowserMediaRouter.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/BrowserMediaRouter.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/BrowserMediaRouter.java
|
|
|
+@@ -10,9 +10,6 @@ import androidx.annotation.Nullable;
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+ import androidx.mediarouter.media.MediaRouter;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.base.StrictModeContext;
|
|
|
+@@ -42,20 +39,7 @@ public class BrowserMediaRouter implements MediaRouteManager {
|
|
|
+ new MediaRouteProvider.Factory() {
|
|
|
+ @Override
|
|
|
+ public void addProviders(MediaRouteManager manager) {
|
|
|
+- int googleApiAvailabilityResult =
|
|
|
+- GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
|
|
|
+- ContextUtils.getApplicationContext(),
|
|
|
+- MIN_GOOGLE_PLAY_SERVICES_APK_VERSION);
|
|
|
+- if (googleApiAvailabilityResult != ConnectionResult.SUCCESS) {
|
|
|
+- GoogleApiAvailability.getInstance().showErrorNotification(
|
|
|
+- ContextUtils.getApplicationContext(), googleApiAvailabilityResult);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+- MediaRouteProvider cafProvider = CafMediaRouteProvider.create(manager);
|
|
|
+- manager.addMediaRouteProvider(cafProvider);
|
|
|
+- MediaRouteProvider remotingProvider =
|
|
|
+- CafRemotingMediaRouteProvider.create(manager);
|
|
|
+- manager.addMediaRouteProvider(remotingProvider);
|
|
|
++ return;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/CastSessionUtil.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/CastSessionUtil.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/CastSessionUtil.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/CastSessionUtil.java
|
|
|
+@@ -4,9 +4,6 @@
|
|
|
+
|
|
|
+ package org.chromium.components.media_router;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.CastDevice;
|
|
|
+-import com.google.android.gms.cast.RemoteMediaPlayer;
|
|
|
+-
|
|
|
+ import org.chromium.components.browser_ui.media.MediaNotificationInfo;
|
|
|
+ import org.chromium.services.media_session.MediaMetadata;
|
|
|
+
|
|
|
+@@ -18,36 +15,4 @@ public class CastSessionUtil {
|
|
|
+
|
|
|
+ // The value is borrowed from the Android Cast SDK code to match their behavior.
|
|
|
+ public static final double MIN_VOLUME_LEVEL_DELTA = 1e-7;
|
|
|
+-
|
|
|
+- /**
|
|
|
+- * Builds a MediaMetadata from the given CastDevice and MediaPlayer, and sets it on the builder
|
|
|
+- */
|
|
|
+- public static void setNotificationMetadata(MediaNotificationInfo.Builder builder,
|
|
|
+- CastDevice castDevice, RemoteMediaPlayer mediaPlayer) {
|
|
|
+- MediaMetadata notificationMetadata = new MediaMetadata("", "", "");
|
|
|
+- builder.setMetadata(notificationMetadata);
|
|
|
+-
|
|
|
+- if (castDevice != null) notificationMetadata.setTitle(castDevice.getFriendlyName());
|
|
|
+-
|
|
|
+- if (mediaPlayer == null) return;
|
|
|
+-
|
|
|
+- com.google.android.gms.cast.MediaInfo info = mediaPlayer.getMediaInfo();
|
|
|
+- if (info == null) return;
|
|
|
+-
|
|
|
+- com.google.android.gms.cast.MediaMetadata metadata = info.getMetadata();
|
|
|
+- if (metadata == null) return;
|
|
|
+-
|
|
|
+- String title = metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_TITLE);
|
|
|
+- if (title != null) notificationMetadata.setTitle(title);
|
|
|
+-
|
|
|
+- String artist = metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_ARTIST);
|
|
|
+- if (artist == null) {
|
|
|
+- artist = metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_ARTIST);
|
|
|
+- }
|
|
|
+- if (artist != null) notificationMetadata.setArtist(artist);
|
|
|
+-
|
|
|
+- String album =
|
|
|
+- metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_TITLE);
|
|
|
+- if (album != null) notificationMetadata.setAlbum(album);
|
|
|
+- }
|
|
|
+ }
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaSink.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaSink.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaSink.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaSink.java
|
|
|
+@@ -8,41 +8,24 @@ import androidx.annotation.Nullable;
|
|
|
+ import androidx.mediarouter.media.MediaRouter;
|
|
|
+ import androidx.mediarouter.media.MediaRouter.RouteInfo;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.CastDevice;
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * A common descriptor of a device that can present some URI.
|
|
|
+ */
|
|
|
+ public class MediaSink {
|
|
|
+ private static final String CAST_SINK_URN_PREFIX = "urn:x-org.chromium:media:sink:cast-";
|
|
|
+- private final String mId;
|
|
|
+- private final String mName;
|
|
|
+- private final CastDevice mDevice;
|
|
|
+-
|
|
|
+- /**
|
|
|
+- * Constructor.
|
|
|
+- * @param id A unique identifier of the sink.
|
|
|
+- * @param name A user friendly name of the sink.
|
|
|
+- * @param device {@link CastDevice} corresponding to this sink.
|
|
|
+- */
|
|
|
+- public MediaSink(String id, String name, CastDevice device) {
|
|
|
+- mId = id;
|
|
|
+- mName = name;
|
|
|
+- mDevice = device;
|
|
|
+- }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return The unique identifier of the sink.
|
|
|
+ */
|
|
|
+ public String getId() {
|
|
|
+- return mId;
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return The user friendly name of the sink.
|
|
|
+ */
|
|
|
+ public String getName() {
|
|
|
+- return mName;
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -52,17 +35,8 @@ public class MediaSink {
|
|
|
+ return CAST_SINK_URN_PREFIX + getId();
|
|
|
+ }
|
|
|
+
|
|
|
+- public CastDevice getDevice() {
|
|
|
+- return mDevice;
|
|
|
+- }
|
|
|
+-
|
|
|
+ @Override
|
|
|
+ public boolean equals(Object o) {
|
|
|
+- if (o == this) return true;
|
|
|
+- if (o instanceof MediaSink) {
|
|
|
+- MediaSink other = (MediaSink) o;
|
|
|
+- return mId.equals(other.getId()) && mName.equals(other.getName());
|
|
|
+- }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -70,23 +44,15 @@ public class MediaSink {
|
|
|
+ public int hashCode() {
|
|
|
+ final int prime = 31;
|
|
|
+ int result = 1;
|
|
|
+- result = prime * result + ((mId == null) ? 0 : mId.hashCode());
|
|
|
+- result = prime * result + ((mName == null) ? 0 : mName.hashCode());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+- @Override
|
|
|
+- public String toString() {
|
|
|
+- return String.format("MediaSink: %s, %s", getId(), getName());
|
|
|
+- }
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * @param route The route information provided by Android.
|
|
|
+ * @return A new MediaSink instance corresponding to the specified {@link RouteInfo}.
|
|
|
+ */
|
|
|
+ public static MediaSink fromRoute(MediaRouter.RouteInfo route) {
|
|
|
+- return new MediaSink(
|
|
|
+- route.getId(), route.getName(), CastDevice.getFromBundle(route.getExtras()));
|
|
|
++ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -97,10 +63,6 @@ public class MediaSink {
|
|
|
+ */
|
|
|
+ @Nullable
|
|
|
+ public static MediaSink fromSinkId(String sinkId, MediaRouter router) {
|
|
|
+- for (MediaRouter.RouteInfo route : router.getRoutes()) {
|
|
|
+- MediaSink sink = MediaSink.fromRoute(route);
|
|
|
+- if (sink.getId().equals(sinkId)) return sink;
|
|
|
+- }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaStatusBridge.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaStatusBridge.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaStatusBridge.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/MediaStatusBridge.java
|
|
|
+@@ -4,10 +4,6 @@
|
|
|
+
|
|
|
+ package org.chromium.components.media_router;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.MediaInfo;
|
|
|
+-import com.google.android.gms.cast.MediaMetadata;
|
|
|
+-import com.google.android.gms.cast.MediaStatus;
|
|
|
+-
|
|
|
+ import org.chromium.base.annotations.CalledByNative;
|
|
|
+ import org.chromium.base.annotations.JNINamespace;
|
|
|
+
|
|
|
+@@ -17,11 +13,6 @@ import org.chromium.base.annotations.JNINamespace;
|
|
|
+ */
|
|
|
+ @JNINamespace("media_router")
|
|
|
+ public class MediaStatusBridge {
|
|
|
+- private MediaStatus mStatus;
|
|
|
+-
|
|
|
+- public MediaStatusBridge(MediaStatus status) {
|
|
|
+- mStatus = status;
|
|
|
+- }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets the play state of the stream. Return values are defined as such:
|
|
|
+@@ -34,7 +25,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public int playerState() {
|
|
|
+- return mStatus.getPlayerState();
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -48,7 +39,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public int idleReason() {
|
|
|
+- return mStatus.getIdleReason();
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -57,13 +48,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public String title() {
|
|
|
+- MediaInfo info = mStatus.getMediaInfo();
|
|
|
+- if (info == null) return "";
|
|
|
+-
|
|
|
+- MediaMetadata metadata = info.getMetadata();
|
|
|
+- if (metadata == null) return "";
|
|
|
+-
|
|
|
+- return metadata.getString(MediaMetadata.KEY_TITLE);
|
|
|
++ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -71,7 +56,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public boolean canPlayPause() {
|
|
|
+- return mStatus.isMediaCommandSupported(MediaStatus.COMMAND_PAUSE);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -79,7 +64,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public boolean canMute() {
|
|
|
+- return mStatus.isMediaCommandSupported(MediaStatus.COMMAND_TOGGLE_MUTE);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -87,7 +72,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public boolean canSetVolume() {
|
|
|
+- return mStatus.isMediaCommandSupported(MediaStatus.COMMAND_SET_VOLUME);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -95,7 +80,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public boolean canSeek() {
|
|
|
+- return mStatus.isMediaCommandSupported(MediaStatus.COMMAND_SEEK);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -103,7 +88,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public boolean isMuted() {
|
|
|
+- return mStatus.isMute();
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -113,7 +98,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public double volume() {
|
|
|
+- return mStatus.getStreamVolume();
|
|
|
++ return 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -122,10 +107,7 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public long duration() {
|
|
|
+- MediaInfo info = mStatus.getMediaInfo();
|
|
|
+- if (info == null) return 0;
|
|
|
+-
|
|
|
+- return info.getStreamDuration();
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -133,6 +115,6 @@ public class MediaStatusBridge {
|
|
|
+ */
|
|
|
+ @CalledByNative
|
|
|
+ public long currentTime() {
|
|
|
+- return mStatus.getStreamPosition();
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseNotificationController.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseNotificationController.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseNotificationController.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseNotificationController.java
|
|
|
+@@ -6,10 +6,6 @@ package org.chromium.components.media_router.caf;
|
|
|
+
|
|
|
+ import android.content.Intent;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.CastDevice;
|
|
|
+-import com.google.android.gms.cast.MediaStatus;
|
|
|
+-import com.google.android.gms.cast.framework.media.RemoteMediaClient;
|
|
|
+-
|
|
|
+ import org.chromium.components.browser_ui.media.MediaNotificationInfo;
|
|
|
+ import org.chromium.components.browser_ui.media.MediaNotificationListener;
|
|
|
+ import org.chromium.components.browser_ui.media.MediaNotificationManager;
|
|
|
+@@ -61,20 +57,6 @@ public abstract class BaseNotificationController
|
|
|
+ public void onStatusUpdated() {
|
|
|
+ if (mNotificationBuilder == null) return;
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- MediaStatus mediaStatus = mSessionController.getRemoteMediaClient().getMediaStatus();
|
|
|
+- if (mediaStatus == null) return;
|
|
|
+-
|
|
|
+- int playerState = mediaStatus.getPlayerState();
|
|
|
+- if (playerState == MediaStatus.PLAYER_STATE_PAUSED
|
|
|
+- || playerState == MediaStatus.PLAYER_STATE_PLAYING) {
|
|
|
+- mNotificationBuilder.setPaused(playerState != MediaStatus.PLAYER_STATE_PLAYING);
|
|
|
+- mNotificationBuilder.setActions(
|
|
|
+- MediaNotificationInfo.ACTION_STOP | MediaNotificationInfo.ACTION_PLAY_PAUSE);
|
|
|
+- } else {
|
|
|
+- mNotificationBuilder.setActions(MediaNotificationInfo.ACTION_STOP);
|
|
|
+- }
|
|
|
+- MediaRouterClient.getInstance().showNotification(mNotificationBuilder.build());
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Called when media metadata updated. */
|
|
|
+@@ -90,30 +72,6 @@ public abstract class BaseNotificationController
|
|
|
+ mNotificationBuilder.setMetadata(notificationMetadata);
|
|
|
+
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- CastDevice castDevice = mSessionController.getSession().getCastDevice();
|
|
|
+- if (castDevice != null) notificationMetadata.setTitle(castDevice.getFriendlyName());
|
|
|
+-
|
|
|
+- RemoteMediaClient remoteMediaClient = mSessionController.getRemoteMediaClient();
|
|
|
+-
|
|
|
+- com.google.android.gms.cast.MediaInfo info = remoteMediaClient.getMediaInfo();
|
|
|
+- if (info == null) return;
|
|
|
+-
|
|
|
+- com.google.android.gms.cast.MediaMetadata metadata = info.getMetadata();
|
|
|
+- if (metadata == null) return;
|
|
|
+-
|
|
|
+- String title = metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_TITLE);
|
|
|
+- if (title != null) notificationMetadata.setTitle(title);
|
|
|
+-
|
|
|
+- String artist = metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_ARTIST);
|
|
|
+- if (artist == null) {
|
|
|
+- artist = metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_ARTIST);
|
|
|
+- }
|
|
|
+- if (artist != null) notificationMetadata.setArtist(artist);
|
|
|
+-
|
|
|
+- String album =
|
|
|
+- metadata.getString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_TITLE);
|
|
|
+- if (album != null) notificationMetadata.setAlbum(album);
|
|
|
+ }
|
|
|
+
|
|
|
+ /////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+@@ -122,15 +80,11 @@ public abstract class BaseNotificationController
|
|
|
+ @Override
|
|
|
+ public void onPlay(int actionSource) {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- mSessionController.getRemoteMediaClient().play();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPause(int actionSource) {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- mSessionController.getRemoteMediaClient().pause();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseSessionController.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseSessionController.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseSessionController.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/BaseSessionController.java
|
|
|
+@@ -6,12 +6,7 @@ package org.chromium.components.media_router.caf;
|
|
|
+
|
|
|
+ import androidx.annotation.Nullable;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.CastDevice;
|
|
|
+-import com.google.android.gms.cast.framework.CastSession;
|
|
|
+-import com.google.android.gms.cast.framework.media.RemoteMediaClient;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+-import org.chromium.components.media_router.CastSessionUtil;
|
|
|
+ import org.chromium.components.media_router.FlingingController;
|
|
|
+ import org.chromium.components.media_router.MediaSink;
|
|
|
+ import org.chromium.components.media_router.MediaSource;
|
|
|
+@@ -42,15 +37,12 @@ public abstract class BaseSessionController {
|
|
|
+ void onMetadataUpdated();
|
|
|
+ }
|
|
|
+
|
|
|
+- private CastSession mCastSession;
|
|
|
+ private final CafBaseMediaRouteProvider mProvider;
|
|
|
+ private CreateRouteRequestInfo mRouteCreationInfo;
|
|
|
+- private final RemoteMediaClient.Callback mRemoteMediaClientCallback;
|
|
|
+ private final List<Callback> mCallbacks = new ArrayList<>();
|
|
|
+
|
|
|
+ public BaseSessionController(CafBaseMediaRouteProvider provider) {
|
|
|
+ mProvider = provider;
|
|
|
+- mRemoteMediaClientCallback = new RemoteMediaClientCallback();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void addCallback(Callback callback) {
|
|
|
+@@ -63,9 +55,6 @@ public abstract class BaseSessionController {
|
|
|
+
|
|
|
+ public void requestSessionLaunch() {
|
|
|
+ mRouteCreationInfo = mProvider.getPendingCreateRouteRequestInfo();
|
|
|
+- CastUtils.getCastContext().setReceiverApplicationId(
|
|
|
+- mRouteCreationInfo.source.getApplicationId());
|
|
|
+-
|
|
|
+ // When the user clicks a route on the MediaRouteChooserDialog, we intercept the click event
|
|
|
+ // and do not select the route. Instead the route selection is postponed to here. This will
|
|
|
+ // trigger CAF to launch the session.
|
|
|
+@@ -84,69 +73,22 @@ public abstract class BaseSessionController {
|
|
|
+ return mRouteCreationInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+- public CastSession getSession() {
|
|
|
+- return mCastSession;
|
|
|
+- }
|
|
|
+-
|
|
|
+- public RemoteMediaClient getRemoteMediaClient() {
|
|
|
+- return isConnected() ? mCastSession.getRemoteMediaClient() : null;
|
|
|
+- }
|
|
|
+-
|
|
|
+ public abstract BaseNotificationController getNotificationController();
|
|
|
+
|
|
|
+ public void endSession() {
|
|
|
+- CastUtils.getCastContext().getSessionManager().endCurrentSession(/* stopCasting= */ true);
|
|
|
+- CastUtils.getCastContext().setReceiverApplicationId(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<String> getCapabilities() {
|
|
|
+ List<String> capabilities = new ArrayList<>();
|
|
|
+- if (mCastSession == null || !mCastSession.isConnected()) return capabilities;
|
|
|
+- CastDevice device = mCastSession.getCastDevice();
|
|
|
+- if (device.hasCapability(CastDevice.CAPABILITY_AUDIO_IN)) {
|
|
|
+- capabilities.add("audio_in");
|
|
|
+- }
|
|
|
+- if (device.hasCapability(CastDevice.CAPABILITY_AUDIO_OUT)) {
|
|
|
+- capabilities.add("audio_out");
|
|
|
+- }
|
|
|
+- if (device.hasCapability(CastDevice.CAPABILITY_VIDEO_IN)) {
|
|
|
+- capabilities.add("video_in");
|
|
|
+- }
|
|
|
+- if (device.hasCapability(CastDevice.CAPABILITY_VIDEO_OUT)) {
|
|
|
+- capabilities.add("video_out");
|
|
|
+- }
|
|
|
+ return capabilities;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isConnected() {
|
|
|
+- return mCastSession != null && mCastSession.isConnected();
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateRemoteMediaClient(String message) {
|
|
|
+ if (!isConnected()) return;
|
|
|
+-
|
|
|
+- mCastSession.getRemoteMediaClient().onMessageReceived(
|
|
|
+- mCastSession.getCastDevice(), CastSessionUtil.MEDIA_NAMESPACE, message);
|
|
|
+- }
|
|
|
+-
|
|
|
+- /** Attaches the controller to the current {@link CastSession}. */
|
|
|
+- public void attachToCastSession(CastSession session) {
|
|
|
+- mCastSession = session;
|
|
|
+- RemoteMediaClient uncheckedRemoteMediaClient = mCastSession.getRemoteMediaClient();
|
|
|
+- if (uncheckedRemoteMediaClient != null) {
|
|
|
+- uncheckedRemoteMediaClient.registerCallback(mRemoteMediaClientCallback);
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- /** Detaches the controller from any {@link CastSession}. */
|
|
|
+- public void detachFromCastSession() {
|
|
|
+- if (mCastSession == null) return;
|
|
|
+-
|
|
|
+- RemoteMediaClient uncheckedRemoteMediaClient = mCastSession.getRemoteMediaClient();
|
|
|
+- if (uncheckedRemoteMediaClient != null) {
|
|
|
+- uncheckedRemoteMediaClient.unregisterCallback(mRemoteMediaClientCallback);
|
|
|
+- }
|
|
|
+- mCastSession = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Called when session started. */
|
|
|
+@@ -163,50 +105,12 @@ public abstract class BaseSessionController {
|
|
|
+ return mProvider;
|
|
|
+ }
|
|
|
+
|
|
|
+- /**
|
|
|
+- * All sub-classes need to register this method to listen to messages of the namespaces they are
|
|
|
+- * interested in.
|
|
|
+- */
|
|
|
+- protected void onMessageReceived(CastDevice castDevice, String namespace, String message) {
|
|
|
+- Log.d(TAG,
|
|
|
+- "Received message from Cast device: namespace=\"" + namespace + "\" message=\""
|
|
|
+- + message + "\"");
|
|
|
+- if (CastSessionUtil.MEDIA_NAMESPACE.equals(namespace)) {
|
|
|
+- updateRemoteMediaClient(message);
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private class RemoteMediaClientCallback extends RemoteMediaClient.Callback {
|
|
|
+- @Override
|
|
|
+- public void onStatusUpdated() {
|
|
|
+- BaseSessionController.this.onStatusUpdated();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onMetadataUpdated() {
|
|
|
+- BaseSessionController.this.onMetadataUpdated();
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- protected void onStatusUpdated() {
|
|
|
+- notifyCallback((Callback callback) -> callback.onStatusUpdated());
|
|
|
+- }
|
|
|
+-
|
|
|
+- protected void onMetadataUpdated() {
|
|
|
+- notifyCallback((Callback callback) -> callback.onMetadataUpdated());
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Nullable
|
|
|
+- public FlingingController getFlingingController() {
|
|
|
+- return null;
|
|
|
+- }
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * Helper message to get the session ID of the attached session. For stubbing in tests as
|
|
|
+ * {@link CastSession#getSessionId()} is final.
|
|
|
+ */
|
|
|
+ public String getSessionId() {
|
|
|
+- return isConnected() ? getSession().getSessionId() : null;
|
|
|
++ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void notifyCallback(NotifyCallbackAction action) {
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafBaseMediaRouteProvider.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafBaseMediaRouteProvider.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafBaseMediaRouteProvider.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafBaseMediaRouteProvider.java
|
|
|
+@@ -12,9 +12,6 @@ import androidx.mediarouter.media.MediaRouteSelector;
|
|
|
+ import androidx.mediarouter.media.MediaRouter;
|
|
|
+ import androidx.mediarouter.media.MediaRouter.RouteInfo;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.framework.CastSession;
|
|
|
+-import com.google.android.gms.cast.framework.SessionManagerListener;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.components.media_router.DiscoveryCallback;
|
|
|
+ import org.chromium.components.media_router.DiscoveryDelegate;
|
|
|
+@@ -37,7 +34,7 @@ import java.util.Set;
|
|
|
+ * A base provider containing common implementation for CAF-based {@link MediaRouteProvider}s.
|
|
|
+ */
|
|
|
+ public abstract class CafBaseMediaRouteProvider
|
|
|
+- implements MediaRouteProvider, DiscoveryDelegate, SessionManagerListener<CastSession> {
|
|
|
++ implements MediaRouteProvider, DiscoveryDelegate {
|
|
|
+ private static final String TAG = "CafMR";
|
|
|
+
|
|
|
+ protected static final List<MediaSink> NO_SINKS = Collections.emptyList();
|
|
|
+@@ -153,7 +150,6 @@ public abstract class CafBaseMediaRouteProvider
|
|
|
+ // current session and clean up the routes (can't wait for session ending as the signal
|
|
|
+ // might be delayed).
|
|
|
+ sessionController().endSession();
|
|
|
+- handleSessionEnd();
|
|
|
+ }
|
|
|
+ if (mPendingCreateRouteRequestInfo != null) {
|
|
|
+ cancelPendingRequest("Request replaced");
|
|
|
+@@ -182,9 +178,6 @@ public abstract class CafBaseMediaRouteProvider
|
|
|
+ mManager.onCreateRouteRequestError("The sink does not exist", nativeRequestId);
|
|
|
+ }
|
|
|
+
|
|
|
+- CastUtils.getCastContext().getSessionManager().addSessionManagerListener(
|
|
|
+- this, CastSession.class);
|
|
|
+-
|
|
|
+ mPendingCreateRouteRequestInfo = new CreateRouteRequestInfo(source, sink, presentationId,
|
|
|
+ origin, tabId, isOffTheRecord, nativeRequestId, targetRouteInfo);
|
|
|
+
|
|
|
+@@ -211,100 +204,6 @@ public abstract class CafBaseMediaRouteProvider
|
|
|
+ removeRoute(routeId, /* error= */ null);
|
|
|
+ }
|
|
|
+
|
|
|
+- ///////////////////////////////////////////////////////
|
|
|
+- // SessionManagerListener implementation begin
|
|
|
+- ///////////////////////////////////////////////////////
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public final void onSessionStarting(CastSession session) {
|
|
|
+- // The session is not connected yet at this point so this is no-op.
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onSessionStartFailed(CastSession session, int error) {
|
|
|
+- removeAllRoutes("Launch error");
|
|
|
+- cancelPendingRequest("Launch error");
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onSessionStarted(CastSession session, String sessionId) {
|
|
|
+- Log.d(TAG, "onSessionStarted");
|
|
|
+-
|
|
|
+- if (session != CastUtils.getCastContext().getSessionManager().getCurrentCastSession()) {
|
|
|
+- // Sometimes the session start signal might come in for an earlier launch request, which
|
|
|
+- // should be ignored.
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- if (session == sessionController().getSession() || mPendingCreateRouteRequestInfo == null) {
|
|
|
+- // Early return for any possible case that the session start signal comes in twice for
|
|
|
+- // the same session.
|
|
|
+- return;
|
|
|
+- }
|
|
|
+- handleSessionStart(session, sessionId);
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public final void onSessionResumed(CastSession session, boolean wasSuspended) {
|
|
|
+- sessionController().attachToCastSession(session);
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public final void onSessionResuming(CastSession session, String sessionId) {}
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public final void onSessionResumeFailed(CastSession session, int error) {}
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public final void onSessionEnding(CastSession session) {
|
|
|
+- handleSessionEnd();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public final void onSessionEnded(CastSession session, int error) {
|
|
|
+- Log.d(TAG, "Session ended with error code " + error);
|
|
|
+- handleSessionEnd();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public final void onSessionSuspended(CastSession session, int reason) {
|
|
|
+- sessionController().detachFromCastSession();
|
|
|
+- }
|
|
|
+-
|
|
|
+- ///////////////////////////////////////////////////////
|
|
|
+- // SessionManagerListener implementation end
|
|
|
+- ///////////////////////////////////////////////////////
|
|
|
+-
|
|
|
+- protected void handleSessionStart(CastSession session, String sessionId) {
|
|
|
+- sessionController().attachToCastSession(session);
|
|
|
+- sessionController().onSessionStarted();
|
|
|
+-
|
|
|
+- MediaSink sink = mPendingCreateRouteRequestInfo.sink;
|
|
|
+- MediaSource source = mPendingCreateRouteRequestInfo.source;
|
|
|
+- MediaRoute route = new MediaRoute(
|
|
|
+- sink.getId(), source.getSourceId(), mPendingCreateRouteRequestInfo.presentationId);
|
|
|
+- addRoute(route, mPendingCreateRouteRequestInfo.origin, mPendingCreateRouteRequestInfo.tabId,
|
|
|
+- mPendingCreateRouteRequestInfo.nativeRequestId, /* wasLaunched= */ true);
|
|
|
+-
|
|
|
+- mPendingCreateRouteRequestInfo = null;
|
|
|
+- }
|
|
|
+-
|
|
|
+- private void handleSessionEnd() {
|
|
|
+- if (mPendingCreateRouteRequestInfo != null) {
|
|
|
+- // The Cast SDK notifies about session ending when a route is unselected, even when
|
|
|
+- // there's no current session. Because CastSessionController unselects the route to set
|
|
|
+- // the receiver app ID, this needs to be guarded by a pending request null check to make
|
|
|
+- // sure the listener is not unregistered during a session relaunch.
|
|
|
+- return;
|
|
|
+- }
|
|
|
+- sessionController().onSessionEnded();
|
|
|
+- sessionController().detachFromCastSession();
|
|
|
+- getAndroidMediaRouter().selectRoute(getAndroidMediaRouter().getDefaultRoute());
|
|
|
+- terminateAllRoutes();
|
|
|
+- CastUtils.getCastContext().getSessionManager().removeSessionManagerListener(
|
|
|
+- this, CastSession.class);
|
|
|
+- }
|
|
|
+-
|
|
|
+ private void cancelPendingRequest(String error) {
|
|
|
+ if (mPendingCreateRouteRequestInfo == null) return;
|
|
|
+
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMediaRouteProvider.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMediaRouteProvider.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMediaRouteProvider.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMediaRouteProvider.java
|
|
|
+@@ -11,8 +11,6 @@ import androidx.annotation.Nullable;
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+ import androidx.mediarouter.media.MediaRouter;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.framework.CastSession;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.components.media_router.BrowserMediaRouter;
|
|
|
+ import org.chromium.components.media_router.ClientRecord;
|
|
|
+@@ -147,20 +145,6 @@ public class CafMediaRouteProvider extends CafBaseMediaRouteProvider {
|
|
|
+ return mMessageHandler;
|
|
|
+ }
|
|
|
+
|
|
|
+- @Override
|
|
|
+- protected void handleSessionStart(CastSession session, String sessionId) {
|
|
|
+- super.handleSessionStart(session, sessionId);
|
|
|
+-
|
|
|
+- for (ClientRecord clientRecord : mClientIdToRecords.values()) {
|
|
|
+- // Should be exactly one instance of MediaRoute/ClientRecord at this moment.
|
|
|
+- mMessageHandler.sendReceiverActionToClient(clientRecord.routeId,
|
|
|
+- sessionController().getSink(), clientRecord.clientId, "cast");
|
|
|
+- }
|
|
|
+-
|
|
|
+- mMessageHandler.onSessionStarted();
|
|
|
+- sessionController().getSession().getRemoteMediaClient().requestStatus();
|
|
|
+- }
|
|
|
+-
|
|
|
+ @Override
|
|
|
+ protected void addRoute(
|
|
|
+ MediaRoute route, String origin, int tabId, int nativeRequestId, boolean wasLaunched) {
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMessageHandler.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMessageHandler.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMessageHandler.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CafMessageHandler.java
|
|
|
+@@ -13,10 +13,6 @@ import android.util.SparseArray;
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+ import androidx.collection.ArrayMap;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.ApplicationMetadata;
|
|
|
+-import com.google.android.gms.common.api.PendingResult;
|
|
|
+-import com.google.android.gms.common.api.Status;
|
|
|
+-
|
|
|
+ import org.json.JSONArray;
|
|
|
+ import org.json.JSONException;
|
|
|
+ import org.json.JSONObject;
|
|
|
+@@ -345,49 +341,7 @@ public class CafMessageHandler {
|
|
|
+ final int sequenceNumber) throws JSONException {
|
|
|
+ if (volumeMessage == null) return false;
|
|
|
+ if (!mSessionController.isConnected()) return false;
|
|
|
+- boolean shouldWaitForVolumeChange = false;
|
|
|
+- try {
|
|
|
+- if (!volumeMessage.isNull("muted")) {
|
|
|
+- boolean newMuted = volumeMessage.getBoolean("muted");
|
|
|
+- if (mSessionController.getSession().isMute() != newMuted) {
|
|
|
+- mSessionController.getSession().setMute(newMuted);
|
|
|
+- shouldWaitForVolumeChange = true;
|
|
|
+- }
|
|
|
+- }
|
|
|
+- if (!volumeMessage.isNull("level")) {
|
|
|
+- double newLevel = volumeMessage.getDouble("level");
|
|
|
+- double currentLevel = mSessionController.getSession().getVolume();
|
|
|
+- if (!Double.isNaN(currentLevel)
|
|
|
+- && Math.abs(currentLevel - newLevel)
|
|
|
+- > CastSessionUtil.MIN_VOLUME_LEVEL_DELTA) {
|
|
|
+- mSessionController.getSession().setVolume(newLevel);
|
|
|
+- shouldWaitForVolumeChange = true;
|
|
|
+- }
|
|
|
+- }
|
|
|
+- } catch (IOException | IllegalStateException e) {
|
|
|
+- Log.e(TAG, "Failed to send volume command: " + e);
|
|
|
+- return false;
|
|
|
+- }
|
|
|
+-
|
|
|
+- // For each successful volume message we need to respond with an empty "v2_message" so the
|
|
|
+- // Cast Web SDK can call the success callback of the page. If we expect the volume to change
|
|
|
+- // as the result of the command, we're relying on {@link Cast.CastListener#onVolumeChanged}
|
|
|
+- // to get called by the Android Cast SDK when the receiver status is updated. We keep the
|
|
|
+- // sequence number until then. If the volume doesn't change as the result of the command, we
|
|
|
+- // won't get notified by the Android SDK
|
|
|
+- if (shouldWaitForVolumeChange) {
|
|
|
+- mVolumeRequests.add(new RequestRecord(clientId, sequenceNumber));
|
|
|
+- } else {
|
|
|
+- // It's usually bad to have request and response on the same call stack so post the
|
|
|
+- // response to the Android message loop.
|
|
|
+- mHandler.post(new Runnable() {
|
|
|
+- @Override
|
|
|
+- public void run() {
|
|
|
+- onVolumeChanged(clientId, sequenceNumber);
|
|
|
+- }
|
|
|
+- });
|
|
|
+- }
|
|
|
+- return true;
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @VisibleForTesting
|
|
|
+@@ -675,19 +629,11 @@ public class CafMessageHandler {
|
|
|
+ try {
|
|
|
+ // "volume" is a part of "receiver" initialized below.
|
|
|
+ JSONObject jsonVolume = new JSONObject();
|
|
|
+- jsonVolume.put("level", mSessionController.getSession().getVolume());
|
|
|
+- jsonVolume.put("muted", mSessionController.getSession().isMute());
|
|
|
+
|
|
|
+ // "receiver" is a part of "message" initialized below.
|
|
|
+ JSONObject jsonReceiver = new JSONObject();
|
|
|
+- jsonReceiver.put(
|
|
|
+- "label", mSessionController.getSession().getCastDevice().getDeviceId());
|
|
|
+- jsonReceiver.put("friendlyName",
|
|
|
+- mSessionController.getSession().getCastDevice().getFriendlyName());
|
|
|
+ jsonReceiver.put("capabilities", toJSONArray(mSessionController.getCapabilities()));
|
|
|
+ jsonReceiver.put("volume", jsonVolume);
|
|
|
+- jsonReceiver.put(
|
|
|
+- "isActiveInput", mSessionController.getSession().getActiveInputState());
|
|
|
+ jsonReceiver.put("displayStatus", null);
|
|
|
+ jsonReceiver.put("receiverType", "cast");
|
|
|
+
|
|
|
+@@ -700,23 +646,14 @@ public class CafMessageHandler {
|
|
|
+
|
|
|
+ JSONObject jsonMessage = new JSONObject();
|
|
|
+ jsonMessage.put("sessionId", mSessionController.getSessionId());
|
|
|
+- jsonMessage.put("statusText", mSessionController.getSession().getApplicationStatus());
|
|
|
+ jsonMessage.put("receiver", jsonReceiver);
|
|
|
+ jsonMessage.put("namespaces", jsonNamespaces);
|
|
|
+ jsonMessage.put("media", toJSONArray(new ArrayList<>()));
|
|
|
+ jsonMessage.put("status", "connected");
|
|
|
+ jsonMessage.put("transportId", "web-4");
|
|
|
+
|
|
|
+- ApplicationMetadata applicationMetadata =
|
|
|
+- mSessionController.getSession().getApplicationMetadata();
|
|
|
+- if (applicationMetadata != null) {
|
|
|
+- jsonMessage.put("appId", applicationMetadata.getApplicationId());
|
|
|
+- } else {
|
|
|
+- jsonMessage.put("appId",
|
|
|
+- mSessionController.getRouteCreationInfo().source.getApplicationId());
|
|
|
+- }
|
|
|
+- jsonMessage.put("displayName",
|
|
|
+- mSessionController.getSession().getCastDevice().getFriendlyName());
|
|
|
++ jsonMessage.put("appId",
|
|
|
++ mSessionController.getRouteCreationInfo().source.getApplicationId());
|
|
|
+
|
|
|
+ return jsonMessage.toString();
|
|
|
+ } catch (JSONException e) {
|
|
|
+@@ -797,32 +734,6 @@ public class CafMessageHandler {
|
|
|
+ boolean sendStringCastMessage(
|
|
|
+ String message, String namespace, String clientId, int sequenceNumber) {
|
|
|
+ if (!mSessionController.isConnected()) return false;
|
|
|
+-
|
|
|
+- PendingResult<Status> pendingResult =
|
|
|
+- mSessionController.getSession().sendMessage(namespace, message);
|
|
|
+- if (!TextUtils.equals(namespace, CastSessionUtil.MEDIA_NAMESPACE)) {
|
|
|
+- // Media commands wait for the media status update as a result.
|
|
|
+- pendingResult.setResultCallback(
|
|
|
+- (Status result) -> onSendAppMessageResult(result, clientId, sequenceNumber));
|
|
|
+- }
|
|
|
+- return true;
|
|
|
+- }
|
|
|
+-
|
|
|
+- /**
|
|
|
+- * Notifies a client that an app message has been sent.
|
|
|
+- * @param clientId The client id the message is sent from.
|
|
|
+- * @param sequenceNumber The sequence number of the message.
|
|
|
+- */
|
|
|
+- void onSendAppMessageResult(Status result, String clientId, int sequenceNumber) {
|
|
|
+- if (!result.isSuccess()) {
|
|
|
+- // TODO(avayvod): should actually report back to the page.
|
|
|
+- // See https://crbug.com/550445.
|
|
|
+- Log.e(TAG, "Failed to send the message: " + result);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- // App messages wait for the empty message with the sequence
|
|
|
+- // number.
|
|
|
+- sendEnclosedMessageToClient(clientId, "app_message", null, sequenceNumber);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastMediaSource.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastMediaSource.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastMediaSource.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastMediaSource.java
|
|
|
+@@ -9,8 +9,6 @@ import android.net.Uri;
|
|
|
+ import androidx.annotation.Nullable;
|
|
|
+ import androidx.mediarouter.media.MediaRouteSelector;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.CastMediaControlIntent;
|
|
|
+-
|
|
|
+ import org.chromium.components.media_router.MediaSource;
|
|
|
+
|
|
|
+ import java.util.Arrays;
|
|
|
+@@ -106,13 +104,7 @@ public class CastMediaSource implements MediaSource {
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public MediaRouteSelector buildRouteSelector() {
|
|
|
+- try {
|
|
|
+- return new MediaRouteSelector.Builder()
|
|
|
+- .addControlCategory(CastMediaControlIntent.categoryForCast(mApplicationId))
|
|
|
+- .build();
|
|
|
+- } catch (IllegalArgumentException e) {
|
|
|
+- return null;
|
|
|
+- }
|
|
|
++ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastOptionsProvider.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastOptionsProvider.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastOptionsProvider.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastOptionsProvider.java
|
|
|
+@@ -6,28 +6,8 @@ package org.chromium.components.media_router.caf;
|
|
|
+
|
|
|
+ import android.content.Context;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.LaunchOptions;
|
|
|
+-import com.google.android.gms.cast.framework.CastOptions;
|
|
|
+-import com.google.android.gms.cast.framework.OptionsProvider;
|
|
|
+-import com.google.android.gms.cast.framework.SessionProvider;
|
|
|
+-
|
|
|
+ import java.util.List;
|
|
|
+
|
|
|
+ /** {@link OptionsProvider} implementation for Chrome MR. */
|
|
|
+-public class CastOptionsProvider implements OptionsProvider {
|
|
|
+- @Override
|
|
|
+- public CastOptions getCastOptions(Context context) {
|
|
|
+- return new CastOptions.Builder()
|
|
|
+- .setCastMediaOptions(null)
|
|
|
+- .setEnableReconnectionService(false)
|
|
|
+- .setLaunchOptions(new LaunchOptions.Builder().setRelaunchIfRunning(true).build())
|
|
|
+- .setResumeSavedSession(false)
|
|
|
+- .setStopReceiverApplicationWhenEndingSession(true)
|
|
|
+- .build();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public List<SessionProvider> getAdditionalSessionProviders(Context context) {
|
|
|
+- return null;
|
|
|
+- }
|
|
|
++public class CastOptionsProvider {
|
|
|
+ }
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastSessionController.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastSessionController.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastSessionController.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastSessionController.java
|
|
|
+@@ -7,11 +7,6 @@ package org.chromium.components.media_router.caf;
|
|
|
+ import androidx.annotation.NonNull;
|
|
|
+ import androidx.annotation.VisibleForTesting;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.ApplicationMetadata;
|
|
|
+-import com.google.android.gms.cast.Cast;
|
|
|
+-import com.google.android.gms.cast.CastDevice;
|
|
|
+-import com.google.android.gms.cast.framework.CastSession;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+
|
|
|
+ import java.util.ArrayList;
|
|
|
+@@ -24,12 +19,10 @@ public class CastSessionController extends BaseSessionController {
|
|
|
+ private static final String TAG = "CafSessionCtrl";
|
|
|
+
|
|
|
+ private List<String> mNamespaces = new ArrayList<String>();
|
|
|
+- private CastListener mCastListener;
|
|
|
+ private CafNotificationController mNotificationController;
|
|
|
+
|
|
|
+ public CastSessionController(CafBaseMediaRouteProvider provider) {
|
|
|
+ super(provider);
|
|
|
+- mCastListener = new CastListener();
|
|
|
+ mNotificationController = new CafNotificationController(this);
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -37,30 +30,6 @@ public class CastSessionController extends BaseSessionController {
|
|
|
+ return mNamespaces;
|
|
|
+ }
|
|
|
+
|
|
|
+- /**
|
|
|
+- * Init nested fields for testing. The reason is that nested classes are bound to the original
|
|
|
+- * instance instead of the spyed instance.
|
|
|
+- */
|
|
|
+- void initNestedFieldsForTesting() {
|
|
|
+- mCastListener = new CastListener();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void attachToCastSession(CastSession session) {
|
|
|
+- super.attachToCastSession(session);
|
|
|
+- getSession().addCastListener(mCastListener);
|
|
|
+- updateNamespaces();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void detachFromCastSession() {
|
|
|
+- if (getSession() == null) return;
|
|
|
+-
|
|
|
+- mNamespaces.clear();
|
|
|
+- getSession().removeCastListener(mCastListener);
|
|
|
+- super.detachFromCastSession();
|
|
|
+- }
|
|
|
+-
|
|
|
+ @Override
|
|
|
+ public void onSessionEnded() {
|
|
|
+ getMessageHandler().onSessionEnded();
|
|
|
+@@ -72,24 +41,6 @@ public class CastSessionController extends BaseSessionController {
|
|
|
+ return mNotificationController;
|
|
|
+ }
|
|
|
+
|
|
|
+- private class CastListener extends Cast.Listener {
|
|
|
+- @Override
|
|
|
+- public void onApplicationStatusChanged() {
|
|
|
+- CastSessionController.this.onApplicationStatusChanged();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onApplicationMetadataChanged(ApplicationMetadata metadata) {
|
|
|
+- CastSessionController.this.onApplicationStatusChanged();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onVolumeChanged() {
|
|
|
+- CastSessionController.this.onApplicationStatusChanged();
|
|
|
+- getMessageHandler().onVolumeChanged();
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+ private void onApplicationStatusChanged() {
|
|
|
+ updateNamespaces();
|
|
|
+
|
|
|
+@@ -100,53 +51,18 @@ public class CastSessionController extends BaseSessionController {
|
|
|
+ @VisibleForTesting
|
|
|
+ void updateNamespaces() {
|
|
|
+ if (!isConnected()) return;
|
|
|
+-
|
|
|
+- if (getSession().getApplicationMetadata() == null
|
|
|
+- || getSession().getApplicationMetadata().getSupportedNamespaces() == null) {
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- Set<String> namespacesToAdd =
|
|
|
+- new HashSet<>(getSession().getApplicationMetadata().getSupportedNamespaces());
|
|
|
+- Set<String> namespacesToRemove = new HashSet<String>(mNamespaces);
|
|
|
+-
|
|
|
+- namespacesToRemove.removeAll(namespacesToAdd);
|
|
|
+- namespacesToAdd.removeAll(mNamespaces);
|
|
|
+-
|
|
|
+- for (String namespace : namespacesToRemove) unregisterNamespace(namespace);
|
|
|
+- for (String namespace : namespacesToAdd) registerNamespace(namespace);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void registerNamespace(String namespace) {
|
|
|
+ assert !mNamespaces.contains(namespace);
|
|
|
+
|
|
|
+ if (!isConnected()) return;
|
|
|
+-
|
|
|
+- try {
|
|
|
+- getSession().setMessageReceivedCallbacks(namespace, this::onMessageReceived);
|
|
|
+- mNamespaces.add(namespace);
|
|
|
+- } catch (Exception e) {
|
|
|
+- Log.e(TAG, "Failed to register namespace listener for %s", namespace, e);
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void unregisterNamespace(String namespace) {
|
|
|
+ assert mNamespaces.contains(namespace);
|
|
|
+
|
|
|
+ if (!isConnected()) return;
|
|
|
+-
|
|
|
+- try {
|
|
|
+- getSession().removeMessageReceivedCallbacks(namespace);
|
|
|
+- mNamespaces.remove(namespace);
|
|
|
+- } catch (Exception e) {
|
|
|
+- Log.e(TAG, "Failed to remove the namespace listener for %s", namespace, e);
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- protected void onMessageReceived(CastDevice castDevice, String namespace, String message) {
|
|
|
+- super.onMessageReceived(castDevice, namespace, message);
|
|
|
+- getMessageHandler().onMessageReceived(namespace, message);
|
|
|
+ }
|
|
|
+
|
|
|
+ @NonNull
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastUtils.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastUtils.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastUtils.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/CastUtils.java
|
|
|
+@@ -4,18 +4,10 @@
|
|
|
+
|
|
|
+ package org.chromium.components.media_router.caf;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.framework.CastContext;
|
|
|
+-
|
|
|
+ import org.chromium.components.media_router.MediaRouterClient;
|
|
|
+
|
|
|
+ /** Utility methods for Cast. */
|
|
|
+ public class CastUtils {
|
|
|
+- /** Helper method to return the {@link CastContext} instance. */
|
|
|
+- public static CastContext getCastContext() {
|
|
|
+- return CastContext.getSharedInstance(
|
|
|
+- MediaRouterClient.getInstance().getContextForRemoting());
|
|
|
+- }
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * Compares two origins. Empty origin strings correspond to unique origins in
|
|
|
+ * url::Origin.
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafExpandedControllerActivity.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafExpandedControllerActivity.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafExpandedControllerActivity.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafExpandedControllerActivity.java
|
|
|
+@@ -45,53 +45,36 @@ public class CafExpandedControllerActivity
|
|
|
+ @Override
|
|
|
+ public void play() {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- mSessionController.getSession().getRemoteMediaClient().play();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void pause() {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- mSessionController.getSession().getRemoteMediaClient().pause();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getDuration() {
|
|
|
+- if (!mSessionController.isConnected()) return 0;
|
|
|
+- return mSessionController.getFlingingController().getDuration();
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getPosition() {
|
|
|
+- if (!mSessionController.isConnected()) return 0;
|
|
|
+- return mSessionController.getFlingingController().getApproximateCurrentTime();
|
|
|
++ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void seekTo(long pos) {
|
|
|
+- if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- mSessionController.getSession().getRemoteMediaClient().seek(pos);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isPlaying() {
|
|
|
+- if (!mSessionController.isConnected()) return false;
|
|
|
+-
|
|
|
+- return mSessionController.getSession().getRemoteMediaClient().isPlaying();
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getActionFlags() {
|
|
|
+ long flags =
|
|
|
+ PlaybackStateCompat.ACTION_REWIND | PlaybackStateCompat.ACTION_FAST_FORWARD;
|
|
|
+- if (mSessionController.isConnected()
|
|
|
+- && mSessionController.getSession().getRemoteMediaClient().isPlaying()) {
|
|
|
+- flags |= PlaybackStateCompat.ACTION_PAUSE;
|
|
|
+- } else {
|
|
|
+- flags |= PlaybackStateCompat.ACTION_PLAY;
|
|
|
+- }
|
|
|
+ return flags;
|
|
|
+ }
|
|
|
+ };
|
|
|
+@@ -180,20 +163,10 @@ public class CafExpandedControllerActivity
|
|
|
+ private void updateUi() {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+
|
|
|
+- String deviceName = mSessionController.getSession().getCastDevice().getFriendlyName();
|
|
|
+- String titleText = "";
|
|
|
+- if (deviceName != null) {
|
|
|
+- titleText = getResources().getString(R.string.cast_casting_video, deviceName);
|
|
|
+- }
|
|
|
+- mTitleView.setText(titleText);
|
|
|
+-
|
|
|
+ mMediaController.refresh();
|
|
|
+ mMediaController.updateProgress();
|
|
|
+
|
|
|
+ cancelProgressUpdateTask();
|
|
|
+- if (mSessionController.getSession().getRemoteMediaClient().isPlaying()) {
|
|
|
+- scheduleProgressUpdateTask();
|
|
|
+- }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void scheduleProgressUpdateTask() {
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafRemotingMediaRouteProvider.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafRemotingMediaRouteProvider.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafRemotingMediaRouteProvider.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/CafRemotingMediaRouteProvider.java
|
|
|
+@@ -65,6 +65,6 @@ public class CafRemotingMediaRouteProvider extends CafBaseMediaRouteProvider {
|
|
|
+
|
|
|
+ if (!mRoutes.containsKey(routeId)) return null;
|
|
|
+
|
|
|
+- return sessionController().getFlingingController();
|
|
|
++ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/FlingingControllerAdapter.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/FlingingControllerAdapter.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/FlingingControllerAdapter.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/FlingingControllerAdapter.java
|
|
|
+@@ -4,11 +4,6 @@
|
|
|
+
|
|
|
+ package org.chromium.components.media_router.caf.remoting;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.MediaInfo;
|
|
|
+-import com.google.android.gms.cast.MediaStatus;
|
|
|
+-import com.google.android.gms.cast.framework.media.RemoteMediaClient;
|
|
|
+-import com.google.android.gms.common.api.Result;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.components.media_router.FlingingController;
|
|
|
+ import org.chromium.components.media_router.MediaController;
|
|
|
+@@ -69,14 +64,6 @@ public class FlingingControllerAdapter implements FlingingController, MediaContr
|
|
|
+ /** Starts loading the media URL, from the given position. */
|
|
|
+ public void load(long position) {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- mLoaded = true;
|
|
|
+-
|
|
|
+- MediaInfo mediaInfo = new MediaInfo.Builder(mMediaUrl)
|
|
|
+- .setContentType("*/*")
|
|
|
+- .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
|
|
|
+- .build();
|
|
|
+- mSessionController.getRemoteMediaClient().load(mediaInfo, /* autoplay= */ true, position);
|
|
|
+ }
|
|
|
+
|
|
|
+ ////////////////////////////////////////////
|
|
|
+@@ -91,89 +78,28 @@ public class FlingingControllerAdapter implements FlingingController, MediaContr
|
|
|
+ load(/* position= */ 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+-
|
|
|
+- mSessionController.getRemoteMediaClient().play().setResultCallback(
|
|
|
+- this::onMediaCommandResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void pause() {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+- mSessionController.getRemoteMediaClient().pause().setResultCallback(
|
|
|
+- this::onMediaCommandResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setMute(boolean mute) {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+- mSessionController.getRemoteMediaClient().setStreamMute(mute).setResultCallback(
|
|
|
+- this::onMediaCommandResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setVolume(double volume) {
|
|
|
+ if (!mSessionController.isConnected()) return;
|
|
|
+- mSessionController.getRemoteMediaClient().setStreamVolume(volume).setResultCallback(
|
|
|
+- this::onMediaCommandResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void seek(long position) {
|
|
|
+- if (!mSessionController.isConnected()) return;
|
|
|
+-
|
|
|
+- if (!mLoaded) {
|
|
|
+- load(position);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- mSessionController.getRemoteMediaClient().seek(position).setResultCallback(
|
|
|
+- this::onMediaCommandResult);
|
|
|
+- mStreamPositionExtrapolator.onSeek(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ ////////////////////////////////////////////
|
|
|
+ // MediaController implementation end
|
|
|
+ ////////////////////////////////////////////
|
|
|
+-
|
|
|
+- public void onStatusUpdated() {
|
|
|
+- if (mMediaStatusObserver == null) return;
|
|
|
+-
|
|
|
+- RemoteMediaClient remoteMediaClient = mSessionController.getRemoteMediaClient();
|
|
|
+-
|
|
|
+- MediaStatus mediaStatus = remoteMediaClient.getMediaStatus();
|
|
|
+- if (mediaStatus != null) {
|
|
|
+- mHasEverReceivedValidMediaSession = true;
|
|
|
+- if (mediaStatus.getPlayerState() == MediaStatus.PLAYER_STATE_IDLE
|
|
|
+- && mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) {
|
|
|
+- mLoaded = false;
|
|
|
+- mStreamPositionExtrapolator.onFinish();
|
|
|
+- } else {
|
|
|
+- mStreamPositionExtrapolator.update(remoteMediaClient.getStreamDuration(),
|
|
|
+- remoteMediaClient.getApproximateStreamPosition(),
|
|
|
+- remoteMediaClient.isPlaying(), mediaStatus.getPlaybackRate());
|
|
|
+- }
|
|
|
+-
|
|
|
+- mMediaStatusObserver.onMediaStatusUpdate(new MediaStatusBridge(mediaStatus));
|
|
|
+-
|
|
|
+- } else if (mHasEverReceivedValidMediaSession) {
|
|
|
+- // We can receive a null |mediaStatus| while we are in the process of loading the video.
|
|
|
+- // We should wait until we receive one valid media status before considering the video
|
|
|
+- // unloaded. Otherwise, the first call to seek or play will reload the video.
|
|
|
+- // See b/144325733.
|
|
|
+- mLoaded = false;
|
|
|
+- mStreamPositionExtrapolator.clear();
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- private void onMediaCommandResult(Result result) {
|
|
|
+- // When multiple API calls are made in quick succession, "Results have already been set"
|
|
|
+- // IllegalStateExceptions might be thrown from GMS code. We prefer to catch the exception
|
|
|
+- // and noop it, than to crash. This might lead to some API calls never getting their
|
|
|
+- // onResult() called, so we should not rely on onResult() being called for every API call.
|
|
|
+- // See https://crbug.com/853923.
|
|
|
+- if (!result.getStatus().isSuccess()) {
|
|
|
+- Log.e(TAG, "Error when sending command. Status code: %d",
|
|
|
+- result.getStatus().getStatusCode());
|
|
|
+- }
|
|
|
+- }
|
|
|
+ }
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingMediaSource.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingMediaSource.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingMediaSource.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingMediaSource.java
|
|
|
+@@ -13,8 +13,6 @@ import android.util.Base64;
|
|
|
+ import androidx.annotation.Nullable;
|
|
|
+ import androidx.mediarouter.media.MediaRouteSelector;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.CastMediaControlIntent;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.components.media_router.MediaSource;
|
|
|
+@@ -84,9 +82,7 @@ public class RemotingMediaSource implements MediaSource {
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public MediaRouteSelector buildRouteSelector() {
|
|
|
+- return new MediaRouteSelector.Builder()
|
|
|
+- .addControlCategory(CastMediaControlIntent.categoryForCast(getApplicationId()))
|
|
|
+- .build();
|
|
|
++ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -113,7 +109,7 @@ public class RemotingMediaSource implements MediaSource {
|
|
|
+
|
|
|
+ sApplicationId = (customAppId != null && !customAppId.isEmpty())
|
|
|
+ ? customAppId
|
|
|
+- : CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID;
|
|
|
++ : "CC1AD845"; /*DEFAULT_MEDIA_RECEIVER_APPLICATION_ID*/
|
|
|
+ }
|
|
|
+
|
|
|
+ return sApplicationId;
|
|
|
+diff --git a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingSessionController.java b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingSessionController.java
|
|
|
+--- a/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingSessionController.java
|
|
|
++++ b/components/media_router/browser/android/java/src/org/chromium/components/media_router/caf/remoting/RemotingSessionController.java
|
|
|
+@@ -4,8 +4,6 @@
|
|
|
+
|
|
|
+ package org.chromium.components.media_router.caf.remoting;
|
|
|
+
|
|
|
+-import com.google.android.gms.cast.framework.CastSession;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.components.media_router.CastSessionUtil;
|
|
|
+ import org.chromium.components.media_router.caf.BaseNotificationController;
|
|
|
+@@ -33,19 +31,6 @@ public class RemotingSessionController extends BaseSessionController {
|
|
|
+ sInstance = new WeakReference<>(this);
|
|
|
+ }
|
|
|
+
|
|
|
+- @Override
|
|
|
+- public void attachToCastSession(CastSession session) {
|
|
|
+- super.attachToCastSession(session);
|
|
|
+-
|
|
|
+- try {
|
|
|
+- getSession().setMessageReceivedCallbacks(
|
|
|
+- CastSessionUtil.MEDIA_NAMESPACE, this::onMessageReceived);
|
|
|
+- } catch (Exception e) {
|
|
|
+- Log.e(TAG, "Failed to register namespace listener for %s",
|
|
|
+- CastSessionUtil.MEDIA_NAMESPACE, e);
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+ @Override
|
|
|
+ public void onSessionStarted() {
|
|
|
+ super.onSessionStarted();
|
|
|
+@@ -53,17 +38,6 @@ public class RemotingSessionController extends BaseSessionController {
|
|
|
+ mFlingingControllerAdapter = new FlingingControllerAdapter(this, source.getMediaUrl());
|
|
|
+ }
|
|
|
+
|
|
|
+- @Override
|
|
|
+- protected void onStatusUpdated() {
|
|
|
+- mFlingingControllerAdapter.onStatusUpdated();
|
|
|
+- super.onStatusUpdated();
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public FlingingControllerAdapter getFlingingController() {
|
|
|
+- return mFlingingControllerAdapter;
|
|
|
+- }
|
|
|
+-
|
|
|
+ @Override
|
|
|
+ public BaseNotificationController getNotificationController() {
|
|
|
+ return mNotificationController;
|
|
|
+diff --git a/components/media_router/test/android/cast_emulator/BUILD.gn b/components/media_router/test/android/cast_emulator/BUILD.gn
|
|
|
+--- a/components/media_router/test/android/cast_emulator/BUILD.gn
|
|
|
++++ b/components/media_router/test/android/cast_emulator/BUILD.gn
|
|
|
+@@ -20,7 +20,6 @@ android_library("cast_emulator_java") {
|
|
|
+ "src/org/chromium/components/media_router/cast_emulator/router/DummyRoutePublisher.java",
|
|
|
+ ]
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_cast_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//third_party/android_deps:android_support_v7_appcompat_java",
|
|
|
+ "//third_party/android_deps:androidx_mediarouter_mediarouter_java",
|
|
|
+diff --git a/components/module_installer/android/BUILD.gn b/components/module_installer/android/BUILD.gn
|
|
|
+--- a/components/module_installer/android/BUILD.gn
|
|
|
++++ b/components/module_installer/android/BUILD.gn
|
|
|
+@@ -37,7 +37,6 @@ android_library("module_installer_java") {
|
|
|
+ "//base:jni_java",
|
|
|
+ "//components/crash/android:java",
|
|
|
+ "//third_party/android_deps:androidx_annotation_annotation_java",
|
|
|
+- "//third_party/google_android_play_core:com_google_android_play_core_java",
|
|
|
+ ]
|
|
|
+
|
|
|
+ annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
|
|
|
+@@ -60,7 +59,6 @@ junit_binary("module_installer_junit_tests") {
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//base:base_junit_test_support",
|
|
|
+- "//third_party/google_android_play_core:com_google_android_play_core_java",
|
|
|
+ "//third_party/hamcrest:hamcrest_java",
|
|
|
+ ]
|
|
|
+ }
|
|
|
+diff --git a/components/signin/core/browser/android/BUILD.gn b/components/signin/core/browser/android/BUILD.gn
|
|
|
+--- a/components/signin/core/browser/android/BUILD.gn
|
|
|
++++ b/components/signin/core/browser/android/BUILD.gn
|
|
|
+@@ -14,9 +14,6 @@ generate_jni("jni_headers") {
|
|
|
+
|
|
|
+ android_library("java") {
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_auth_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//net/android:net_java",
|
|
|
+diff --git a/components/signin/core/browser/android/java/src/org/chromium/components/signin/GmsAvailabilityException.java b/components/signin/core/browser/android/java/src/org/chromium/components/signin/GmsAvailabilityException.java
|
|
|
+--- a/components/signin/core/browser/android/java/src/org/chromium/components/signin/GmsAvailabilityException.java
|
|
|
++++ b/components/signin/core/browser/android/java/src/org/chromium/components/signin/GmsAvailabilityException.java
|
|
|
+@@ -4,8 +4,6 @@
|
|
|
+
|
|
|
+ package org.chromium.components.signin;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ /**
|
|
|
+ * This class encapsulates return code if GMSCore package is not available.
|
|
|
+ */
|
|
|
+@@ -27,6 +25,6 @@ public class GmsAvailabilityException extends AccountManagerDelegateException {
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isUserResolvableError() {
|
|
|
+- return GoogleApiAvailability.getInstance().isUserResolvableError(mResultCode);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java b/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
|
|
|
+--- a/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
|
|
|
++++ b/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
|
|
|
+@@ -26,9 +26,6 @@ import android.os.SystemClock;
|
|
|
+
|
|
|
+ import androidx.annotation.Nullable;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.ApiCompatibilityUtils;
|
|
|
+ import org.chromium.base.Callback;
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+@@ -86,17 +83,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void checkCanUseGooglePlayServices() throws AccountManagerDelegateException {
|
|
|
+- Context context = ContextUtils.getApplicationContext();
|
|
|
+- final int resultCode =
|
|
|
+- ChromiumPlayServicesAvailability.getGooglePlayServicesConnectionResult(context);
|
|
|
+- if (resultCode == ConnectionResult.SUCCESS) {
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- throw new GmsAvailabilityException(
|
|
|
+- String.format("Can't use Google Play Services: %s",
|
|
|
+- GoogleApiAvailability.getInstance().getErrorString(resultCode)),
|
|
|
+- resultCode);
|
|
|
++ throw new GmsAvailabilityException("Can't use Google Play Services", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -182,11 +169,7 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isGooglePlayServicesAvailable() {
|
|
|
+- // TODO(http://crbug.com/577190): Remove StrictMode override.
|
|
|
+- try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
|
|
|
+- return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
|
|
|
+- ContextUtils.getApplicationContext());
|
|
|
+- }
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected boolean hasGetAccountsPermission() {
|
|
|
+diff --git a/components/sync/android/BUILD.gn b/components/sync/android/BUILD.gn
|
|
|
+--- a/components/sync/android/BUILD.gn
|
|
|
++++ b/components/sync/android/BUILD.gn
|
|
|
+@@ -13,7 +13,6 @@ android_library("sync_java") {
|
|
|
+ "//net/android:net_java",
|
|
|
+ "//third_party/android_deps:androidx_annotation_annotation_java",
|
|
|
+ "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
|
|
|
+- "//third_party/android_sdk:android_gcm_java",
|
|
|
+ ]
|
|
|
+ annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
|
|
|
+ srcjar_deps = [ ":java_enums" ]
|
|
|
+diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn
|
|
|
+--- a/content/public/android/BUILD.gn
|
|
|
++++ b/content/public/android/BUILD.gn
|
|
|
+@@ -139,10 +139,6 @@ android_library("content_main_dex_java") {
|
|
|
+ android_library("content_full_java") {
|
|
|
+ deps = [
|
|
|
+ ":content_main_dex_java",
|
|
|
+- "$google_play_services_package:google_play_services_auth_api_phone_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_tasks_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//build:chromeos_buildflags",
|
|
|
+diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
|
|
|
+--- a/content/public/common/content_features.cc
|
|
|
++++ b/content/public/common/content_features.cc
|
|
|
+@@ -786,7 +786,7 @@ const base::Feature kWebAssemblyTrapHandler{"WebAssemblyTrapHandler",
|
|
|
+ // Controls whether the WebAuthentication API is enabled:
|
|
|
+ // https://w3c.github.io/webauthn
|
|
|
+ const base::Feature kWebAuth{"WebAuthentication",
|
|
|
+- base::FEATURE_ENABLED_BY_DEFAULT};
|
|
|
++ base::FEATURE_DISABLED_BY_DEFAULT};
|
|
|
+
|
|
|
+ // Controls whether CTAP2 devices can communicate via the WebAuthentication API
|
|
|
+ // using pairingless BLE protocol.
|
|
|
+diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
|
|
|
+--- a/content/test/BUILD.gn
|
|
|
++++ b/content/test/BUILD.gn
|
|
|
+@@ -2630,10 +2630,6 @@ if (is_android) {
|
|
|
+ testonly = true
|
|
|
+ sources = content_java_sources_needing_jni
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_auth_api_phone_java",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_tasks_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//content/public/android:content_java",
|
|
|
+ "//ui/android:ui_full_java",
|
|
|
+diff --git a/device/BUILD.gn b/device/BUILD.gn
|
|
|
+--- a/device/BUILD.gn
|
|
|
++++ b/device/BUILD.gn
|
|
|
+@@ -422,9 +422,6 @@ if (is_android) {
|
|
|
+ junit_binary("device_junit_tests") {
|
|
|
+ sources = [ "gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java" ]
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_location_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//base:base_junit_test_support",
|
|
|
+diff --git a/remoting/android/client_java_tmpl.gni b/remoting/android/client_java_tmpl.gni
|
|
|
+--- a/remoting/android/client_java_tmpl.gni
|
|
|
++++ b/remoting/android/client_java_tmpl.gni
|
|
|
+@@ -104,9 +104,6 @@ template("remoting_android_client_java_tmpl") {
|
|
|
+
|
|
|
+ if (defined(invoker.play_services_package)) {
|
|
|
+ deps += [
|
|
|
+- "${invoker.play_services_package}:google_play_services_auth_base_java",
|
|
|
+- "${invoker.play_services_package}:google_play_services_base_java",
|
|
|
+- "${invoker.play_services_package}:google_play_services_basement_java",
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/services/BUILD.gn b/services/BUILD.gn
|
|
|
+--- a/services/BUILD.gn
|
|
|
++++ b/services/BUILD.gn
|
|
|
+@@ -104,11 +104,6 @@ if (is_android) {
|
|
|
+ "shape_detection/android/junit/src/org/chromium/shape_detection/BitmapUtilsTest.java",
|
|
|
+ ]
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_location_java",
|
|
|
+- "$google_play_services_package:google_play_services_vision_common_java",
|
|
|
+- "$google_play_services_package:google_play_services_vision_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//base:base_junit_test_support",
|
|
|
+@@ -137,10 +132,6 @@ if (is_android) {
|
|
|
+ "shape_detection/android/javatests/src/org/chromium/shape_detection/TextDetectionImplTest.java",
|
|
|
+ ]
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_vision_common_java",
|
|
|
+- "$google_play_services_package:google_play_services_vision_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:base_java_test_support",
|
|
|
+ "//mojo/public/java:base_java",
|
|
|
+diff --git a/services/device/geolocation/BUILD.gn b/services/device/geolocation/BUILD.gn
|
|
|
+--- a/services/device/geolocation/BUILD.gn
|
|
|
++++ b/services/device/geolocation/BUILD.gn
|
|
|
+@@ -156,9 +156,6 @@ if (is_android) {
|
|
|
+
|
|
|
+ deps = [
|
|
|
+ ":geolocation_jni_headers",
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_location_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//base:jni_java",
|
|
|
+ "//components/location/android:location_java",
|
|
|
+diff --git a/services/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderGmsCore.java b/services/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderGmsCore.java
|
|
|
+--- a/services/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderGmsCore.java
|
|
|
++++ b/services/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderGmsCore.java
|
|
|
+@@ -8,132 +8,40 @@ import android.content.Context;
|
|
|
+ import android.location.Location;
|
|
|
+ import android.os.Bundle;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.api.GoogleApiClient;
|
|
|
+-import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
|
|
|
+-import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
|
|
|
+-import com.google.android.gms.location.FusedLocationProviderApi;
|
|
|
+-import com.google.android.gms.location.LocationListener;
|
|
|
+-import com.google.android.gms.location.LocationRequest;
|
|
|
+-import com.google.android.gms.location.LocationServices;
|
|
|
+-
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.base.ThreadUtils;
|
|
|
+ import org.chromium.components.location.LocationUtils;
|
|
|
+-import org.chromium.gms.ChromiumPlayServicesAvailability;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This is a LocationProvider using Google Play Services.
|
|
|
+ *
|
|
|
+ * https://developers.google.com/android/reference/com/google/android/gms/location/package-summary
|
|
|
+ */
|
|
|
+-public class LocationProviderGmsCore implements ConnectionCallbacks, OnConnectionFailedListener,
|
|
|
+- LocationListener, LocationProvider {
|
|
|
++public class LocationProviderGmsCore implements LocationProvider {
|
|
|
+ private static final String TAG = "LocationProvider";
|
|
|
+
|
|
|
+ // Values for the LocationRequest's setInterval for normal and high accuracy, respectively.
|
|
|
+ private static final long UPDATE_INTERVAL_MS = 1000;
|
|
|
+ private static final long UPDATE_INTERVAL_FAST_MS = 500;
|
|
|
+
|
|
|
+- private final GoogleApiClient mGoogleApiClient;
|
|
|
+- private FusedLocationProviderApi mLocationProviderApi = LocationServices.FusedLocationApi;
|
|
|
+-
|
|
|
+- private boolean mEnablehighAccuracy;
|
|
|
+- private LocationRequest mLocationRequest;
|
|
|
+-
|
|
|
+ public static boolean isGooglePlayServicesAvailable(Context context) {
|
|
|
+- return ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(context);
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ LocationProviderGmsCore(Context context) {
|
|
|
+ Log.i(TAG, "Google Play Services");
|
|
|
+- mGoogleApiClient = new GoogleApiClient.Builder(context)
|
|
|
+- .addApi(LocationServices.API)
|
|
|
+- .addConnectionCallbacks(this)
|
|
|
+- .addOnConnectionFailedListener(this)
|
|
|
+- .build();
|
|
|
+- assert mGoogleApiClient != null;
|
|
|
+- }
|
|
|
+-
|
|
|
+- LocationProviderGmsCore(GoogleApiClient client, FusedLocationProviderApi locationApi) {
|
|
|
+- mGoogleApiClient = client;
|
|
|
+- mLocationProviderApi = locationApi;
|
|
|
+- }
|
|
|
+-
|
|
|
+- // ConnectionCallbacks implementation
|
|
|
+- @Override
|
|
|
+- public void onConnected(Bundle connectionHint) {
|
|
|
+- ThreadUtils.assertOnUiThread();
|
|
|
+-
|
|
|
+- mLocationRequest = LocationRequest.create();
|
|
|
+- if (mEnablehighAccuracy) {
|
|
|
+- // With enableHighAccuracy, request a faster update interval and configure the provider
|
|
|
+- // for high accuracy mode.
|
|
|
+- mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
|
|
|
+- .setInterval(UPDATE_INTERVAL_FAST_MS);
|
|
|
+- } else {
|
|
|
+- // Use balanced mode by default. In this mode, the API will prefer the network provider
|
|
|
+- // but may use sensor data (for instance, GPS) if high accuracy is requested by another
|
|
|
+- // app.
|
|
|
+- //
|
|
|
+- // If location is configured for sensors-only then elevate the priority to ensure GPS
|
|
|
+- // and other sensors are used.
|
|
|
+- if (LocationUtils.getInstance().isSystemLocationSettingSensorsOnly()) {
|
|
|
+- mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
|
|
+- } else {
|
|
|
+- mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
|
|
|
+- }
|
|
|
+- mLocationRequest.setInterval(UPDATE_INTERVAL_MS);
|
|
|
+- }
|
|
|
+-
|
|
|
+- final Location location = mLocationProviderApi.getLastLocation(mGoogleApiClient);
|
|
|
+- if (location != null) {
|
|
|
+- LocationProviderAdapter.onNewLocationAvailable(location);
|
|
|
+- }
|
|
|
+-
|
|
|
+- try {
|
|
|
+- // Request updates on UI Thread replicating LocationProviderAndroid's behaviour.
|
|
|
+- mLocationProviderApi.requestLocationUpdates(
|
|
|
+- mGoogleApiClient, mLocationRequest, this, ThreadUtils.getUiThreadLooper());
|
|
|
+- } catch (IllegalStateException | SecurityException e) {
|
|
|
+- // IllegalStateException is thrown "If this method is executed in a thread that has not
|
|
|
+- // called Looper.prepare()". SecurityException is thrown if there is no permission, see
|
|
|
+- // https://crbug.com/731271.
|
|
|
+- Log.e(TAG, " mLocationProviderApi.requestLocationUpdates() " + e);
|
|
|
+- LocationProviderAdapter.newErrorAvailable(
|
|
|
+- "Failed to request location updates: " + e.toString());
|
|
|
+- assert false;
|
|
|
+- }
|
|
|
+- }
|
|
|
+-
|
|
|
+- @Override
|
|
|
+- public void onConnectionSuspended(int cause) {}
|
|
|
+-
|
|
|
+- // OnConnectionFailedListener implementation
|
|
|
+- @Override
|
|
|
+- public void onConnectionFailed(ConnectionResult result) {
|
|
|
+- LocationProviderAdapter.newErrorAvailable(
|
|
|
+- "Failed to connect to Google Play Services: " + result.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ // LocationProvider implementation
|
|
|
+ @Override
|
|
|
+ public void start(boolean enableHighAccuracy) {
|
|
|
+ ThreadUtils.assertOnUiThread();
|
|
|
+- if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect();
|
|
|
+-
|
|
|
+ mEnablehighAccuracy = enableHighAccuracy;
|
|
|
+- mGoogleApiClient.connect(); // Should return via onConnected().
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+ ThreadUtils.assertOnUiThread();
|
|
|
+- if (!mGoogleApiClient.isConnected()) return;
|
|
|
+-
|
|
|
+- mLocationProviderApi.removeLocationUpdates(mGoogleApiClient, this);
|
|
|
+-
|
|
|
+- mGoogleApiClient.disconnect();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -142,10 +50,4 @@ public class LocationProviderGmsCore implements ConnectionCallbacks, OnConnectio
|
|
|
+ if (mGoogleApiClient == null) return false;
|
|
|
+ return mGoogleApiClient.isConnecting() || mGoogleApiClient.isConnected();
|
|
|
+ }
|
|
|
+-
|
|
|
+- // LocationListener implementation
|
|
|
+- @Override
|
|
|
+- public void onLocationChanged(Location location) {
|
|
|
+- LocationProviderAdapter.onNewLocationAvailable(location);
|
|
|
+- }
|
|
|
+ }
|
|
|
+diff --git a/services/shape_detection/BUILD.gn b/services/shape_detection/BUILD.gn
|
|
|
+--- a/services/shape_detection/BUILD.gn
|
|
|
++++ b/services/shape_detection/BUILD.gn
|
|
|
+@@ -107,10 +107,6 @@ if (is_android) {
|
|
|
+ ]
|
|
|
+
|
|
|
+ deps = [
|
|
|
+- "$google_play_services_package:google_play_services_base_java",
|
|
|
+- "$google_play_services_package:google_play_services_basement_java",
|
|
|
+- "$google_play_services_package:google_play_services_vision_common_java",
|
|
|
+- "$google_play_services_package:google_play_services_vision_java",
|
|
|
+ "//base:base_java",
|
|
|
+ "//mojo/public/java:base_java",
|
|
|
+ "//mojo/public/java:bindings_java",
|
|
|
+diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
|
|
+--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
|
|
++++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
|
|
+@@ -8,10 +8,6 @@ import android.graphics.Point;
|
|
|
+ import android.graphics.Rect;
|
|
|
+ import android.util.SparseArray;
|
|
|
+
|
|
|
+-import com.google.android.gms.vision.Frame;
|
|
|
+-import com.google.android.gms.vision.barcode.Barcode;
|
|
|
+-import com.google.android.gms.vision.barcode.BarcodeDetector;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.gfx.mojom.PointF;
|
|
|
+@@ -28,50 +24,7 @@ import org.chromium.shape_detection.mojom.BarcodeFormat;
|
|
|
+ public class BarcodeDetectionImpl implements BarcodeDetection {
|
|
|
+ private static final String TAG = "BarcodeDetectionImpl";
|
|
|
+
|
|
|
+- private BarcodeDetector mBarcodeDetector;
|
|
|
+-
|
|
|
+ public BarcodeDetectionImpl(BarcodeDetectorOptions options) {
|
|
|
+- int formats = Barcode.ALL_FORMATS;
|
|
|
+- if (options.formats != null && options.formats.length > 0) {
|
|
|
+- formats = 0;
|
|
|
+- // Keep this list in sync with the constants defined in
|
|
|
+- // com.google.android.gms.vision.barcode.Barcode and the list of
|
|
|
+- // supported formats in BarcodeDetectionProviderImpl.
|
|
|
+- for (int i = 0; i < options.formats.length; ++i) {
|
|
|
+- if (options.formats[i] == BarcodeFormat.AZTEC) {
|
|
|
+- formats |= Barcode.AZTEC;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.CODE_128) {
|
|
|
+- formats |= Barcode.CODE_128;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.CODE_39) {
|
|
|
+- formats |= Barcode.CODE_39;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.CODE_93) {
|
|
|
+- formats |= Barcode.CODE_93;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.CODABAR) {
|
|
|
+- formats |= Barcode.CODABAR;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.DATA_MATRIX) {
|
|
|
+- formats |= Barcode.DATA_MATRIX;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.EAN_13) {
|
|
|
+- formats |= Barcode.EAN_13;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.EAN_8) {
|
|
|
+- formats |= Barcode.EAN_8;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.ITF) {
|
|
|
+- formats |= Barcode.ITF;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.PDF417) {
|
|
|
+- formats |= Barcode.PDF417;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.QR_CODE) {
|
|
|
+- formats |= Barcode.QR_CODE;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.UPC_A) {
|
|
|
+- formats |= Barcode.UPC_A;
|
|
|
+- } else if (options.formats[i] == BarcodeFormat.UPC_E) {
|
|
|
+- formats |= Barcode.UPC_E;
|
|
|
+- } else {
|
|
|
+- Log.e(TAG, "Unsupported barcode format hint: " + options.formats[i]);
|
|
|
+- }
|
|
|
+- }
|
|
|
+- }
|
|
|
+- mBarcodeDetector = new BarcodeDetector.Builder(ContextUtils.getApplicationContext())
|
|
|
+- .setBarcodeFormats(formats)
|
|
|
+- .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -80,47 +33,12 @@ public class BarcodeDetectionImpl implements BarcodeDetection {
|
|
|
+ // on the device; this happens "fast", but it might have not completed,
|
|
|
+ // bail in this case. Also, the API was disabled between and v.9.0 and
|
|
|
+ // v.9.2, see https://developers.google.com/android/guides/releases.
|
|
|
+- if (!mBarcodeDetector.isOperational()) {
|
|
|
+- Log.e(TAG, "BarcodeDetector is not operational");
|
|
|
+- callback.call(new BarcodeDetectionResult[0]);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- Frame frame = BitmapUtils.convertToFrame(bitmapData);
|
|
|
+- if (frame == null) {
|
|
|
+- Log.e(TAG, "Error converting Mojom Bitmap to Frame");
|
|
|
+- callback.call(new BarcodeDetectionResult[0]);
|
|
|
+- return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- final SparseArray<Barcode> barcodes = mBarcodeDetector.detect(frame);
|
|
|
+-
|
|
|
+- BarcodeDetectionResult[] barcodeArray = new BarcodeDetectionResult[barcodes.size()];
|
|
|
+- for (int i = 0; i < barcodes.size(); i++) {
|
|
|
+- barcodeArray[i] = new BarcodeDetectionResult();
|
|
|
+- final Barcode barcode = barcodes.valueAt(i);
|
|
|
+- barcodeArray[i].rawValue = barcode.rawValue;
|
|
|
+- final Rect rect = barcode.getBoundingBox();
|
|
|
+- barcodeArray[i].boundingBox = new RectF();
|
|
|
+- barcodeArray[i].boundingBox.x = rect.left;
|
|
|
+- barcodeArray[i].boundingBox.y = rect.top;
|
|
|
+- barcodeArray[i].boundingBox.width = rect.width();
|
|
|
+- barcodeArray[i].boundingBox.height = rect.height();
|
|
|
+- final Point[] corners = barcode.cornerPoints;
|
|
|
+- barcodeArray[i].cornerPoints = new PointF[corners.length];
|
|
|
+- for (int j = 0; j < corners.length; j++) {
|
|
|
+- barcodeArray[i].cornerPoints[j] = new PointF();
|
|
|
+- barcodeArray[i].cornerPoints[j].x = corners[j].x;
|
|
|
+- barcodeArray[i].cornerPoints[j].y = corners[j].y;
|
|
|
+- }
|
|
|
+- barcodeArray[i].format = toBarcodeFormat(barcode.format);
|
|
|
+- }
|
|
|
+- callback.call(barcodeArray);
|
|
|
++ Log.e(TAG, "BarcodeDetector is not operational");
|
|
|
++ callback.call(new BarcodeDetectionResult[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void close() {
|
|
|
+- mBarcodeDetector.release();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -129,34 +47,6 @@ public class BarcodeDetectionImpl implements BarcodeDetection {
|
|
|
+ }
|
|
|
+
|
|
|
+ private int toBarcodeFormat(int format) {
|
|
|
+- switch (format) {
|
|
|
+- case Barcode.CODE_128:
|
|
|
+- return BarcodeFormat.CODE_128;
|
|
|
+- case Barcode.CODE_39:
|
|
|
+- return BarcodeFormat.CODE_39;
|
|
|
+- case Barcode.CODE_93:
|
|
|
+- return BarcodeFormat.CODE_93;
|
|
|
+- case Barcode.CODABAR:
|
|
|
+- return BarcodeFormat.CODABAR;
|
|
|
+- case Barcode.DATA_MATRIX:
|
|
|
+- return BarcodeFormat.DATA_MATRIX;
|
|
|
+- case Barcode.EAN_13:
|
|
|
+- return BarcodeFormat.EAN_13;
|
|
|
+- case Barcode.EAN_8:
|
|
|
+- return BarcodeFormat.EAN_8;
|
|
|
+- case Barcode.ITF:
|
|
|
+- return BarcodeFormat.ITF;
|
|
|
+- case Barcode.QR_CODE:
|
|
|
+- return BarcodeFormat.QR_CODE;
|
|
|
+- case Barcode.UPC_A:
|
|
|
+- return BarcodeFormat.UPC_A;
|
|
|
+- case Barcode.UPC_E:
|
|
|
+- return BarcodeFormat.UPC_E;
|
|
|
+- case Barcode.PDF417:
|
|
|
+- return BarcodeFormat.PDF417;
|
|
|
+- case Barcode.AZTEC:
|
|
|
+- return BarcodeFormat.AZTEC;
|
|
|
+- }
|
|
|
+ return BarcodeFormat.UNKNOWN;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java
|
|
|
+--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java
|
|
|
++++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java
|
|
|
+@@ -8,8 +8,6 @@ import android.content.Context;
|
|
|
+ import android.content.pm.PackageInfo;
|
|
|
+ import android.content.pm.PackageManager.NameNotFoundException;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.gms.ChromiumPlayServicesAvailability;
|
|
|
+@@ -36,15 +34,6 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void enumerateSupportedFormats(EnumerateSupportedFormatsResponse callback) {
|
|
|
+- // Keep this list in sync with the constants defined in
|
|
|
+- // com.google.android.gms.vision.barcode.Barcode and the format hints
|
|
|
+- // supported by BarcodeDetectionImpl.
|
|
|
+- int[] supportedFormats = {BarcodeFormat.AZTEC, BarcodeFormat.CODE_128,
|
|
|
+- BarcodeFormat.CODE_39, BarcodeFormat.CODE_93, BarcodeFormat.CODABAR,
|
|
|
+- BarcodeFormat.DATA_MATRIX, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8,
|
|
|
+- BarcodeFormat.ITF, BarcodeFormat.PDF417, BarcodeFormat.QR_CODE, BarcodeFormat.UPC_A,
|
|
|
+- BarcodeFormat.UPC_E};
|
|
|
+- callback.call(supportedFormats);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -54,23 +43,7 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider {
|
|
|
+ public void onConnectionError(MojoException e) {}
|
|
|
+
|
|
|
+ public static BarcodeDetectionProvider create() {
|
|
|
+- Context ctx = ContextUtils.getApplicationContext();
|
|
|
+- if (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(ctx)) {
|
|
|
+- Log.w(TAG, "Google Play Services not available");
|
|
|
+- return null;
|
|
|
+- }
|
|
|
+- try {
|
|
|
+- PackageInfo playServicesPackage = ctx.getPackageManager().getPackageInfo(
|
|
|
+- GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0);
|
|
|
+- if (playServicesPackage.versionCode < 19742000) {
|
|
|
+- // https://crbug.com/1020746
|
|
|
+- Log.w(TAG, "Detection disabled (%s < 19.7.42)", playServicesPackage.versionName);
|
|
|
+- return null;
|
|
|
+- }
|
|
|
+- } catch (NameNotFoundException e) {
|
|
|
+- Log.w(TAG, "Google Play Services not available");
|
|
|
+- return null;
|
|
|
+- }
|
|
|
+- return new BarcodeDetectionProviderImpl();
|
|
|
++ Log.w(TAG, "Google Play Services not available");
|
|
|
++ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java
|
|
|
+--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java
|
|
|
++++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java
|
|
|
+@@ -7,11 +7,6 @@ package org.chromium.shape_detection;
|
|
|
+ import android.graphics.PointF;
|
|
|
+ import android.util.SparseArray;
|
|
|
+
|
|
|
+-import com.google.android.gms.vision.Frame;
|
|
|
+-import com.google.android.gms.vision.face.Face;
|
|
|
+-import com.google.android.gms.vision.face.FaceDetector;
|
|
|
+-import com.google.android.gms.vision.face.Landmark;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.gfx.mojom.RectF;
|
|
|
+@@ -36,26 +31,10 @@ public class FaceDetectionImplGmsCore implements FaceDetection {
|
|
|
+ private static final int MAX_EULER_Z = 15;
|
|
|
+ private final int mMaxFaces;
|
|
|
+ private final boolean mFastMode;
|
|
|
+- private final FaceDetector mFaceDetector;
|
|
|
+
|
|
|
+- FaceDetectionImplGmsCore(FaceDetectorOptions options) {
|
|
|
+- FaceDetector.Builder builder =
|
|
|
+- new FaceDetector.Builder(ContextUtils.getApplicationContext());
|
|
|
++ FaceDetectionImplGmsCore(FaceDetectorOptions options) { FaceDetector.Builder builder = new FaceDetector.Builder(ContextUtils.getApplicationContext());
|
|
|
+ mMaxFaces = Math.min(options.maxDetectedFaces, MAX_FACES);
|
|
|
+ mFastMode = options.fastMode;
|
|
|
+-
|
|
|
+- try {
|
|
|
+- builder.setMode(mFastMode ? FaceDetector.FAST_MODE : FaceDetector.ACCURATE_MODE);
|
|
|
+- builder.setLandmarkType(FaceDetector.ALL_LANDMARKS);
|
|
|
+- if (mMaxFaces == 1) {
|
|
|
+- builder.setProminentFaceOnly(true);
|
|
|
+- }
|
|
|
+- } catch (IllegalArgumentException e) {
|
|
|
+- Log.e(TAG, "Unexpected exception " + e);
|
|
|
+- assert false;
|
|
|
+- }
|
|
|
+-
|
|
|
+- mFaceDetector = builder.build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -63,7 +42,7 @@ public class FaceDetectionImplGmsCore implements FaceDetection {
|
|
|
+ // The vision library will be downloaded the first time the API is used
|
|
|
+ // on the device; this happens "fast", but it might have not completed,
|
|
|
+ // bail in this case.
|
|
|
+- if (!mFaceDetector.isOperational()) {
|
|
|
++/* if (!mFaceDetector.isOperational()) {
|
|
|
+ Log.e(TAG, "FaceDetector is not operational");
|
|
|
+
|
|
|
+ // Fallback to Android's FaceDetectionImpl.
|
|
|
+@@ -131,12 +110,13 @@ public class FaceDetectionImplGmsCore implements FaceDetection {
|
|
|
+ faceArray[i].landmarks = mojoLandmarks.toArray(
|
|
|
+ new org.chromium.shape_detection.mojom.Landmark[mojoLandmarks.size()]);
|
|
|
+ }
|
|
|
+- callback.call(faceArray);
|
|
|
++ callback.call(faceArray); */
|
|
|
++ Log.e(TAG, "FaceDetector is not operational");
|
|
|
++ callback.call(new FaceDetectionResult[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void close() {
|
|
|
+- mFaceDetector.release();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java
|
|
|
+--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java
|
|
|
++++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java
|
|
|
+@@ -8,15 +8,10 @@ import android.graphics.Point;
|
|
|
+ import android.graphics.Rect;
|
|
|
+ import android.util.SparseArray;
|
|
|
+
|
|
|
+-import com.google.android.gms.vision.Frame;
|
|
|
+-import com.google.android.gms.vision.text.TextBlock;
|
|
|
+-import com.google.android.gms.vision.text.TextRecognizer;
|
|
|
+-
|
|
|
+ import org.chromium.base.ContextUtils;
|
|
|
+ import org.chromium.base.Log;
|
|
|
+ import org.chromium.gfx.mojom.PointF;
|
|
|
+ import org.chromium.gfx.mojom.RectF;
|
|
|
+-import org.chromium.gms.ChromiumPlayServicesAvailability;
|
|
|
+ import org.chromium.mojo.system.MojoException;
|
|
|
+ import org.chromium.shape_detection.mojom.TextDetection;
|
|
|
+ import org.chromium.shape_detection.mojom.TextDetectionResult;
|
|
|
+@@ -27,10 +22,7 @@ import org.chromium.shape_detection.mojom.TextDetectionResult;
|
|
|
+ public class TextDetectionImpl implements TextDetection {
|
|
|
+ private static final String TAG = "TextDetectionImpl";
|
|
|
+
|
|
|
+- private TextRecognizer mTextRecognizer;
|
|
|
+-
|
|
|
+ public TextDetectionImpl() {
|
|
|
+- mTextRecognizer = new TextRecognizer.Builder(ContextUtils.getApplicationContext()).build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -39,13 +31,10 @@ public class TextDetectionImpl implements TextDetection {
|
|
|
+ // on the device; this happens "fast", but it might have not completed,
|
|
|
+ // bail in this case. Also, the API was disabled between and v.9.0 and
|
|
|
+ // v.9.2, see https://developers.google.com/android/guides/releases.
|
|
|
+- if (!mTextRecognizer.isOperational()) {
|
|
|
+ Log.e(TAG, "TextDetector is not operational");
|
|
|
+ callback.call(new TextDetectionResult[0]);
|
|
|
+ return;
|
|
|
+- }
|
|
|
+-
|
|
|
+- Frame frame = BitmapUtils.convertToFrame(bitmapData);
|
|
|
++/* Frame frame = BitmapUtils.convertToFrame(bitmapData);
|
|
|
+ if (frame == null) {
|
|
|
+ Log.e(TAG, "Error converting Mojom Bitmap to Frame");
|
|
|
+ callback.call(new TextDetectionResult[0]);
|
|
|
+@@ -73,12 +62,11 @@ public class TextDetectionImpl implements TextDetection {
|
|
|
+ detectedTextArray[i].cornerPoints[j].y = corners[j].y;
|
|
|
+ }
|
|
|
+ }
|
|
|
+- callback.call(detectedTextArray);
|
|
|
++ callback.call(detectedTextArray); */
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void close() {
|
|
|
+- mTextRecognizer.release();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+@@ -87,11 +75,7 @@ public class TextDetectionImpl implements TextDetection {
|
|
|
+ }
|
|
|
+
|
|
|
+ public static TextDetection create() {
|
|
|
+- if (!ChromiumPlayServicesAvailability.isGooglePlayServicesAvailable(
|
|
|
+- ContextUtils.getApplicationContext())) {
|
|
|
+- Log.e(TAG, "Google Play Services not available");
|
|
|
+- return null;
|
|
|
+- }
|
|
|
+- return new TextDetectionImpl();
|
|
|
++ Log.e(TAG, "Google Play Services not available");
|
|
|
++ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/third_party/android_deps/BUILD.gn b/third_party/android_deps/BUILD.gn
|
|
|
+--- a/third_party/android_deps/BUILD.gn
|
|
|
++++ b/third_party/android_deps/BUILD.gn
|
|
|
+@@ -62,7 +62,6 @@ java_group("robolectric_all_java") {
|
|
|
+ ":org_robolectric_shadowapi_java",
|
|
|
+ ":org_robolectric_shadows_framework_java",
|
|
|
+ ":org_robolectric_shadows_multidex_java",
|
|
|
+- ":org_robolectric_shadows_playservices_java",
|
|
|
+ ":org_robolectric_utils_java",
|
|
|
+ ":org_robolectric_utils_reflector_java",
|
|
|
+ "//third_party/robolectric:android-all-10-robolectric-5803371_java",
|
|
|
+@@ -90,7 +89,7 @@ java_annotation_processor("auto_service_processor") {
|
|
|
+
|
|
|
+ android_library("chromium_play_services_availability_java") {
|
|
|
+ sources = [ "util/org/chromium/gms/ChromiumPlayServicesAvailability.java" ]
|
|
|
+- deps = [ "$google_play_services_package:google_play_services_base_java" ]
|
|
|
++ deps = [ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ android_library("chromium_play_services_availability_shadows_java") {
|
|
|
+@@ -1155,246 +1154,6 @@ java_prebuilt("com_android_tools_build_jetifier_jetifier_processor_java") {
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_auth_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_auth/play-services-auth-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_auth/com_google_android_gms_play_services_auth.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_fragment_fragment_java",
|
|
|
+- ":androidx_loader_loader_java",
|
|
|
+- ":google_play_services_auth_api_phone_java",
|
|
|
+- ":google_play_services_auth_base_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_auth_api_phone_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_auth_api_phone/play-services-auth-api-phone-17.5.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_auth_api_phone/com_google_android_gms_play_services_auth_api_phone.info"
|
|
|
+- deps = [
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_auth_base_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_auth_base/play-services-auth-base-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_auth_base/com_google_android_gms_play_services_auth_base.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_collection_collection_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_base_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_base/play-services-base-17.1.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_base/com_google_android_gms_play_services_base.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_collection_collection_java",
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":androidx_fragment_fragment_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_basement_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_basement/play-services-basement-17.1.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_basement/com_google_android_gms_play_services_basement.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_collection_collection_java",
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":androidx_fragment_fragment_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-
|
|
|
+- # https://crbug.com/989505
|
|
|
+- jar_excluded_patterns = [ "META-INF/proguard/*" ]
|
|
|
+- input_jars_paths = [ "$android_sdk/optional/org.apache.http.legacy.jar" ]
|
|
|
+- bytecode_rewriter_target =
|
|
|
+- "//build/android/bytecode:fragment_activity_replacer"
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_cast_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_cast/play-services-cast-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_cast/com_google_android_gms_play_services_cast.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":androidx_mediarouter_mediarouter_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_flags_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_cast_framework_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_cast_framework/play-services-cast-framework-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_cast_framework/com_google_android_gms_play_services_cast_framework.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_appcompat_appcompat_java",
|
|
|
+- ":androidx_collection_collection_java",
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":androidx_fragment_fragment_java",
|
|
|
+- ":androidx_media_media_java",
|
|
|
+- ":androidx_mediarouter_mediarouter_java",
|
|
|
+- ":androidx_recyclerview_recyclerview_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_cast_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing all resources from cast framework as they are unused bloat.
|
|
|
+- # Can only safely remove them when R8 will strip the path that accesses them.
|
|
|
+- strip_resources = !is_java_debug
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_fido_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_fido/play-services-fido-18.1.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_fido/com_google_android_gms_play_services_fido.info"
|
|
|
+- deps = [
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_gcm_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_gcm/play-services-gcm-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_gcm/com_google_android_gms_play_services_gcm.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_collection_collection_java",
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":androidx_legacy_legacy_support_core_utils_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_iid_java",
|
|
|
+- ":google_play_services_stats_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_iid_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_iid/play-services-iid-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_iid/com_google_android_gms_play_services_iid.info"
|
|
|
+- deps = [
|
|
|
+- ":androidx_collection_collection_java",
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_stats_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_instantapps_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_instantapps/play-services-instantapps-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_instantapps/com_google_android_gms_play_services_instantapps.info"
|
|
|
+- deps = [
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_location_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_location/play-services-location-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_location/com_google_android_gms_play_services_location.info"
|
|
|
+- deps = [
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_places_placereport_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_tasks_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_tasks/play-services-tasks-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_tasks/com_google_android_gms_play_services_tasks.info"
|
|
|
+- deps = [ ":google_play_services_basement_java" ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_vision_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_vision/play-services-vision-18.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_vision/com_google_android_gms_play_services_vision.info"
|
|
|
+- deps = [
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_vision_common_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_vision_common_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_vision_common/play-services-vision-common-18.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_vision_common/com_google_android_gms_play_services_vision_common.info"
|
|
|
+- deps = [
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_clearcut_java",
|
|
|
+- ":google_play_services_flags_java",
|
|
|
+- ":google_play_services_phenotype_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+ # This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+ android_aar_prebuilt("com_google_android_material_material_java") {
|
|
|
+ aar_path =
|
|
|
+@@ -1806,20 +1565,6 @@ java_prebuilt("org_robolectric_shadows_multidex_java") {
|
|
|
+ bypass_platform_checks = true
|
|
|
+ }
|
|
|
+
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-java_prebuilt("org_robolectric_shadows_playservices_java") {
|
|
|
+- jar_path =
|
|
|
+- "libs/org_robolectric_shadows_playservices/shadows-playservices-4.3.1.jar"
|
|
|
+- output_name = "org_robolectric_shadows_playservices"
|
|
|
+- enable_bytecode_checks = false
|
|
|
+- testonly = true
|
|
|
+- deps = [
|
|
|
+- ":com_google_guava_guava_java",
|
|
|
+- ":org_robolectric_annotations_java",
|
|
|
+- ]
|
|
|
+- bypass_platform_checks = true
|
|
|
+-}
|
|
|
+-
|
|
|
+ # This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+ java_prebuilt("org_robolectric_utils_java") {
|
|
|
+ jar_path = "libs/org_robolectric_utils/utils-4.3.1.jar"
|
|
|
+@@ -2352,93 +2097,6 @@ java_prebuilt("com_github_kevinstern_software_and_algorithms_java") {
|
|
|
+ visibility = [ ":*" ]
|
|
|
+ }
|
|
|
+
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_clearcut_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_clearcut/play-services-clearcut-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_clearcut/com_google_android_gms_play_services_clearcut.info"
|
|
|
+-
|
|
|
+- # To remove visibility constraint, add this dependency to
|
|
|
+- # //third_party/android_deps/build.gradle.
|
|
|
+- visibility = [ ":*" ]
|
|
|
+- deps = [
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_phenotype_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_flags_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_flags/play-services-flags-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_flags/com_google_android_gms_play_services_flags.info"
|
|
|
+-
|
|
|
+- # To remove visibility constraint, add this dependency to
|
|
|
+- # //third_party/android_deps/build.gradle.
|
|
|
+- visibility = [ ":*" ]
|
|
|
+- deps = [
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_phenotype_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_phenotype/play-services-phenotype-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_phenotype/com_google_android_gms_play_services_phenotype.info"
|
|
|
+-
|
|
|
+- # To remove visibility constraint, add this dependency to
|
|
|
+- # //third_party/android_deps/build.gradle.
|
|
|
+- visibility = [ ":*" ]
|
|
|
+- deps = [
|
|
|
+- ":androidx_core_core_java",
|
|
|
+- ":google_play_services_base_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ":google_play_services_tasks_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_places_placereport_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_places_placereport/play-services-places-placereport-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_places_placereport/com_google_android_gms_play_services_places_placereport.info"
|
|
|
+-
|
|
|
+- # To remove visibility constraint, add this dependency to
|
|
|
+- # //third_party/android_deps/build.gradle.
|
|
|
+- visibility = [ ":*" ]
|
|
|
+- deps = [ ":google_play_services_basement_java" ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+-android_aar_prebuilt("google_play_services_stats_java") {
|
|
|
+- aar_path = "libs/com_google_android_gms_play_services_stats/play-services-stats-17.0.0.aar"
|
|
|
+- info_path = "libs/com_google_android_gms_play_services_stats/com_google_android_gms_play_services_stats.info"
|
|
|
+-
|
|
|
+- # To remove visibility constraint, add this dependency to
|
|
|
+- # //third_party/android_deps/build.gradle.
|
|
|
+- visibility = [ ":*" ]
|
|
|
+- deps = [
|
|
|
+- ":androidx_legacy_legacy_support_core_utils_java",
|
|
|
+- ":google_play_services_basement_java",
|
|
|
+- ]
|
|
|
+-
|
|
|
+- # Removing drawables from GMS .aars as they are unused bloat.
|
|
|
+- strip_drawables = true
|
|
|
+-}
|
|
|
+-
|
|
|
+ # This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
|
+ java_prebuilt("com_google_auto_auto_common_java") {
|
|
|
+ jar_path = "libs/com_google_auto_auto_common/auto-common-0.10.jar"
|
|
|
+diff --git a/third_party/android_deps/util/org/chromium/gms/ChromiumPlayServicesAvailability.java b/third_party/android_deps/util/org/chromium/gms/ChromiumPlayServicesAvailability.java
|
|
|
+--- a/third_party/android_deps/util/org/chromium/gms/ChromiumPlayServicesAvailability.java
|
|
|
++++ b/third_party/android_deps/util/org/chromium/gms/ChromiumPlayServicesAvailability.java
|
|
|
+@@ -5,9 +5,6 @@ package org.chromium.gms;
|
|
|
+
|
|
|
+ import android.content.Context;
|
|
|
+
|
|
|
+-import com.google.android.gms.common.ConnectionResult;
|
|
|
+-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
+-
|
|
|
+ // Refer to go/doubledown-play-services#new-apis for more detail.
|
|
|
+ public final class ChromiumPlayServicesAvailability {
|
|
|
+ /**
|
|
|
+@@ -30,9 +27,7 @@ public final class ChromiumPlayServicesAvailability {
|
|
|
+ * PM/UX.
|
|
|
+ */
|
|
|
+ public static boolean isGooglePlayServicesAvailable(final Context context) {
|
|
|
+- return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
|
|
|
+- context, GMS_VERSION_NUMBER)
|
|
|
+- == ConnectionResult.SUCCESS;
|
|
|
++ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -50,7 +45,6 @@ public final class ChromiumPlayServicesAvailability {
|
|
|
+ * PM/UX.
|
|
|
+ */
|
|
|
+ public static int getGooglePlayServicesConnectionResult(final Context context) {
|
|
|
+- return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
|
|
|
+- context, GMS_VERSION_NUMBER);
|
|
|
++ return 16; // API_UNAVAILABLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/third_party/android_sdk/BUILD.gn b/third_party/android_sdk/BUILD.gn
|
|
|
+--- a/third_party/android_sdk/BUILD.gn
|
|
|
++++ b/third_party/android_sdk/BUILD.gn
|
|
|
+@@ -63,7 +63,4 @@ if (enable_java_templates) {
|
|
|
+ testonly = true
|
|
|
+ sources = [ "//third_party/android_sdk/public/extras/chromium/support/src/org/chromium/android/support/PackageManagerWrapper.java" ]
|
|
|
+ }
|
|
|
+- android_java_prebuilt("android_gcm_java") {
|
|
|
+- jar_path = "//third_party/android_sdk/public/extras/google/gcm/gcm-client/dist/gcm.jar"
|
|
|
+- }
|
|
|
+ }
|
|
|
+diff --git a/third_party/google_android_play_core/BUILD.gn b/third_party/google_android_play_core/BUILD.gn
|
|
|
+--- a/third_party/google_android_play_core/BUILD.gn
|
|
|
++++ b/third_party/google_android_play_core/BUILD.gn
|
|
|
+@@ -3,8 +3,3 @@
|
|
|
+ # found in the LICENSE file.
|
|
|
+
|
|
|
+ import("//build/config/android/rules.gni")
|
|
|
+-
|
|
|
+-android_aar_prebuilt("com_google_android_play_core_java") {
|
|
|
+- aar_path = "core-1.6.4.aar"
|
|
|
+- info_path = "com_google_android_play_core.info"
|
|
|
+-}
|
|
|
+--
|
|
|
+2.17.1
|
|
|
+
|