Protect possible NPE in MediaOutputDialogReceiver
-Do nothing if package name is empty Bug: 181654879 Test: manual test Change-Id: I4c36a811d71e28e800d0b8398c998da3263218d8
This commit is contained in:
@@ -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.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user