Loading res/layout/dialog_sim_status.xml +0 −9 Original line number Diff line number Diff line Loading @@ -156,15 +156,6 @@ android:layout_height="wrap_content" android:text="@string/device_info_not_available"/> <TextView style="@style/device_info_dialog_label" android:id="@+id/esim_id_label" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/status_esim_id"/> <include layout="@xml/esim_eid_and_qrcode" /> <TextView style="@style/device_info_dialog_label" android:id="@+id/ims_reg_state_label" Loading res/xml/esim_eid_and_qrcode.xmldeleted 100644 → 0 +0 −33 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> <merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <TextView style="@style/device_info_dialog_value" android:id="@+id/esim_id_value" android:layout_width="match_parent" android:layout_height="wrap_content" android:textIsSelectable="true" android:text="@string/device_info_not_available"/> <ImageView android:id="@+id/esim_id_qrcode" android:layout_width="match_parent" android:layout_height="wrap_content" tools:ignore="ContentDescription" /> </merge> src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java +1 −94 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.annotation.Nullable; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; Loading @@ -47,7 +46,6 @@ import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.TelephonyCallback; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.UiccCardInfo; import android.telephony.euicc.EuiccManager; import android.telephony.ims.ImsException; import android.telephony.ims.ImsMmTelManager; Loading @@ -64,17 +62,13 @@ import com.android.settings.R; import com.android.settingslib.DeviceInfoUtils; import com.android.settingslib.Utils; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.utils.ThreadUtils; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; /** * Controller for Sim Status information within the About Phone Settings page. */ public class SimStatusDialogController implements LifecycleObserver, DialogInterface.OnShowListener { public class SimStatusDialogController implements LifecycleObserver { private final static String TAG = "SimStatusDialogCtrl"; Loading Loading @@ -105,12 +99,6 @@ public class SimStatusDialogController implements LifecycleObserver, @VisibleForTesting final static int ICCID_INFO_VALUE_ID = R.id.icc_id_value; @VisibleForTesting final static int EID_INFO_LABEL_ID = R.id.esim_id_label; @VisibleForTesting final static int EID_INFO_VALUE_ID = R.id.esim_id_value; @VisibleForTesting final static int EID_INFO_QRCODE_ID = R.id.esim_id_qrcode; @VisibleForTesting final static int IMS_REGISTRATION_STATE_LABEL_ID = R.id.ims_reg_state_label; @VisibleForTesting final static int IMS_REGISTRATION_STATE_VALUE_ID = R.id.ims_reg_state_value; Loading Loading @@ -162,7 +150,6 @@ public class SimStatusDialogController implements LifecycleObserver, private boolean mShowLatestAreaInfo; private boolean mIsRegisteredListener = false; private AtomicReference<String> mEid = null; private final BroadcastReceiver mAreaInfoReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -239,8 +226,6 @@ public class SimStatusDialogController implements LifecycleObserver, } public void initialize() { requestForUpdateEid(); if (mSubscriptionInfo == null) { return; } Loading Loading @@ -268,19 +253,6 @@ public class SimStatusDialogController implements LifecycleObserver, updateImsRegistrationState(); } /** * Callback when dialog end of show(). */ public void onShow(DialogInterface dialog) { if (mEid != null) { String eidText = mEid.get(); if (eidText != null) { // Present QR code after the completion of layout mDialog.setQrCode(EID_INFO_QRCODE_ID, eidText); } } } /** * Deinitialization works */ Loading Loading @@ -633,71 +605,6 @@ public class SimStatusDialogController implements LifecycleObserver, } } @VisibleForTesting protected void requestForUpdateEid() { ThreadUtils.postOnBackgroundThread(() -> { mEid = getEid(mSlotIndex); ThreadUtils.postOnMainThread(() -> updateEid(mEid)); }); } @VisibleForTesting public AtomicReference<String> getEid(int slotIndex) { boolean shouldHaveEid = false; String eid = null; if (getTelephonyManager().getActiveModemCount() > MAX_PHONE_COUNT_SINGLE_SIM) { // Get EID per-SIM in multi-SIM mode final Map<Integer, Integer> mapping = mTelephonyManager .getLogicalToPhysicalSlotMapping(); final int pSlotId = mapping.getOrDefault(slotIndex, SubscriptionManager.INVALID_SIM_SLOT_INDEX); if (pSlotId != SubscriptionManager.INVALID_SIM_SLOT_INDEX) { final List<UiccCardInfo> infos = getTelephonyManager().getUiccCardsInfo(); for (UiccCardInfo info : infos) { if (info.getPhysicalSlotIndex() == pSlotId) { if (info.isEuicc()) { shouldHaveEid = true; eid = info.getEid(); if (TextUtils.isEmpty(eid)) { eid = mEuiccManager.createForCardId(info.getCardId()).getEid(); } } break; } } } } else if (mEuiccManager.isEnabled()) { // Get EID of default eSIM in single-SIM mode shouldHaveEid = true; eid = mEuiccManager.getEid(); } if ((!shouldHaveEid) && (eid == null)) { return null; } return new AtomicReference<String>(eid); } @VisibleForTesting protected void updateEid(AtomicReference<String> eid) { boolean removeQrCode = true; if (eid == null) { mDialog.removeSettingFromScreen(EID_INFO_LABEL_ID); mDialog.removeSettingFromScreen(EID_INFO_VALUE_ID); mDialog.removeSettingFromScreen(EID_INFO_QRCODE_ID); } else { String eidText = eid.get(); if (eidText != null) { mDialog.setText(EID_INFO_VALUE_ID, eidText); removeQrCode = (eidText == ""); } } if (removeQrCode) { mDialog.removeSettingFromScreen(EID_INFO_QRCODE_ID); } } private boolean isImsRegistrationStateShowUp() { if (mSubscriptionInfo == null) { return false; Loading src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java +1 −22 Original line number Diff line number Diff line Loading @@ -19,14 +19,11 @@ package com.android.settings.deviceinfo.simstatus; import android.app.Dialog; import android.app.settings.SettingsEnums; import android.os.Bundle; import android.graphics.Bitmap; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.ImageView; import android.widget.TextView; import android.util.Log; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; Loading @@ -35,7 +32,6 @@ import androidx.fragment.app.FragmentManager; import com.android.settings.R; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; import com.android.settings.deviceinfo.PhoneNumberUtil; import com.android.settingslib.qrcode.QrCodeGenerator; import java.util.Arrays; import java.util.stream.IntStream; Loading Loading @@ -84,7 +80,6 @@ public class SimStatusDialogFragment extends InstrumentedDialogFragment { Dialog dlg = builder.setView(mRootView).create(); dlg.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); dlg.setOnShowListener(mController); return dlg; } Loading @@ -107,8 +102,7 @@ public class SimStatusDialogFragment extends InstrumentedDialogFragment { **/ private static final int[] sViewIdsInDigitFormat = IntStream .of(SimStatusDialogController.ICCID_INFO_VALUE_ID, SimStatusDialogController.PHONE_NUMBER_VALUE_ID, SimStatusDialogController.EID_INFO_VALUE_ID) SimStatusDialogController.PHONE_NUMBER_VALUE_ID) .sorted().toArray(); public void setText(int viewId, CharSequence text) { Loading @@ -128,19 +122,4 @@ public class SimStatusDialogFragment extends InstrumentedDialogFragment { textView.setText(text); textView.setTextIsSelectable(enableCopy); } public void setQrCode(int viewId, String qrcodeText) { ImageView qrCodeView = (ImageView) mRootView.findViewById(viewId); Bitmap qrCodeBitmap = null; try { qrCodeBitmap = QrCodeGenerator.encodeQrCode(qrcodeText, qrCodeView.getWidth()); } catch (Exception exception) { Log.w(TAG, "Error when presenting QR code in + " + qrCodeView, exception); } if (qrCodeBitmap == null) { return; } qrCodeView.setImageBitmap(qrCodeBitmap); } } Loading
res/layout/dialog_sim_status.xml +0 −9 Original line number Diff line number Diff line Loading @@ -156,15 +156,6 @@ android:layout_height="wrap_content" android:text="@string/device_info_not_available"/> <TextView style="@style/device_info_dialog_label" android:id="@+id/esim_id_label" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/status_esim_id"/> <include layout="@xml/esim_eid_and_qrcode" /> <TextView style="@style/device_info_dialog_label" android:id="@+id/ims_reg_state_label" Loading
res/xml/esim_eid_and_qrcode.xmldeleted 100644 → 0 +0 −33 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> <merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <TextView style="@style/device_info_dialog_value" android:id="@+id/esim_id_value" android:layout_width="match_parent" android:layout_height="wrap_content" android:textIsSelectable="true" android:text="@string/device_info_not_available"/> <ImageView android:id="@+id/esim_id_qrcode" android:layout_width="match_parent" android:layout_height="wrap_content" tools:ignore="ContentDescription" /> </merge>
src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java +1 −94 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.annotation.Nullable; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; Loading @@ -47,7 +46,6 @@ import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.TelephonyCallback; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.UiccCardInfo; import android.telephony.euicc.EuiccManager; import android.telephony.ims.ImsException; import android.telephony.ims.ImsMmTelManager; Loading @@ -64,17 +62,13 @@ import com.android.settings.R; import com.android.settingslib.DeviceInfoUtils; import com.android.settingslib.Utils; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.utils.ThreadUtils; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; /** * Controller for Sim Status information within the About Phone Settings page. */ public class SimStatusDialogController implements LifecycleObserver, DialogInterface.OnShowListener { public class SimStatusDialogController implements LifecycleObserver { private final static String TAG = "SimStatusDialogCtrl"; Loading Loading @@ -105,12 +99,6 @@ public class SimStatusDialogController implements LifecycleObserver, @VisibleForTesting final static int ICCID_INFO_VALUE_ID = R.id.icc_id_value; @VisibleForTesting final static int EID_INFO_LABEL_ID = R.id.esim_id_label; @VisibleForTesting final static int EID_INFO_VALUE_ID = R.id.esim_id_value; @VisibleForTesting final static int EID_INFO_QRCODE_ID = R.id.esim_id_qrcode; @VisibleForTesting final static int IMS_REGISTRATION_STATE_LABEL_ID = R.id.ims_reg_state_label; @VisibleForTesting final static int IMS_REGISTRATION_STATE_VALUE_ID = R.id.ims_reg_state_value; Loading Loading @@ -162,7 +150,6 @@ public class SimStatusDialogController implements LifecycleObserver, private boolean mShowLatestAreaInfo; private boolean mIsRegisteredListener = false; private AtomicReference<String> mEid = null; private final BroadcastReceiver mAreaInfoReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -239,8 +226,6 @@ public class SimStatusDialogController implements LifecycleObserver, } public void initialize() { requestForUpdateEid(); if (mSubscriptionInfo == null) { return; } Loading Loading @@ -268,19 +253,6 @@ public class SimStatusDialogController implements LifecycleObserver, updateImsRegistrationState(); } /** * Callback when dialog end of show(). */ public void onShow(DialogInterface dialog) { if (mEid != null) { String eidText = mEid.get(); if (eidText != null) { // Present QR code after the completion of layout mDialog.setQrCode(EID_INFO_QRCODE_ID, eidText); } } } /** * Deinitialization works */ Loading Loading @@ -633,71 +605,6 @@ public class SimStatusDialogController implements LifecycleObserver, } } @VisibleForTesting protected void requestForUpdateEid() { ThreadUtils.postOnBackgroundThread(() -> { mEid = getEid(mSlotIndex); ThreadUtils.postOnMainThread(() -> updateEid(mEid)); }); } @VisibleForTesting public AtomicReference<String> getEid(int slotIndex) { boolean shouldHaveEid = false; String eid = null; if (getTelephonyManager().getActiveModemCount() > MAX_PHONE_COUNT_SINGLE_SIM) { // Get EID per-SIM in multi-SIM mode final Map<Integer, Integer> mapping = mTelephonyManager .getLogicalToPhysicalSlotMapping(); final int pSlotId = mapping.getOrDefault(slotIndex, SubscriptionManager.INVALID_SIM_SLOT_INDEX); if (pSlotId != SubscriptionManager.INVALID_SIM_SLOT_INDEX) { final List<UiccCardInfo> infos = getTelephonyManager().getUiccCardsInfo(); for (UiccCardInfo info : infos) { if (info.getPhysicalSlotIndex() == pSlotId) { if (info.isEuicc()) { shouldHaveEid = true; eid = info.getEid(); if (TextUtils.isEmpty(eid)) { eid = mEuiccManager.createForCardId(info.getCardId()).getEid(); } } break; } } } } else if (mEuiccManager.isEnabled()) { // Get EID of default eSIM in single-SIM mode shouldHaveEid = true; eid = mEuiccManager.getEid(); } if ((!shouldHaveEid) && (eid == null)) { return null; } return new AtomicReference<String>(eid); } @VisibleForTesting protected void updateEid(AtomicReference<String> eid) { boolean removeQrCode = true; if (eid == null) { mDialog.removeSettingFromScreen(EID_INFO_LABEL_ID); mDialog.removeSettingFromScreen(EID_INFO_VALUE_ID); mDialog.removeSettingFromScreen(EID_INFO_QRCODE_ID); } else { String eidText = eid.get(); if (eidText != null) { mDialog.setText(EID_INFO_VALUE_ID, eidText); removeQrCode = (eidText == ""); } } if (removeQrCode) { mDialog.removeSettingFromScreen(EID_INFO_QRCODE_ID); } } private boolean isImsRegistrationStateShowUp() { if (mSubscriptionInfo == null) { return false; Loading
src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java +1 −22 Original line number Diff line number Diff line Loading @@ -19,14 +19,11 @@ package com.android.settings.deviceinfo.simstatus; import android.app.Dialog; import android.app.settings.SettingsEnums; import android.os.Bundle; import android.graphics.Bitmap; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.ImageView; import android.widget.TextView; import android.util.Log; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; Loading @@ -35,7 +32,6 @@ import androidx.fragment.app.FragmentManager; import com.android.settings.R; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; import com.android.settings.deviceinfo.PhoneNumberUtil; import com.android.settingslib.qrcode.QrCodeGenerator; import java.util.Arrays; import java.util.stream.IntStream; Loading Loading @@ -84,7 +80,6 @@ public class SimStatusDialogFragment extends InstrumentedDialogFragment { Dialog dlg = builder.setView(mRootView).create(); dlg.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); dlg.setOnShowListener(mController); return dlg; } Loading @@ -107,8 +102,7 @@ public class SimStatusDialogFragment extends InstrumentedDialogFragment { **/ private static final int[] sViewIdsInDigitFormat = IntStream .of(SimStatusDialogController.ICCID_INFO_VALUE_ID, SimStatusDialogController.PHONE_NUMBER_VALUE_ID, SimStatusDialogController.EID_INFO_VALUE_ID) SimStatusDialogController.PHONE_NUMBER_VALUE_ID) .sorted().toArray(); public void setText(int viewId, CharSequence text) { Loading @@ -128,19 +122,4 @@ public class SimStatusDialogFragment extends InstrumentedDialogFragment { textView.setText(text); textView.setTextIsSelectable(enableCopy); } public void setQrCode(int viewId, String qrcodeText) { ImageView qrCodeView = (ImageView) mRootView.findViewById(viewId); Bitmap qrCodeBitmap = null; try { qrCodeBitmap = QrCodeGenerator.encodeQrCode(qrcodeText, qrCodeView.getWidth()); } catch (Exception exception) { Log.w(TAG, "Error when presenting QR code in + " + qrCodeView, exception); } if (qrCodeBitmap == null) { return; } qrCodeView.setImageBitmap(qrCodeBitmap); } }