Snap for 8445064 from b28925ad48 to tm-release
Change-Id: Icadc505d14d8e69f73f8bef51524000e56c0f94c
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -74,8 +74,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profile_badge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@*android:string/notification_work_profile_content_description"
|
||||
|
||||
@@ -41,21 +41,6 @@ public class RingVibrationPreferenceConfig extends VibrationPreferenceConfig {
|
||||
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
|
||||
public boolean updateIntensity(int intensity) {
|
||||
final boolean success = super.updateIntensity(intensity);
|
||||
|
||||
@@ -157,7 +157,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
}
|
||||
}
|
||||
|
||||
setupDefaultShortcutIfNecessary(getPrefContext());
|
||||
final int resId = getPreferenceScreenResId();
|
||||
if (resId <= 0) {
|
||||
final PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
|
||||
@@ -226,6 +225,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
if (mNeedsQSTooltipReshow) {
|
||||
getView().post(this::showQuickSettingsTooltipIfNeeded);
|
||||
}
|
||||
|
||||
writeDefaultShortcutTargetServiceToSettingsIfNeeded(getPrefContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -792,8 +793,22 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
|
||||
/**
|
||||
* 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;
|
||||
String targetString = Settings.Secure.getString(context.getContentResolver(), targetKey);
|
||||
if (!TextUtils.isEmpty(targetString)) {
|
||||
|
||||
@@ -177,4 +177,11 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the enabled state of all items.
|
||||
*/
|
||||
public boolean getEnabled() {
|
||||
return mEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class DreamPickerController extends BasePreferenceController implements
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
if (mActiveDream == null) {
|
||||
if (!mAdapter.getEnabled() || mActiveDream == null) {
|
||||
return false;
|
||||
}
|
||||
return mDreamInfo.componentName.equals(mActiveDream.componentName);
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.os.LocaleList;
|
||||
import android.os.UserHandle;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -32,7 +33,6 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -182,7 +182,7 @@ public final class ConvertUtils {
|
||||
}
|
||||
|
||||
// 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(nextBatteryHistMap.keySet());
|
||||
allBatteryHistEntryKeys.addAll(nextTwoBatteryHistMap.keySet());
|
||||
|
||||
@@ -21,12 +21,12 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Process;
|
||||
import android.util.ArraySet;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settingslib.fuelgauge.Estimate;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -169,7 +169,7 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
|
||||
@Override
|
||||
public Set<CharSequence> getHideBackgroundUsageTimeSet(Context context) {
|
||||
return new HashSet<>();
|
||||
return new ArraySet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -356,8 +356,10 @@ public class NotificationHistoryActivity extends CollapsingToolbarBaseActivity {
|
||||
}
|
||||
final int newState = isChecked ? 1 : 0;
|
||||
if (oldState != newState) {
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
NOTIFICATION_HISTORY_ENABLED, newState);
|
||||
for (int user : mUm.getProfileIds(ActivityManager.getCurrentUser(), false)) {
|
||||
Settings.Secure.putIntForUser(getContentResolver(),
|
||||
NOTIFICATION_HISTORY_ENABLED, newState, user);
|
||||
}
|
||||
mUiEventLogger.log(isChecked ? NotificationHistoryEvent.NOTIFICATION_HISTORY_ON
|
||||
: NotificationHistoryEvent.NOTIFICATION_HISTORY_OFF);
|
||||
Log.d(TAG, "onSwitchChange history to " + isChecked);
|
||||
|
||||
@@ -121,7 +121,7 @@ public class NotificationSbnAdapter extends
|
||||
int userId = normalizeUserId(sbn);
|
||||
if (!mUserBadgeCache.containsKey(userId)) {
|
||||
Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
|
||||
UserHandle.of(userId), -1);
|
||||
UserHandle.of(userId), 0);
|
||||
mUserBadgeCache.put(userId, profile);
|
||||
}
|
||||
holder.setProfileBadge(mUserBadgeCache.get(userId));
|
||||
|
||||
@@ -121,22 +121,22 @@ public class RingVibrationIntensityPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
|
||||
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayRingIntensity() {
|
||||
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
|
||||
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||
|
||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||
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,
|
||||
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||
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);
|
||||
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);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -116,22 +116,24 @@ public class RingVibrationTogglePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@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);
|
||||
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||
|
||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
assertThat(mPreference.isChecked()).isTrue();
|
||||
|
||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
|
||||
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
assertThat(mPreference.isChecked()).isTrue();
|
||||
|
||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
assertThat(mPreference.isChecked()).isTrue();
|
||||
|
||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
Reference in New Issue
Block a user