Phone number only available for admin users

The phone number is hidden to non-admin users, following the same
reasoning that exists for other telephony-specific fields like the
baseband IMEI.

Bug: 392808943
Flag: EXEMPT bugfix
Test: atest PhoneNumberPreferenceControllerTest
Test: atest MobileNetworkPhoneNumberPreferenceControllerTest

Change-Id: I4e612219d0c7439930e91b3e1d6e368a0dfd073e
This commit is contained in:
Aleksander Morgado
2025-02-06 17:49:40 +00:00
parent 035a15ac37
commit 571103b891
4 changed files with 59 additions and 17 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.deviceinfo;
import android.content.Context;
import android.os.UserManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -51,8 +52,13 @@ public class PhoneNumberPreferenceController extends BasePreferenceController {
@Override
public int getAvailabilityStatus() {
return SubscriptionUtil.isSimHardwareVisible(mContext) ?
AVAILABLE : UNSUPPORTED_ON_DEVICE;
if (!SubscriptionUtil.isSimHardwareVisible(mContext)) {
return UNSUPPORTED_ON_DEVICE;
}
if (!mContext.getSystemService(UserManager.class).isAdminUser()) {
return DISABLED_FOR_USER;
}
return AVAILABLE;
}
@Override