Snap for 8445064 from b28925ad48 to tm-release

Change-Id: Icadc505d14d8e69f73f8bef51524000e56c0f94c
This commit is contained in:
Android Build Coastguard Worker
2022-04-13 01:09:55 +00:00
12 changed files with 187 additions and 336 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -74,8 +74,8 @@
<ImageView <ImageView
android:id="@+id/profile_badge" android:id="@+id/profile_badge"
android:layout_width="wrap_content" android:layout_width="16dp"
android:layout_height="wrap_content" android:layout_height="16dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:contentDescription="@*android:string/notification_work_profile_content_description" android:contentDescription="@*android:string/notification_work_profile_content_description"

View File

@@ -41,21 +41,6 @@ public class RingVibrationPreferenceConfig extends VibrationPreferenceConfig {
return true; return true;
} }
@Override
public int readIntensity() {
final int vibrateWhenRinging = Settings.System.getInt(mContentResolver,
Settings.System.VIBRATE_WHEN_RINGING, ON);
if ((vibrateWhenRinging == OFF)
&& !mAudioManager.isRampingRingerEnabled()) {
// VIBRATE_WHEN_RINGING is deprecated but should still be applied if the user has
// turned it off and has not enabled the ramping ringer (old three-state setting).
return Vibrator.VIBRATION_INTENSITY_OFF;
}
return super.readIntensity();
}
@Override @Override
public boolean updateIntensity(int intensity) { public boolean updateIntensity(int intensity) {
final boolean success = super.updateIntensity(intensity); final boolean success = super.updateIntensity(intensity);

View File

@@ -157,7 +157,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
} }
} }
setupDefaultShortcutIfNecessary(getPrefContext());
final int resId = getPreferenceScreenResId(); final int resId = getPreferenceScreenResId();
if (resId <= 0) { if (resId <= 0) {
final PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen( final PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
@@ -226,6 +225,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
if (mNeedsQSTooltipReshow) { if (mNeedsQSTooltipReshow) {
getView().post(this::showQuickSettingsTooltipIfNeeded); getView().post(this::showQuickSettingsTooltipIfNeeded);
} }
writeDefaultShortcutTargetServiceToSettingsIfNeeded(getPrefContext());
} }
@Override @Override
@@ -792,8 +793,22 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
/** /**
* Setups a configurable default if the setting has never been set. * Setups a configurable default if the setting has never been set.
*
* TODO(b/228562075): Remove this function when correcting the format in config file
* `config_defaultAccessibilityService`.
*/ */
private static void setupDefaultShortcutIfNecessary(Context context) { private void writeDefaultShortcutTargetServiceToSettingsIfNeeded(Context context) {
if (mComponentName == null) {
return;
}
final ComponentName defaultService = ComponentName.unflattenFromString(context.getString(
com.android.internal.R.string.config_defaultAccessibilityService));
// write default accessibility service only when user enter into corresponding page.
if (!mComponentName.equals(defaultService)) {
return;
}
final String targetKey = Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE; final String targetKey = Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
String targetString = Settings.Secure.getString(context.getContentResolver(), targetKey); String targetString = Settings.Secure.getString(context.getContentResolver(), targetKey);
if (!TextUtils.isEmpty(targetString)) { if (!TextUtils.isEmpty(targetString)) {

View File

@@ -177,4 +177,11 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }
/**
* Gets the enabled state of all items.
*/
public boolean getEnabled() {
return mEnabled;
}
} }

View File

@@ -158,7 +158,7 @@ public class DreamPickerController extends BasePreferenceController implements
@Override @Override
public boolean isActive() { public boolean isActive() {
if (mActiveDream == null) { if (!mAdapter.getEnabled() || mActiveDream == null) {
return false; return false;
} }
return mDreamInfo.componentName.equals(mActiveDream.componentName); return mDreamInfo.componentName.equals(mActiveDream.componentName);

View File

@@ -21,6 +21,7 @@ import android.os.LocaleList;
import android.os.UserHandle; import android.os.UserHandle;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.util.ArraySet;
import android.util.Log; import android.util.Log;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -32,7 +33,6 @@ import java.lang.annotation.RetentionPolicy;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -182,7 +182,7 @@ public final class ConvertUtils {
} }
// Collects all keys in these three time slot records as all populations. // Collects all keys in these three time slot records as all populations.
final Set<String> allBatteryHistEntryKeys = new HashSet<>(); final Set<String> allBatteryHistEntryKeys = new ArraySet<>();
allBatteryHistEntryKeys.addAll(currentBatteryHistMap.keySet()); allBatteryHistEntryKeys.addAll(currentBatteryHistMap.keySet());
allBatteryHistEntryKeys.addAll(nextBatteryHistMap.keySet()); allBatteryHistEntryKeys.addAll(nextBatteryHistMap.keySet());
allBatteryHistEntryKeys.addAll(nextTwoBatteryHistMap.keySet()); allBatteryHistEntryKeys.addAll(nextTwoBatteryHistMap.keySet());

View File

@@ -21,12 +21,12 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Process; import android.os.Process;
import android.util.ArraySet;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import com.android.internal.util.ArrayUtils; import com.android.internal.util.ArrayUtils;
import com.android.settingslib.fuelgauge.Estimate; import com.android.settingslib.fuelgauge.Estimate;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -169,7 +169,7 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
@Override @Override
public Set<CharSequence> getHideBackgroundUsageTimeSet(Context context) { public Set<CharSequence> getHideBackgroundUsageTimeSet(Context context) {
return new HashSet<>(); return new ArraySet<>();
} }
@Override @Override

View File

@@ -356,8 +356,10 @@ public class NotificationHistoryActivity extends CollapsingToolbarBaseActivity {
} }
final int newState = isChecked ? 1 : 0; final int newState = isChecked ? 1 : 0;
if (oldState != newState) { if (oldState != newState) {
Settings.Secure.putInt(getContentResolver(), for (int user : mUm.getProfileIds(ActivityManager.getCurrentUser(), false)) {
NOTIFICATION_HISTORY_ENABLED, newState); Settings.Secure.putIntForUser(getContentResolver(),
NOTIFICATION_HISTORY_ENABLED, newState, user);
}
mUiEventLogger.log(isChecked ? NotificationHistoryEvent.NOTIFICATION_HISTORY_ON mUiEventLogger.log(isChecked ? NotificationHistoryEvent.NOTIFICATION_HISTORY_ON
: NotificationHistoryEvent.NOTIFICATION_HISTORY_OFF); : NotificationHistoryEvent.NOTIFICATION_HISTORY_OFF);
Log.d(TAG, "onSwitchChange history to " + isChecked); Log.d(TAG, "onSwitchChange history to " + isChecked);

View File

@@ -121,7 +121,7 @@ public class NotificationSbnAdapter extends
int userId = normalizeUserId(sbn); int userId = normalizeUserId(sbn);
if (!mUserBadgeCache.containsKey(userId)) { if (!mUserBadgeCache.containsKey(userId)) {
Drawable profile = mContext.getPackageManager().getUserBadgeForDensity( Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
UserHandle.of(userId), -1); UserHandle.of(userId), 0);
mUserBadgeCache.put(userId, profile); mUserBadgeCache.put(userId, profile);
} }
holder.setProfileBadge(mUserBadgeCache.get(userId)); holder.setProfileBadge(mUserBadgeCache.get(userId));

View File

@@ -121,22 +121,22 @@ public class RingVibrationIntensityPreferenceControllerTest {
} }
@Test @Test
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() { public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayRingIntensity() {
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false); when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF); updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH); updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF); assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
Vibrator.VIBRATION_INTENSITY_MEDIUM); Vibrator.VIBRATION_INTENSITY_MEDIUM);
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF); assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF); assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF); updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
mController.updateState(mPreference); mController.updateState(mPreference);

View File

@@ -116,22 +116,24 @@ public class RingVibrationTogglePreferenceControllerTest {
} }
@Test @Test
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() { public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldIgnoreAndUseIntensity() {
// VIBRATE_WHEN_RINGING is deprecated and should have no effect on the ring vibration
// setting. The ramping ringer is also independent now, instead of a 3-state setting.
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false); when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF); updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH); updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isFalse(); assertThat(mPreference.isChecked()).isTrue();
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
Vibrator.VIBRATION_INTENSITY_MEDIUM); Vibrator.VIBRATION_INTENSITY_MEDIUM);
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isFalse(); assertThat(mPreference.isChecked()).isTrue();
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isFalse(); assertThat(mPreference.isChecked()).isTrue();
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF); updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
mController.updateState(mPreference); mController.updateState(mPreference);