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

Commit 5fc39c6f authored by Chelsea Hao's avatar Chelsea Hao Committed by Android (Google) Code Review
Browse files

Merge "Allow `notifyBroadcastStateChange` from sysui, also moved the...

Merge "Allow `notifyBroadcastStateChange` from sysui, also moved the triggering to `onBroadcastStarted`." into main
parents cdd481c6 91a51c62
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
    public @interface BroadcastState {}

    private static final String SETTINGS_PKG = "com.android.settings";
    private static final String SYSUI_PKG = "com.android.systemui";
    private static final String TAG = "LocalBluetoothLeBroadcast";
    private static final boolean DEBUG = BluetoothUtils.D;

@@ -216,6 +217,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
                    }
                    setLatestBroadcastId(broadcastId);
                    setAppSourceName(mNewAppSourceName, /* updateContentResolver= */ true);
                    notifyBroadcastStateChange(BROADCAST_STATE_ON);
                }

                @Override
@@ -232,7 +234,6 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
                        Log.d(TAG, "onBroadcastMetadataChanged(), broadcastId = " + broadcastId);
                    }
                    setLatestBluetoothLeBroadcastMetadata(metadata);
                    notifyBroadcastStateChange(BROADCAST_STATE_ON);
                }

                @Override
@@ -1247,8 +1248,9 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
    }

    private void notifyBroadcastStateChange(@BroadcastState int state) {
        if (!mContext.getPackageName().equals(SETTINGS_PKG)) {
            Log.d(TAG, "Skip notifyBroadcastStateChange, not triggered by Settings.");
        String packageName = mContext.getPackageName();
        if (!packageName.equals(SETTINGS_PKG) && !packageName.equals(SYSUI_PKG)) {
            Log.d(TAG, "Skip notifyBroadcastStateChange, not triggered by Settings or SystemUI.");
            return;
        }
        if (isWorkProfile(mContext)) {
@@ -1257,8 +1259,8 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
        }
        Intent intent = new Intent(ACTION_LE_AUDIO_SHARING_STATE_CHANGE);
        intent.putExtra(EXTRA_LE_AUDIO_SHARING_STATE, state);
        intent.setPackage(mContext.getPackageName());
        Log.d(TAG, "notifyBroadcastStateChange for state = " + state);
        intent.setPackage(SETTINGS_PKG);
        Log.d(TAG, "notifyBroadcastStateChange for state = " + state + " by pkg = " + packageName);
        mContext.sendBroadcast(intent);
    }