From fc74261655883f332ce9a87654e837a03c697e0b Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Wed, 18 Apr 2018 16:01:49 -0400 Subject: [PATCH] More interface details for the cast framework --- .gitignore | 1 + build.gradle | 2 +- extern/GmsApi | 2 +- extern/GmsLib | 2 +- play-services-core/build.gradle | 2 + .../src/main/AndroidManifest.xml | 8 ++ .../framework/internal/CastContextImpl.java | 126 ++++++++++++++++++ .../internal/CastDynamiteModuleImpl.java | 80 +++-------- .../framework/internal/CastSessionImpl.java | 23 ++++ .../internal/DiscoveryManagerImpl.java | 69 ++++++++++ .../internal/MediaRouterCallbackImpl.java | 49 +++++++ .../cast/framework/internal/SessionImpl.java | 49 +++++++ .../internal/SessionManagerImpl.java | 79 +++++++++++ .../media/CastMediaRouteProviderService.java | 32 +++++ .../gms/cast/CastMediaRouteProvider.java | 103 ++++++++++++++ 15 files changed, 564 insertions(+), 63 deletions(-) create mode 100644 play-services-core/src/main/java/com/google/android/gms/cast/framework/internal/CastContextImpl.java create mode 100644 play-services-core/src/main/java/com/google/android/gms/cast/framework/internal/CastSessionImpl.java create mode 100644 play-services-core/src/main/java/com/google/android/gms/cast/framework/internal/DiscoveryManagerImpl.java create mode 100644 play-services-core/src/main/java/com/google/android/gms/cast/framework/internal/MediaRouterCallbackImpl.java create mode 100644 play-services-core/src/main/java/com/google/android/gms/cast/framework/internal/SessionImpl.java create mode 100644 play-services-core/src/main/java/com/google/android/gms/cast/framework/internal/SessionManagerImpl.java create mode 100644 play-services-core/src/main/java/com/google/android/gms/cast/media/CastMediaRouteProviderService.java create mode 100644 play-services-core/src/main/java/org/microg/gms/cast/CastMediaRouteProvider.java diff --git a/.gitignore b/.gitignore index 6265e60a..25ed3657 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ gen/ bin/ build/ .gradle/ +.idea/ user.gradle local.properties .directory diff --git a/build.gradle b/build.gradle index eb2ee5dc..98380e1f 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ def androidCompileSdk() { return 27 } def androidTargetSdk() { return 27 } -def androidMinSdk() { return 9 } +def androidMinSdk() { return 14 } def versionCode() { def stdout = new ByteArrayOutputStream() diff --git a/extern/GmsApi b/extern/GmsApi index db0be6ba..a811b2f6 160000 --- a/extern/GmsApi +++ b/extern/GmsApi @@ -1 +1 @@ -Subproject commit db0be6ba010f52b4d12e69aed2482c38a3c2406c +Subproject commit a811b2f64572a10e34a0fd9a0eac189735849f5b diff --git a/extern/GmsLib b/extern/GmsLib index 90e9b7b7..a3b7236b 160000 --- a/extern/GmsLib +++ b/extern/GmsLib @@ -1 +1 @@ -Subproject commit 90e9b7b79dcaddfce887f87b94f80adeed8791e6 +Subproject commit a3b7236b5efa09bcd2bcb65c4946b41c63e3e98f diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle index b43dfe90..6444474d 100644 --- a/play-services-core/build.gradle +++ b/play-services-core/build.gradle @@ -19,12 +19,14 @@ apply plugin: 'com.android.application' dependencies { implementation "com.android.support:support-v4:$supportLibraryVersion" implementation "com.android.support:appcompat-v7:$supportLibraryVersion" + implementation "com.android.support:mediarouter-v7:$supportLibraryVersion" implementation "com.takisoft.fix:preference-v7:$supportLibraryVersion.0" implementation "de.hdodenhof:circleimageview:1.3.0" implementation "com.squareup.wire:wire-runtime:1.6.1" implementation project(':microg-ui-tools') implementation project(':play-services-api') + implementation project(':play-services-cast-api') implementation project(':play-services-wearable') implementation project(':unifiednlp-base') implementation project(':wearable-lib') diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index 2a8b7dd6..5f1ebe13 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -395,6 +395,14 @@ + + + + + + + + CONTROL_FILTERS; + static { + IntentFilter f2 = new IntentFilter(); + f2.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); + f2.addAction(MediaControlIntent.ACTION_PLAY); + + CONTROL_FILTERS = new ArrayList(); + CONTROL_FILTERS.add(f2); + } + + @Override + public void onDiscoveryRequestChanged(MediaRouteDiscoveryRequest request) { + Log.d(TAG, "unimplemented Method: onDiscoveryRequestChanged"); + } + + @Override + public RouteController onCreateRouteController(String routeId) { + Log.d(TAG, "unimplemented Method: onCreateRouteController"); + return null; + } + + /** + * TODO: Currently this method simply publishes a single cast route for + * testing. + */ + private void publishRoutes() { + Log.d(TAG, "unimplemented Method: publishRoutes"); + Bundle extras = new Bundle(); + CastDevice castDevice = new CastDevice("abc123"); + castDevice.putInBundle(extras); + MediaRouteDescriptor routeDescriptor1 = new MediaRouteDescriptor.Builder( + "abc123", + "Rotue Friendly Name") + .setDescription("Chromecast") + .addControlFilters(CONTROL_FILTERS) + .setDeviceType(MediaRouter.RouteInfo.DEVICE_TYPE_TV) + .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE) + .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED) + .setVolumeMax(20) + .setVolume(0) + .setEnabled(true) + .setExtras(extras) + .setConnectionState(MediaRouter.RouteInfo.CONNECTION_STATE_DISCONNECTED) + .build(); + MediaRouteProviderDescriptor providerDescriptor = + new MediaRouteProviderDescriptor.Builder() + .addRoute(routeDescriptor1) + .build(); + this.setDescriptor(providerDescriptor); + } +}