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

Commit 98898e15 authored by kaiyiz's avatar kaiyiz Committed by Steve Kondik
Browse files

SystemUI: Update cast tile when wifi display status changes

Cast tile in quick setting does not watch for wifi display status changes.
As a result, it will not update when wifi display status changes.

Register a broadcast to watch for wifi display status changes as settings
and update remote displays when wifi display status changes.

CRs-Fixed: 718032

Change-Id: Ib2ca4677be91817c007db941531849bbc7eff5d3
parent bad724c3
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -18,10 +18,14 @@ package com.android.systemui.statusbar.policy;

import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.hardware.display.DisplayManager;
import android.media.MediaRouter;
import android.media.MediaRouter.RouteInfo;
import android.media.projection.MediaProjectionInfo;
@@ -65,6 +69,11 @@ public class CastControllerImpl implements CastController {
                context.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
        mProjection = mProjectionManager.getActiveProjectionInfo();
        mProjectionManager.addCallback(mProjectionCallback, new Handler());

        IntentFilter filter = new IntentFilter();
        filter.addAction(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED);
        context.registerReceiver(mReceiver, filter);

        if (DEBUG) Log.d(TAG, "new CastController()");
    }

@@ -270,6 +279,16 @@ public class CastControllerImpl implements CastController {
        return sb.append(",id=").append(route.getTag()).toString();
    }

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED)) {
                updateRemoteDisplays();
            }
        }
    };

    private final MediaRouter.SimpleCallback mMediaCallback = new MediaRouter.SimpleCallback() {
        @Override
        public void onRouteAdded(MediaRouter router, RouteInfo route) {