Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit c23cf812 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Michael Bestas
Browse files

SystemUI: fix MediaProjection cast crash

Clicking on the "cast" icon of an app using the MediaProjection API will
crash as the code assume that it is a device.

java.lang.ClassCastException: android.media.projection.MediaProjectionInfo cannot be cast to android.media.MediaRouter$RouteInfo
	at com.android.systemui.statusbar.policy.CastControllerImpl.startCasting(CastControllerImpl.java:177)
	at com.android.systemui.qs.tiles.CastTile$CastDetailAdapter.onDetailItemClick(CastTile.java:237)
	at com.android.systemui.qs.QSDetailItems$1.onClick(QSDetailItems.java:177)
	at android.view.View.performClick(View.java:4756)
	at android.view.View$PerformClick.run(View.java:19749)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5221)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)

Change-Id: Icfdf745c03da7bd1bbb228e06005f55324c1b8fa
parent cafc92d3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -164,7 +164,7 @@ public class CastControllerImpl implements CastController {


    @Override
    @Override
    public void startCasting(CastDevice device) {
    public void startCasting(CastDevice device) {
        if (device == null || device.tag == null) return;
        if (device == null || !(device.tag instanceof RouteInfo)) return;
        final RouteInfo route = (RouteInfo) device.tag;
        final RouteInfo route = (RouteInfo) device.tag;
        if (DEBUG) Log.d(TAG, "startCasting: " + routeToString(route));
        if (DEBUG) Log.d(TAG, "startCasting: " + routeToString(route));
        mMediaRouter.selectRoute(ROUTE_TYPE_REMOTE_DISPLAY, route);
        mMediaRouter.selectRoute(ROUTE_TYPE_REMOTE_DISPLAY, route);