Settings: Protect sensitive data on the about phone
- Hide some personal info like phone number and IMEI.
- IMEI shows on a tap, so why not.
- Avoid showing this in screenshot/screenrecord
Co-authored-by: El Dainosor <eldainosor@gmail.com>
Change-Id: I45b7898da440c36045aec64a0a86fb804116cd9d
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 2e72764..a5354ef 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -44,6 +44,9 @@
<!-- Device Info screen. LineageOS legal. -->
<string name="lineagelicense_title">LineageOS legal</string>
+ <!-- String for removal of sensitive info on about, depending on tap -->
+ <string name="device_info_protected_single_press">Tap to show info</string>
+
<!-- Double tap to sleep on status bar or lockscreen -->
<string name="status_bar_double_tap_to_sleep_title">Tap to sleep</string>
<string name="status_bar_double_tap_to_sleep_summary">Double-tap on the status bar or lockscreen to turn off the display</string>
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index 6dcfc9f..0bd774b 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -56,7 +56,6 @@
android:order="3"
android:title="@string/status_number"
android:summary="@string/summary_placeholder"
- android:selectable="false"
settings:controller="com.android.settings.deviceinfo.PhoneNumberPreferenceController"
settings:enableCopying="true"/>
</PreferenceCategory>
diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index 2547dbd..bd5313b 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -61,7 +61,24 @@
@Override
public CharSequence getSummary() {
- return getFirstPhoneNumber();
+ return mContext.getString(R.string.device_info_protected_single_press);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ String prefKey = preference.getKey();
+ if (prefKey.startsWith(KEY_PHONE_NUMBER)) {
+ int simSlotNumber = 0;
+ if (!TextUtils.equals(prefKey, KEY_PHONE_NUMBER)) {
+ // Get multisim slot number from preference key.
+ // Multisim preference key is KEY_PHONE_NUMBER + simSlotNumber
+ simSlotNumber = Integer.parseInt(
+ prefKey.replaceAll("[^0-9]", ""));
+ }
+ final Preference simStatusPreference = mPreferenceList.get(simSlotNumber);
+ simStatusPreference.setSummary(getPhoneNumber(simSlotNumber));
+ }
+ return super.handlePreferenceTreeClick(preference);
}
@Override
@@ -78,7 +95,6 @@
final Preference multiSimPreference = createNewPreference(screen.getContext());
multiSimPreference.setOrder(phonePreferenceOrder + simSlotNumber);
multiSimPreference.setKey(KEY_PHONE_NUMBER + simSlotNumber);
- multiSimPreference.setSelectable(false);
category.addPreference(multiSimPreference);
mPreferenceList.add(multiSimPreference);
}
@@ -89,7 +105,7 @@
for (int simSlotNumber = 0; simSlotNumber < mPreferenceList.size(); simSlotNumber++) {
final Preference simStatusPreference = mPreferenceList.get(simSlotNumber);
simStatusPreference.setTitle(getPreferenceTitle(simSlotNumber));
- simStatusPreference.setSummary(getPhoneNumber(simSlotNumber));
+ simStatusPreference.setSummary(getSummary());
}
}
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index e0bff6d..e904772 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -33,7 +33,6 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.deviceinfo.PhoneNumberSummaryPreference;
-import com.android.settings.slices.Sliceable;
import com.android.settingslib.Utils;
import java.util.ArrayList;
@@ -97,7 +96,7 @@
@Override
public CharSequence getSummary() {
- return getSummary(0);
+ return mContext.getString(R.string.device_info_protected_single_press);
}
private CharSequence getSummary(int simSlot) {
@@ -114,6 +113,7 @@
}
ImeiInfoDialogFragment.show(mFragment, simSlot, preference.getTitle().toString());
+ preference.setSummary(getSummary(simSlot));
return true;
}
@@ -128,14 +128,9 @@
return true;
}
- @Override
- public void copy() {
- Sliceable.setCopyContent(mContext, getSummary(0), getTitle(0));
- }
-
private void updatePreference(Preference preference, int simSlot) {
preference.setTitle(getTitle(simSlot));
- preference.setSummary(getSummary(simSlot));
+ preference.setSummary(getSummary());
}
private CharSequence getTitleForGsmPhone(int simSlot) {