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

Commit 5771d1b9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Protect possible NPE in MediaOutputDialogReceiver" into sc-dev am: 0e7fce7b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13749982

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I01dd22d32ef839c288913ee15defe4f72428d857
parents 3795a4b9 0e7fce7b
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -20,9 +20,13 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import android.util.Log
import com.android.settingslib.media.MediaOutputConstants
import javax.inject.Inject

private const val TAG = "MediaOutputDlgReceiver"
private val DEBUG = Log.isLoggable(TAG, Log.DEBUG)

/**
 * BroadcastReceiver for handling media output intent
 */
@@ -32,8 +36,13 @@ class MediaOutputDialogReceiver @Inject constructor(
    override fun onReceive(context: Context, intent: Intent) {
        if (TextUtils.equals(MediaOutputConstants.ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG,
                        intent.action)) {
            mediaOutputDialogFactory.create(
                    intent.getStringExtra(MediaOutputConstants.EXTRA_PACKAGE_NAME), false)
            val packageName: String? =
                    intent.getStringExtra(MediaOutputConstants.EXTRA_PACKAGE_NAME)
            if (!TextUtils.isEmpty(packageName)) {
                mediaOutputDialogFactory.create(packageName!!, false)
            } else if (DEBUG) {
                Log.e(TAG, "Unable to launch media output dialog. Package name is empty.")
            }
        }
    }
}