Allow overriding DeviceDiagnosticsPreferenceController.

Allow devices to specify their own flags by overriding this class.
Additionally, fix a missing PackageManager lookup in getIntent().

Bug: 348647186
Test: launch Settings on Pixel and on AOSP
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:287181169485eb30203c7b698b1f8ee618059e29)
Merged-In: I2489a64804f068a957f9be3f87847d6911b24447
Change-Id: I2489a64804f068a957f9be3f87847d6911b24447
This commit is contained in:
David Anderson
2024-06-25 17:32:23 +00:00
committed by Android Build Coastguard Worker
parent 6c50d62205
commit 80e709f926

View File

@@ -26,7 +26,7 @@ import com.android.settings.R
import com.android.settings.core.BasePreferenceController
import com.android.settings.flags.Flags
class DeviceDiagnosticsPreferenceController(context: Context, preferenceKey: String) :
open class DeviceDiagnosticsPreferenceController(context: Context, preferenceKey: String) :
BasePreferenceController(context, preferenceKey) {
override fun getAvailabilityStatus(): Int {
@@ -59,6 +59,12 @@ class DeviceDiagnosticsPreferenceController(context: Context, preferenceKey: Str
val packageName = mContext.getResources().getString(
R.string.config_device_diagnostics_package_name)
intent.setPackage(packageName)
val info = mContext.getPackageManager().resolveActivity(intent, 0)
if (info == null) {
return null
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return intent
}