From e2f880857b7fe92db4f06da42ae7ca64a40da001 Mon Sep 17 00:00:00 2001 From: peterhel <2047120+peterhel@users.noreply.github.com> Date: Tue, 23 Jun 2026 14:03:08 +0200 Subject: [PATCH] Cast: return a no-op ReconnectionService instead of null CastDynamiteModuleImpl.newReconnectionServiceImpl returned null, but the Cast SDK's ReconnectionService calls onCreate() on the returned delegate without a null check. So any client that starts the ReconnectionService (common on the connectionless Cast.API_CXLESS path used by Prime/YouTube/etc.) crashes with an NPE in ReconnectionService.onCreate, which destabilises the whole cast session. Return a minimal no-op IReconnectionService (no-op onCreate/onDestroy, onStartCommand=START_NOT_STICKY, onBind=null). microG doesn't drive reconnection itself, so the no-op is sufficient and keeps connectionless sessions stable. Tested on-device (Pixel 2 + Chromecast): with this in place, casting a clip via the connectionless path no longer crash-loops the sender and plays cleanly; without it the sender NPE-loops and the cast callbacks throw RemoteException. Co-Authored-By: Claude Opus 4.8 --- .../internal/CastDynamiteModuleImpl.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/play-services-cast-framework/core/src/main/java/com/google/android/gms/cast/framework/internal/CastDynamiteModuleImpl.java b/play-services-cast-framework/core/src/main/java/com/google/android/gms/cast/framework/internal/CastDynamiteModuleImpl.java index e7dcf488be..63ab7a4ef0 100644 --- a/play-services-cast-framework/core/src/main/java/com/google/android/gms/cast/framework/internal/CastDynamiteModuleImpl.java +++ b/play-services-cast-framework/core/src/main/java/com/google/android/gms/cast/framework/internal/CastDynamiteModuleImpl.java @@ -17,6 +17,8 @@ package com.google.android.gms.cast.framework.internal; import android.content.Context; +import android.content.Intent; +import android.os.IBinder; import android.os.RemoteException; import android.util.Log; @@ -65,8 +67,27 @@ public IMediaNotificationService newMediaNotificationServiceImpl(IObjectWrapper @Override public IReconnectionService newReconnectionServiceImpl(IObjectWrapper service, IObjectWrapper sessionManager, IObjectWrapper discoveryManager) throws RemoteException { - Log.d(TAG, "unimplemented Method: newReconnectionServiceImpl"); - return null; + // Return a minimal no-op service rather than null: the Cast SDK's ReconnectionService calls + // onCreate() on this delegate without a null check, so returning null crashes the client app + // (NPE in ReconnectionService.onCreate). microG doesn't drive reconnection itself, so a no-op + // delegate is sufficient and keeps connectionless Cast sessions stable. + return new IReconnectionService.Stub() { + @Override + public void onCreate() {} + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + return android.app.Service.START_NOT_STICKY; + } + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + @Override + public void onDestroy() {} + }; } @Override