From b73201c6be81bd02e9a81da96a605aac80b687f5 Mon Sep 17 00:00:00 2001 From: Joshua Mccloskey Date: Tue, 16 Nov 2021 14:58:49 -0800 Subject: [PATCH 1/2] Added sensorPrivacyDialog to face settings Test: Verify flow presents dialog if the privacy setting is enabled. Bug: 201045056 Change-Id: I96f14db457311d13f07c770ff0993581576c5dba --- .../face/FaceEnrollIntroduction.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java index 74ea27b9d88..eadb5b8c4f1 100644 --- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java +++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java @@ -19,10 +19,12 @@ package com.android.settings.biometrics.face; import android.app.admin.DevicePolicyManager; import android.app.settings.SettingsEnums; import android.content.Intent; +import android.hardware.SensorPrivacyManager; import android.hardware.biometrics.BiometricAuthenticator; import android.hardware.face.FaceManager; import android.hardware.face.FaceSensorPropertiesInternal; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; @@ -34,10 +36,12 @@ import androidx.annotation.StringRes; import com.android.settings.R; import com.android.settings.Utils; +import com.android.settings.biometrics.BiometricEnrollActivity; import com.android.settings.biometrics.BiometricEnrollIntroduction; import com.android.settings.biometrics.BiometricUtils; import com.android.settings.overlay.FeatureFactory; import com.android.settings.password.ChooseLockSettingsHelper; +import com.android.settings.utils.SensorPrivacyManagerHelper; import com.android.settingslib.RestrictedLockUtilsInternal; import com.google.android.setupcompat.template.FooterButton; @@ -57,6 +61,7 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction { private FaceFeatureProvider mFaceFeatureProvider; @Nullable private FooterButton mPrimaryFooterButton; @Nullable private FooterButton mSecondaryFooterButton; + @Nullable private SensorPrivacyManager mSensorPrivacyManager; @Override protected void onCancelButtonClick(View view) { @@ -150,6 +155,14 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction { }); } } + + mSensorPrivacyManager = getApplicationContext() + .getSystemService(SensorPrivacyManager.class); + final SensorPrivacyManagerHelper helper = SensorPrivacyManagerHelper + .getInstance(getApplicationContext()); + final boolean cameraPrivacyEnabled = helper + .isSensorBlocked(SensorPrivacyManager.Sensors.CAMERA, mUserId); + Log.v(TAG, "cameraPrivacyEnabled : " + cameraPrivacyEnabled); } protected boolean generateChallengeOnCreate() { @@ -308,6 +321,28 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction { return BiometricAuthenticator.TYPE_FACE; } + @Override + protected void onNextButtonClick(View view) { + final boolean parentelConsentRequired = + getIntent() + .getBooleanExtra(BiometricEnrollActivity.EXTRA_REQUIRE_PARENTAL_CONSENT, false); + final boolean cameraPrivacyEnabled = SensorPrivacyManagerHelper + .getInstance(getApplicationContext()) + .isSensorBlocked(SensorPrivacyManager.Sensors.CAMERA, mUserId); + final boolean isSetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent()); + final boolean isSettingUp = isSetupWizard || (parentelConsentRequired + && !WizardManagerHelper.isUserSetupComplete(this)); + if (cameraPrivacyEnabled && !isSettingUp) { + if (mSensorPrivacyManager == null) { + mSensorPrivacyManager = getApplicationContext() + .getSystemService(SensorPrivacyManager.class); + } + mSensorPrivacyManager.showSensorUseDialog(SensorPrivacyManager.Sensors.CAMERA); + } else { + super.onNextButtonClick(view); + } + } + @Override @NonNull protected FooterButton getPrimaryFooterButton() { From 3dfad58897b33ec75813c12433a2dc5106a66ec8 Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Tue, 30 Nov 2021 09:48:27 +0800 Subject: [PATCH 2/2] [Settings] support of getPhoneNumber API Access to new API for retrieving phone number. Bug: 208321353 Test: local build pass Change-Id: I8484f94934670f24c80c95df89e8752420c1f439 --- src/com/android/settings/network/SubscriptionUtil.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java index c77a294d1c4..d7e5876c5a4 100644 --- a/src/com/android/settings/network/SubscriptionUtil.java +++ b/src/com/android/settings/network/SubscriptionUtil.java @@ -540,13 +540,14 @@ public class SubscriptionUtil { return null; } - TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class); - String rawPhoneNumber = - telephonyManager.getLine1Number(subscriptionInfo.getSubscriptionId()); - String countryIso = MccTable.countryCodeForMcc(subscriptionInfo.getMccString()); + final SubscriptionManager subscriptionManager = context.getSystemService( + SubscriptionManager.class); + String rawPhoneNumber = subscriptionManager.getPhoneNumber( + subscriptionInfo.getSubscriptionId()); if (TextUtils.isEmpty(rawPhoneNumber)) { return null; } + String countryIso = MccTable.countryCodeForMcc(subscriptionInfo.getMccString()); return PhoneNumberUtils.formatNumber(rawPhoneNumber, countryIso); }