From d3cc9b20e464d735573032a87b40495ba84e9805 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Mon, 30 Oct 2023 11:35:43 +0800 Subject: [PATCH] Async load eid in SimEidPreferenceController Avoid data loading in getAvailabilityStatus() to prevent ANR, override updateNonIndexableKeys() for search availability. Fix: 304560734 Test: manual - on "About phone" page (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b6e44ce818a5284a612a31e0d451a33f9e1ce93e) Merged-In: I9994abf3787f5db0edc71ff48d08e549a4b70bf7 Change-Id: I9994abf3787f5db0edc71ff48d08e549a4b70bf7 --- res/xml/my_device_info.xml | 2 +- .../simstatus/SimEidPreferenceController.kt | 99 +++++++++++++------ .../telephony/TelephonyPreferenceDialog.java | 44 --------- 3 files changed, 71 insertions(+), 74 deletions(-) delete mode 100644 src/com/android/settings/network/telephony/TelephonyPreferenceDialog.java diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml index 6576742e404..6edb5b7023a 100644 --- a/res/xml/my_device_info.xml +++ b/res/xml/my_device_info.xml @@ -114,7 +114,7 @@ settings:controller="com.android.settings.deviceinfo.HardwareInfoPreferenceController"/> - ) { + if (!getIsAvailableAndUpdateEid()) { + keys.add(preferenceKey) } - return super.handlePreferenceTreeClick(preference) } companion object { @@ -122,11 +161,13 @@ class SimEidPreferenceController(context: Context, preferenceKey: String) : * @param eid is the EID string * @return a Bitmap of QR code */ - private fun getEidQrCode(eid: String): Bitmap? = try { - QrCodeGenerator.encodeQrCode(eid, QR_CODE_SIZE) - } catch (exception: Exception) { - Log.w(TAG, "Error when creating QR code width $QR_CODE_SIZE", exception) - null + private suspend fun getEidQrCode(eid: String): Bitmap? = withContext(Dispatchers.Default) { + try { + QrCodeGenerator.encodeQrCode(contents = eid, size = QR_CODE_SIZE) + } catch (exception: Exception) { + Log.w(TAG, "Error when creating QR code width $QR_CODE_SIZE", exception) + null + } } } } diff --git a/src/com/android/settings/network/telephony/TelephonyPreferenceDialog.java b/src/com/android/settings/network/telephony/TelephonyPreferenceDialog.java deleted file mode 100644 index 7dbef0c9de5..00000000000 --- a/src/com/android/settings/network/telephony/TelephonyPreferenceDialog.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.network.telephony; - -import android.content.Context; -import android.util.AttributeSet; -import com.android.settingslib.CustomDialogPreferenceCompat; - -/** - * This is DialogPreference for supporting connectivity features. - */ -public class TelephonyPreferenceDialog extends CustomDialogPreferenceCompat { - - public TelephonyPreferenceDialog(Context context, AttributeSet attrs, int defStyleAttr, - int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - - public TelephonyPreferenceDialog(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - public TelephonyPreferenceDialog(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public TelephonyPreferenceDialog(Context context) { - super(context); - } -}