RESTRICT AUTOMERGE - Merge TQ2A.230305.008

Bug: 264720040
Merged-In: Id3ebc6627d6b46172cae1ce9e5c7500a652e719d
Merged-In: I8b9a2cbd5af7fa1bba56ff9ba62771d677d4a932
Change-Id: I5833464626eb06a01d6979c477be98ba06827893
This commit is contained in:
Xin Li
2023-02-14 16:11:45 -08:00
6 changed files with 71 additions and 237 deletions

View File

@@ -39,6 +39,7 @@ import com.android.settings.SetupWizardUtils;
import com.android.settings.biometrics.face.FaceEnrollIntroduction;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollFindSensor;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.biometrics.fingerprint.SetupFingerprintEnrollFindSensor;
import com.android.settings.biometrics.fingerprint.SetupFingerprintEnrollIntroduction;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockSettingsHelper;
@@ -152,9 +153,13 @@ public class BiometricUtils {
*/
public static Intent getFingerprintFindSensorIntent(@NonNull Context context,
@NonNull Intent activityIntent) {
Intent intent = new Intent(context, FingerprintEnrollFindSensor.class);
SetupWizardUtils.copySetupExtras(activityIntent, intent);
return intent;
if (WizardManagerHelper.isAnySetupWizard(activityIntent)) {
Intent intent = new Intent(context, SetupFingerprintEnrollFindSensor.class);
SetupWizardUtils.copySetupExtras(activityIntent, intent);
return intent;
} else {
return new Intent(context, FingerprintEnrollFindSensor.class);
}
}
/**

View File

@@ -16,7 +16,6 @@
package com.android.settings.notification;
import android.app.ActivityThread;
import android.app.INotificationManager;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
@@ -30,32 +29,26 @@ import android.os.Looper;
import android.os.Message;
import android.os.ServiceManager;
import android.os.Vibrator;
import android.provider.DeviceConfig;
import android.service.notification.NotificationListenerService;
import android.text.TextUtils;
import android.util.Log;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.Objects;
import java.util.Set;
/**
* Update notification volume icon in Settings in response to user adjusting volume.
* Update notification volume icon in Settings in response to user adjusting volume
*/
public class NotificationVolumePreferenceController extends VolumeSeekBarPreferenceController {
private static final String TAG = "NotificationVolumePreferenceController";
private static final String KEY_NOTIFICATION_VOLUME = "notification_volume";
private static final boolean CONFIG_DEFAULT_VAL = false;
private boolean mSeparateNotification;
private Vibrator mVibrator;
private int mRingerMode = AudioManager.RINGER_MODE_NORMAL;
@@ -63,74 +56,39 @@ public class NotificationVolumePreferenceController extends VolumeSeekBarPrefere
private final RingReceiver mReceiver = new RingReceiver();
private final H mHandler = new H();
private INotificationManager mNoMan;
private int mMuteIcon;
private final int mNormalIconId = R.drawable.ic_notifications;
private final int mVibrateIconId = R.drawable.ic_volume_ringer_vibrate;
private final int mSilentIconId = R.drawable.ic_notifications_off_24dp;
private final boolean mRingNotificationAliased;
public NotificationVolumePreferenceController(Context context) {
this(context, KEY_NOTIFICATION_VOLUME);
}
public NotificationVolumePreferenceController(Context context, String key) {
super(context, key);
mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
if (mVibrator != null && !mVibrator.hasVibrator()) {
mVibrator = null;
}
mRingNotificationAliased = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_alias_ring_notif_stream_types);
updateRingerMode();
}
/**
* Allow for notification slider to be enabled in the scenario where the config switches on
* while settings page is already on the screen by always configuring the preference, even if it
* is currently inactive.
*/
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (mPreference == null) {
setupVolPreference(screen);
}
mSeparateNotification = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, CONFIG_DEFAULT_VAL);
if (mPreference != null) {
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
}
updateEffectsSuppressor();
updatePreferenceIconAndSliderState();
}
/**
* Only display the notification slider when the corresponding device config flag is set
*/
private void onDeviceConfigChange(DeviceConfig.Properties properties) {
Set<String> changeSet = properties.getKeyset();
if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) {
boolean newVal = properties.getBoolean(
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, CONFIG_DEFAULT_VAL);
if (newVal != mSeparateNotification) {
mSeparateNotification = newVal;
// manually hiding the preference because being unavailable does not do the job
if (mPreference != null) {
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
}
}
}
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@Override
public void onResume() {
super.onResume();
mReceiver.register(true);
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
ActivityThread.currentApplication().getMainExecutor(),
this::onDeviceConfigChange);
updateEffectsSuppressor();
updatePreferenceIconAndSliderState();
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
@@ -138,17 +96,16 @@ public class NotificationVolumePreferenceController extends VolumeSeekBarPrefere
public void onPause() {
super.onPause();
mReceiver.register(false);
DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange);
}
@Override
public int getAvailabilityStatus() {
boolean separateNotification = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false);
// Show separate notification slider if ring/notification are not aliased by AudioManager --
// if they are, notification volume is controlled by RingVolumePreferenceController.
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
&& (!mRingNotificationAliased || !Utils.isVoiceCapable(mContext))
&& !mHelper.isSingleVolume()
&& (separateNotification || !Utils.isVoiceCapable(mContext))
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}

View File

@@ -16,7 +16,6 @@
package com.android.settings.notification;
import android.app.ActivityThread;
import android.app.INotificationManager;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
@@ -30,7 +29,6 @@ import android.os.Looper;
import android.os.Message;
import android.os.ServiceManager;
import android.os.Vibrator;
import android.provider.DeviceConfig;
import android.service.notification.NotificationListenerService;
import android.text.TextUtils;
import android.util.Log;
@@ -38,13 +36,11 @@ import android.util.Log;
import androidx.lifecycle.OnLifecycleEvent;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.Objects;
import java.util.Set;
/**
* This slider can represent both ring and notification, if the corresponding streams are aliased,
@@ -63,21 +59,24 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
private int mMuteIcon;
private int mNormalIconId;
/*
* Whether ring and notification streams are aliased together by AudioManager.
* If they are, we'll present one volume control for both.
* If not, we'll present separate volume controls.
*/
private final boolean mRingAliasNotif;
private final int mNormalIconId;
@VisibleForTesting
int mVibrateIconId;
final int mVibrateIconId;
@VisibleForTesting
int mSilentIconId;
final int mSilentIconId;
@VisibleForTesting
int mTitleId;
private boolean mSeparateNotification;
final int mTitleId;
private INotificationManager mNoMan;
private static final boolean CONFIG_DEFAULT_VAL = false;
public RingVolumePreferenceController(Context context) {
this(context, KEY_RING_VOLUME);
}
@@ -88,56 +87,29 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
if (mVibrator != null && !mVibrator.hasVibrator()) {
mVibrator = null;
}
mSeparateNotification = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, CONFIG_DEFAULT_VAL);
loadPreferenceIconResources(mSeparateNotification);
updateRingerMode();
}
private void loadPreferenceIconResources(boolean separateNotification) {
if (separateNotification) {
mTitleId = R.string.separate_ring_volume_option_title;
mNormalIconId = R.drawable.ic_ring_volume;
mSilentIconId = R.drawable.ic_ring_volume_off;
} else {
mRingAliasNotif = isRingAliasNotification();
if (mRingAliasNotif) {
mTitleId = R.string.ring_volume_option_title;
mNormalIconId = R.drawable.ic_notifications;
mSilentIconId = R.drawable.ic_notifications_off_24dp;
} else {
mTitleId = R.string.separate_ring_volume_option_title;
mNormalIconId = R.drawable.ic_ring_volume;
mSilentIconId = R.drawable.ic_ring_volume_off;
}
// todo: set a distinct vibrate icon for ring vs notification
mVibrateIconId = R.drawable.ic_volume_ringer_vibrate;
updateRingerMode();
}
/**
* As the responsibility of this slider changes, so should its title & icon
*/
public void onDeviceConfigChange(DeviceConfig.Properties properties) {
Set<String> changeSet = properties.getKeyset();
if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) {
boolean valueUpdated = readSeparateNotificationVolumeConfig();
if (valueUpdated) {
updateEffectsSuppressor();
selectPreferenceIconState();
setPreferenceTitle();
}
}
}
/**
* side effect: updates the cached value of the config, and also the icon
* @return has the config changed?
*/
private boolean readSeparateNotificationVolumeConfig() {
boolean newVal = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, CONFIG_DEFAULT_VAL);
boolean valueUpdated = newVal != mSeparateNotification;
if (valueUpdated) {
mSeparateNotification = newVal;
loadPreferenceIconResources(newVal);
}
return valueUpdated;
@VisibleForTesting
boolean isRingAliasNotification() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_alias_ring_notif_stream_types);
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@@ -145,11 +117,8 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
public void onResume() {
super.onResume();
mReceiver.register(true);
readSeparateNotificationVolumeConfig();
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange);
updateEffectsSuppressor();
selectPreferenceIconState();
updatePreferenceIcon();
setPreferenceTitle();
}
@@ -158,7 +127,6 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
public void onPause() {
super.onPause();
mReceiver.register(false);
DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange);
}
@Override
@@ -202,7 +170,7 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
final int ringerMode = mHelper.getRingerModeInternal();
if (mRingerMode == ringerMode) return;
mRingerMode = ringerMode;
selectPreferenceIconState();
updatePreferenceIcon();
}
private void updateEffectsSuppressor() {
@@ -222,8 +190,7 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
return;
}
if (hintsMatch(hints, DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false))) {
if (hintsMatch(hints, mRingAliasNotif)) {
mSuppressor = suppressor;
if (mPreference != null) {
final String text = SuppressorHelper.getSuppressionText(mContext, suppressor);
@@ -233,11 +200,11 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
}
@VisibleForTesting
boolean hintsMatch(int hints, boolean notificationSeparated) {
boolean hintsMatch(int hints, boolean ringNotificationAliased) {
return (hints & NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS) != 0
|| (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0
|| ((hints & NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS)
!= 0 && !notificationSeparated);
!= 0 && ringNotificationAliased);
}
@VisibleForTesting
@@ -250,7 +217,7 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
mVibrator = vibrator;
}
private void selectPreferenceIconState() {
private void updatePreferenceIcon() {
if (mPreference != null) {
if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
mPreference.showIcon(mNormalIconId);

View File

@@ -55,17 +55,13 @@ public abstract class VolumeSeekBarPreferenceController extends
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
setupVolPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
mPreference.setCallback(mVolumePreferenceCallback);
mPreference.setStream(getAudioStream());
mPreference.setMuteIcon(getMuteIcon());
}
}
protected void setupVolPreference(PreferenceScreen screen) {
mPreference = screen.findPreference(getPreferenceKey());
mPreference.setCallback(mVolumePreferenceCallback);
mPreference.setStream(getAudioStream());
mPreference.setMuteIcon(getMuteIcon());
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
if (mPreference != null) {