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

Commit d0c73d63 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Only deliver latest WIFI_DISPLAY_STATUS_CHANGED.

We've heard reports of apps getting confused about hearing thrashing
WIFI_DISPLAY_STATUS_CHANGED broadcasts when they're thawed.  To
mitigate this, only deliver the latest instance of the broadcast,
replacing any stale broadcasts.

Bug: 273923757
Test: manual
Change-Id: Ie8e4a7213f7b4838b33fdc6cf4ccca9520ad49f9
parent 3f88c155
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.display;

import android.app.BroadcastOptions;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -421,6 +422,7 @@ final class WifiDisplayAdapter extends DisplayAdapter {
    // Runs on the handler.
    private void handleSendStatusChangeBroadcast() {
        final Intent intent;
        final BroadcastOptions options;
        synchronized (getSyncRoot()) {
            if (!mPendingStatusChangeBroadcast) {
                return;
@@ -431,10 +433,13 @@ final class WifiDisplayAdapter extends DisplayAdapter {
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
            intent.putExtra(DisplayManager.EXTRA_WIFI_DISPLAY_STATUS,
                    getWifiDisplayStatusLocked());

            options = BroadcastOptions.makeBasic();
            options.setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT);
        }

        // Send protected broadcast about wifi display status to registered receivers.
        getContext().sendBroadcastAsUser(intent, UserHandle.ALL);
        getContext().sendBroadcastAsUser(intent, UserHandle.ALL, null, options.toBundle());
    }

    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {