diff --git a/res/drawable/ic_fast_pair_24dp.xml b/res/drawable/ic_fast_pair_24dp.xml deleted file mode 100644 index 17bfdd9143f..00000000000 --- a/res/drawable/ic_fast_pair_24dp.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/res/layout/dialog_edittext_dropdown.xml b/res/layout/dialog_edittext_dropdown.xml new file mode 100644 index 00000000000..0e77968023a --- /dev/null +++ b/res/layout/dialog_edittext_dropdown.xml @@ -0,0 +1,42 @@ + + + + + + + + + diff --git a/res/layout/tare_homepage.xml b/res/layout/tare_homepage.xml index ddc93337314..4cd649f189e 100644 --- a/res/layout/tare_homepage.xml +++ b/res/layout/tare_homepage.xml @@ -27,7 +27,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="20dp" - android:text="On" + android:textOff="@string/tare_off" + android:textOn="@string/tare_on" + android:showText="true" android:background="?android:attr/colorBackground" /> - - - - - Fast Pair - - - Nearby detection of Fast Pair bluetooth devices. - - Scan for nearby devices - - Saved devices - @@ -8434,9 +8421,6 @@ connected, device, headphones, headset, speaker, wireless, pair, earbuds, music, media - - pair, earbuds, bluetooth - background, theme, grid, customize, personalize @@ -13870,6 +13854,10 @@ TARE Settings + + On + + Off Revert to Default Settings - Rewards for total event duration + Rewards per second of event duration Maximum Rewards Per Day @@ -14087,6 +14075,13 @@ Confirm + + + ARC + Cake + + Preview diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml index 509aed6c4d0..0287fc65d2d 100644 --- a/res/xml/accessibility_settings.xml +++ b/res/xml/accessibility_settings.xml @@ -41,7 +41,8 @@ android:icon="@drawable/ic_adaptive_font_download" android:key="text_reading_options" android:persistent="false" - android:title="@string/accessibility_text_reading_options_title" /> + android:title="@string/accessibility_text_reading_options_title" + settings:controller="com.android.settings.accessibility.TextReadingFragmentForA11ySettingsController"/> + settings:keywords="text_reading_options" + settings:controller="com.android.settings.accessibility.TextReadingFragmentForSuwController"/> - - diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml index 0649eeef477..1b5e6c01cc4 100644 --- a/res/xml/display_settings.xml +++ b/res/xml/display_settings.xml @@ -72,7 +72,8 @@ android:fragment="com.android.settings.accessibility.TextReadingPreferenceFragment" android:key="text_reading_options" android:persistent="false" - android:title="@string/accessibility_text_reading_options_title" /> + android:title="@string/accessibility_text_reading_options_title" + settings:controller="com.android.settings.accessibility.TextReadingFragmentForDisplaySettingsController"/> - - - - - - - - - diff --git a/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java b/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java index 434157dc2b7..d8a887d510e 100644 --- a/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java +++ b/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java @@ -16,6 +16,16 @@ package com.android.settings.accessibility; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.BOLD_TEXT_KEY; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.DISPLAY_SIZE_KEY; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.ACCESSIBILITY_SETTINGS; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.DISPLAY_SETTINGS; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.SUW_ANYTHING_ELSE; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.SUW_VISION_SETTINGS; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.FONT_SIZE_KEY; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.HIGH_TEXT_CONTRAST_KEY; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.RESET_KEY; + import android.content.ComponentName; import com.android.settings.core.instrumentation.SettingsStatsLog; @@ -58,4 +68,48 @@ public final class AccessibilityStatsLogUtils { .ACCESSIBILITY_PRIVACY_WARNING_STATUS_SERVICE_DISABLED, durationMills); } + + /** + * Converts to the key name for logging. + * + * @param prefKey the preference key + * @return the int value which maps to the key name + */ + static int convertToItemKeyName(String prefKey) { + switch (prefKey) { + case FONT_SIZE_KEY: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_FONT_SIZE; + case DISPLAY_SIZE_KEY: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_DISPLAY_SIZE; + case BOLD_TEXT_KEY: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_BOLD_TEXT; + case HIGH_TEXT_CONTRAST_KEY: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_HIGH_CONTRAST_TEXT; + case RESET_KEY: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_RESET; + default: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_UNKNOWN_ITEM; + } + } + + /** + * Converts to the entry point for logging. + * + * @param entryPoint the entry point + * @return the int value which maps to the entry point + */ + static int convertToEntryPoint(int entryPoint) { + switch (entryPoint) { + case SUW_VISION_SETTINGS: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_SUW_VISION_SETTINGS; + case SUW_ANYTHING_ELSE: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_SUW_ANYTHING_ELSE; + case DISPLAY_SETTINGS: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_DISPLAY_SETTINGS; + case ACCESSIBILITY_SETTINGS: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_ACCESSIBILITY_SETTINGS; + default: + return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_UNKNOWN_ENTRY; + } + } } diff --git a/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java b/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java index e3c1b9eb15b..923e8806910 100644 --- a/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java +++ b/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java @@ -21,7 +21,9 @@ import android.graphics.fonts.FontStyle; import android.provider.Settings; import com.android.settings.R; +import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; import com.android.settings.core.TogglePreferenceController; +import com.android.settings.core.instrumentation.SettingsStatsLog; /** PreferenceController for displaying all text in bold. */ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceController implements @@ -29,6 +31,9 @@ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceCo static final int BOLD_TEXT_ADJUSTMENT = FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL; + @EntryPoint + private int mEntryPoint; + public FontWeightAdjustmentPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } @@ -46,6 +51,12 @@ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceCo @Override public boolean setChecked(boolean isChecked) { + SettingsStatsLog.write( + SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED, + AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()), + isChecked ? 1 : 0, + AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint)); + return Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.FONT_WEIGHT_ADJUSTMENT, (isChecked ? BOLD_TEXT_ADJUSTMENT : 0)); } @@ -59,4 +70,13 @@ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceCo public void resetState() { setChecked(false); } + + /** + * The entry point is used for logging. + * + * @param entryPoint from which settings page + */ + void setEntryPoint(@EntryPoint int entryPoint) { + mEntryPoint = entryPoint; + } } diff --git a/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java b/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java index 8c9d2340f54..9f645f1fa24 100644 --- a/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java +++ b/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java @@ -23,7 +23,9 @@ import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import com.android.settings.R; +import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; import com.android.settings.core.TogglePreferenceController; +import com.android.settings.core.instrumentation.SettingsStatsLog; /** * PreferenceController for displaying all text in high contrast style. @@ -32,6 +34,9 @@ public class HighTextContrastPreferenceController extends TogglePreferenceContro TextReadingResetController.ResetStateListener { private SwitchPreference mSwitchPreference; + @EntryPoint + private int mEntryPoint; + public HighTextContrastPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } @@ -49,6 +54,12 @@ public class HighTextContrastPreferenceController extends TogglePreferenceContro @Override public boolean setChecked(boolean isChecked) { + SettingsStatsLog.write( + SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED, + AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()), + isChecked ? 1 : 0, + AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint)); + return Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, (isChecked ? 1 : 0)); } @@ -69,4 +80,13 @@ public class HighTextContrastPreferenceController extends TogglePreferenceContro setChecked(false); updateState(mSwitchPreference); } + + /** + * The entry point is used for logging. + * + * @param entryPoint from which settings page + */ + void setEntryPoint(@EntryPoint int entryPoint) { + mEntryPoint = entryPoint; + } } diff --git a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java index c7dfd61674a..711eb0fe527 100644 --- a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java +++ b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java @@ -22,7 +22,9 @@ import android.widget.SeekBar; import androidx.annotation.NonNull; import androidx.preference.PreferenceScreen; +import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; import com.android.settings.core.BasePreferenceController; +import com.android.settings.core.instrumentation.SettingsStatsLog; import com.android.settings.widget.LabeledSeekBarPreference; /** @@ -36,6 +38,9 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements private ProgressInteractionListener mInteractionListener; private LabeledSeekBarPreference mSeekBarPreference; + @EntryPoint + private int mEntryPoint; + private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener = new SeekBar.OnSeekBarChangeListener() { @Override @@ -45,6 +50,12 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements if (!mSeekByTouch && mInteractionListener != null) { mInteractionListener.onProgressChanged(); } + + SettingsStatsLog.write( + SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED, + AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()), + progress, + AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint)); } @Override @@ -96,6 +107,15 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements mSeekBarPreference.setProgress(defaultProgress); } + /** + * The entry point is used for logging. + * + * @param entryPoint from which settings page + */ + void setEntryPoint(@EntryPoint int entryPoint) { + mEntryPoint = entryPoint; + } + /** * Interface for callbacks when users interact with the seek bar. */ diff --git a/src/com/android/settings/accessibility/TextReadingFragmentBaseController.java b/src/com/android/settings/accessibility/TextReadingFragmentBaseController.java new file mode 100644 index 00000000000..f26ca962263 --- /dev/null +++ b/src/com/android/settings/accessibility/TextReadingFragmentBaseController.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EXTRA_LAUNCHED_FROM; + +import android.content.Context; +import android.os.Bundle; + +import androidx.preference.Preference; + +import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; +import com.android.settings.core.BasePreferenceController; + +/** + * The base controller for the fragment{@link TextReadingPreferenceFragment}. + */ +public class TextReadingFragmentBaseController extends BasePreferenceController { + @EntryPoint + private int mEntryPoint; + + private TextReadingFragmentBaseController(Context context, String preferenceKey) { + super(context, preferenceKey); + } + + TextReadingFragmentBaseController(Context context, String preferenceKey, + @EntryPoint int entryPoint) { + this(context, preferenceKey); + mEntryPoint = entryPoint; + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE; + } + + @Override + public boolean handlePreferenceTreeClick(Preference preference) { + if (getPreferenceKey().equals(preference.getKey())) { + final Bundle extras = preference.getExtras(); + extras.putInt(EXTRA_LAUNCHED_FROM, mEntryPoint); + } + + return super.handlePreferenceTreeClick(preference); + } +} diff --git a/src/com/android/settings/nearby/FastPairPreferenceController.java b/src/com/android/settings/accessibility/TextReadingFragmentForA11ySettingsController.java similarity index 50% rename from src/com/android/settings/nearby/FastPairPreferenceController.java rename to src/com/android/settings/accessibility/TextReadingFragmentForA11ySettingsController.java index a1152022c6b..434877c476a 100644 --- a/src/com/android/settings/nearby/FastPairPreferenceController.java +++ b/src/com/android/settings/accessibility/TextReadingFragmentForA11ySettingsController.java @@ -14,28 +14,19 @@ * limitations under the License. */ -package com.android.settings.nearby; +package com.android.settings.accessibility; + +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.ACCESSIBILITY_SETTINGS; import android.content.Context; -import androidx.lifecycle.LifecycleObserver; - -import com.android.settings.core.BasePreferenceController; - /** - * {@link BasePreferenceController} for Fast Pair settings. + * The controller for the {@link TextReadingPreferenceFragment} from the accessibility settings. */ -public class FastPairPreferenceController extends BasePreferenceController implements - LifecycleObserver { - public static final String TAG = "FastPairPrefController"; - public static final String KEY_FAST_PAIR_SETTINGS = "connected_device_fast_pair"; - - public FastPairPreferenceController(Context context) { - super(context, KEY_FAST_PAIR_SETTINGS); - } - - @Override - public int getAvailabilityStatus() { - return AVAILABLE; +public class TextReadingFragmentForA11ySettingsController extends + TextReadingFragmentBaseController { + public TextReadingFragmentForA11ySettingsController(Context context, String preferenceKey) { + // Pass the fixed entry point to the parent controller for logging. + super(context, preferenceKey, ACCESSIBILITY_SETTINGS); } } diff --git a/src/com/android/settings/accessibility/TextReadingFragmentForDisplaySettingsController.java b/src/com/android/settings/accessibility/TextReadingFragmentForDisplaySettingsController.java new file mode 100644 index 00000000000..4d603f9cf0e --- /dev/null +++ b/src/com/android/settings/accessibility/TextReadingFragmentForDisplaySettingsController.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.DISPLAY_SETTINGS; + +import android.content.Context; + +/** + * The controller for the {@link TextReadingPreferenceFragment} from the display settings. + */ +public class TextReadingFragmentForDisplaySettingsController extends + TextReadingFragmentBaseController { + public TextReadingFragmentForDisplaySettingsController(Context context, String preferenceKey) { + // Pass the fixed entry point to the parent controller for logging. + super(context, preferenceKey, DISPLAY_SETTINGS); + } +} diff --git a/src/com/android/settings/accessibility/TextReadingFragmentForSuwController.java b/src/com/android/settings/accessibility/TextReadingFragmentForSuwController.java new file mode 100644 index 00000000000..332d9c5ad07 --- /dev/null +++ b/src/com/android/settings/accessibility/TextReadingFragmentForSuwController.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.SUW_VISION_SETTINGS; + +import android.content.Context; + +/** + * The controller for the {@link TextReadingPreferenceFragment} during the SetupWizard. + */ +public class TextReadingFragmentForSuwController extends TextReadingFragmentBaseController { + public TextReadingFragmentForSuwController(Context context, String preferenceKey) { + // Pass the fixed entry point to the parent controller for logging. + super(context, preferenceKey, SUW_VISION_SETTINGS); + } +} diff --git a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java index a4ee961c1fc..104be2644a2 100644 --- a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java +++ b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java @@ -22,9 +22,11 @@ import android.app.Dialog; import android.app.settings.SettingsEnums; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.os.Bundle; import android.widget.Toast; +import androidx.annotation.IntDef; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; @@ -36,8 +38,11 @@ import com.android.settingslib.search.SearchIndexable; import com.google.common.annotations.VisibleForTesting; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; /** @@ -46,15 +51,40 @@ import java.util.stream.Collectors; */ @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) public class TextReadingPreferenceFragment extends DashboardFragment { + public static final String EXTRA_LAUNCHED_FROM = "launched_from"; private static final String TAG = "TextReadingPreferenceFragment"; - private static final String FONT_SIZE_KEY = "font_size"; - private static final String DISPLAY_SIZE_KEY = "display_size"; + private static final String CATEGORY_FOR_ANYTHING_ELSE = + "com.android.settings.suggested.category.DISPLAY_SETTINGS"; + static final String FONT_SIZE_KEY = "font_size"; + static final String DISPLAY_SIZE_KEY = "display_size"; + static final String BOLD_TEXT_KEY = "toggle_force_bold_text"; + static final String HIGH_TEXT_CONTRAST_KEY = "toggle_high_text_contrast_preference"; + static final String RESET_KEY = "reset"; private static final String PREVIEW_KEY = "preview"; - private static final String RESET_KEY = "reset"; - private static final String BOLD_TEXT_KEY = "toggle_force_bold_text"; - private static final String HIGHT_TEXT_CONTRAST_KEY = "toggle_high_text_contrast_preference"; private static final String NEED_RESET_SETTINGS = "need_reset_settings"; private FontWeightAdjustmentPreferenceController mFontWeightAdjustmentController; + private int mEntryPoint = EntryPoint.UNKNOWN_ENTRY; + + /** + * The entry point which launches the {@link TextReadingPreferenceFragment}. + * + *

This should only be used for logging. + */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({ + EntryPoint.UNKNOWN_ENTRY, + EntryPoint.SUW_VISION_SETTINGS, + EntryPoint.SUW_ANYTHING_ELSE, + EntryPoint.DISPLAY_SETTINGS, + EntryPoint.ACCESSIBILITY_SETTINGS, + }) + @interface EntryPoint { + int UNKNOWN_ENTRY = 0; + int SUW_VISION_SETTINGS = 1; + int SUW_ANYTHING_ELSE = 2; + int DISPLAY_SETTINGS = 3; + int ACCESSIBILITY_SETTINGS = 4; + } @VisibleForTesting List mResetStateListeners; @@ -91,6 +121,8 @@ public class TextReadingPreferenceFragment extends DashboardFragment { @Override protected List createPreferenceControllers(Context context) { + updateEntryPoint(); + final List controllers = new ArrayList<>(); final FontSizeData fontSizeData = new FontSizeData(context); final DisplaySizeData displaySizeData = createDisplaySizeData(context); @@ -102,24 +134,29 @@ public class TextReadingPreferenceFragment extends DashboardFragment { final PreviewSizeSeekBarController fontSizeController = new PreviewSizeSeekBarController( context, FONT_SIZE_KEY, fontSizeData); fontSizeController.setInteractionListener(previewController); + fontSizeController.setEntryPoint(mEntryPoint); controllers.add(fontSizeController); final PreviewSizeSeekBarController displaySizeController = new PreviewSizeSeekBarController( context, DISPLAY_SIZE_KEY, displaySizeData); displaySizeController.setInteractionListener(previewController); + displaySizeController.setEntryPoint(mEntryPoint); controllers.add(displaySizeController); mFontWeightAdjustmentController = new FontWeightAdjustmentPreferenceController(context, BOLD_TEXT_KEY); + mFontWeightAdjustmentController.setEntryPoint(mEntryPoint); controllers.add(mFontWeightAdjustmentController); final HighTextContrastPreferenceController highTextContrastController = - new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY); + new HighTextContrastPreferenceController(context, HIGH_TEXT_CONTRAST_KEY); + highTextContrastController.setEntryPoint(mEntryPoint); controllers.add(highTextContrastController); final TextReadingResetController resetController = new TextReadingResetController(context, RESET_KEY, v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS)); + resetController.setEntryPoint(mEntryPoint); controllers.add(resetController); return controllers; @@ -162,6 +199,24 @@ public class TextReadingPreferenceFragment extends DashboardFragment { return new DisplaySizeData(context); } + private void updateEntryPoint() { + final Bundle bundle = getArguments(); + if (bundle != null && bundle.containsKey(EXTRA_LAUNCHED_FROM)) { + mEntryPoint = bundle.getInt(EXTRA_LAUNCHED_FROM, EntryPoint.UNKNOWN_ENTRY); + return; + } + + final Intent intent = getIntent(); + if (intent == null) { + mEntryPoint = EntryPoint.UNKNOWN_ENTRY; + return; + } + + final Set categories = intent.getCategories(); + mEntryPoint = categories != null && categories.contains(CATEGORY_FOR_ANYTHING_ELSE) + ? EntryPoint.SUW_ANYTHING_ELSE : EntryPoint.UNKNOWN_ENTRY; + } + private void onPositiveButtonClicked(DialogInterface dialog, int which) { // To avoid showing the dialog again, probably the onDetach() of SettingsDialogFragment // was interrupted by unexpectedly recreating the activity. diff --git a/src/com/android/settings/accessibility/TextReadingResetController.java b/src/com/android/settings/accessibility/TextReadingResetController.java index 152ad5fe4f1..30a94c2eadd 100644 --- a/src/com/android/settings/accessibility/TextReadingResetController.java +++ b/src/com/android/settings/accessibility/TextReadingResetController.java @@ -23,7 +23,9 @@ import androidx.annotation.Nullable; import androidx.preference.PreferenceScreen; import com.android.settings.R; +import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; import com.android.settings.core.BasePreferenceController; +import com.android.settings.core.instrumentation.SettingsStatsLog; import com.android.settingslib.widget.LayoutPreference; /** @@ -32,6 +34,9 @@ import com.android.settingslib.widget.LayoutPreference; class TextReadingResetController extends BasePreferenceController { private final View.OnClickListener mOnResetClickListener; + @EntryPoint + private int mEntryPoint; + TextReadingResetController(Context context, String preferenceKey, @Nullable View.OnClickListener listener) { super(context, preferenceKey); @@ -52,10 +57,25 @@ class TextReadingResetController extends BasePreferenceController { view.setOnClickListener(v -> { if (mOnResetClickListener != null) { mOnResetClickListener.onClick(v); + + SettingsStatsLog.write( + SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED, + AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()), + /* reset */ -1, + AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint)); } }); } + /** + * The entry point is used for logging. + * + * @param entryPoint from which settings page + */ + void setEntryPoint(@EntryPoint int entryPoint) { + mEntryPoint = entryPoint; + } + /** * Interface for resetting to default state. */ diff --git a/src/com/android/settings/development/tare/AlarmManagerFragment.java b/src/com/android/settings/development/tare/AlarmManagerFragment.java index 980954d7bf9..b9de81db62a 100644 --- a/src/com/android/settings/development/tare/AlarmManagerFragment.java +++ b/src/com/android/settings/development/tare/AlarmManagerFragment.java @@ -98,6 +98,7 @@ public class AlarmManagerFragment extends Fragment implements resources.getString(R.string.tare_actions_ctp), resources.getString(R.string.tare_actions_base_price), resources.getString(R.string.tare_rewards_instantaneous), + resources.getString(R.string.tare_rewards_ongoing), resources.getString(R.string.tare_rewards_max) }; @@ -109,6 +110,7 @@ public class AlarmManagerFragment extends Fragment implements resources.getStringArray(R.array.tare_alarm_manager_actions), resources.getStringArray(R.array.tare_alarm_manager_actions), resources.getStringArray(R.array.tare_rewards_subfactors), + {resources.getString(R.string.tare_top_activity)}, resources.getStringArray(R.array.tare_rewards_subfactors) }; @@ -150,12 +152,13 @@ public class AlarmManagerFragment extends Fragment implements EconomyManager.KEY_AM_ACTION_ALARM_ALARMCLOCK_BASE_PRICE }, { - EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_MAX, - EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_MAX, - EconomyManager.KEY_AM_REWARD_NOTIFICATION_INTERACTION_MAX, - EconomyManager.KEY_AM_REWARD_WIDGET_INTERACTION_MAX, - EconomyManager.KEY_AM_REWARD_OTHER_USER_INTERACTION_MAX, + EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_INSTANT, + EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_INSTANT, + EconomyManager.KEY_AM_REWARD_NOTIFICATION_INTERACTION_INSTANT, + EconomyManager.KEY_AM_REWARD_WIDGET_INTERACTION_INSTANT, + EconomyManager.KEY_AM_REWARD_OTHER_USER_INTERACTION_INSTANT, }, + {EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_ONGOING}, { EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_MAX, EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_MAX, diff --git a/src/com/android/settings/development/tare/JobSchedulerFragment.java b/src/com/android/settings/development/tare/JobSchedulerFragment.java index bffd648c6be..4c5fcc69724 100644 --- a/src/com/android/settings/development/tare/JobSchedulerFragment.java +++ b/src/com/android/settings/development/tare/JobSchedulerFragment.java @@ -99,7 +99,7 @@ public class JobSchedulerFragment extends Fragment implements resources.getString(R.string.tare_actions_ctp), resources.getString(R.string.tare_actions_base_price), resources.getString(R.string.tare_rewards_instantaneous), - // resources.getString(R.string.tare_rewards_ongoing), + resources.getString(R.string.tare_rewards_ongoing), resources.getString(R.string.tare_rewards_max) }; @@ -111,7 +111,7 @@ public class JobSchedulerFragment extends Fragment implements resources.getStringArray(R.array.tare_job_scheduler_actions), resources.getStringArray(R.array.tare_job_scheduler_actions), resources.getStringArray(R.array.tare_rewards_subfactors), - // {resources.getString(R.string.tare_top_activity)}, + {resources.getString(R.string.tare_top_activity)}, resources.getStringArray(R.array.tare_rewards_subfactors) }; @@ -154,13 +154,13 @@ public class JobSchedulerFragment extends Fragment implements EconomyManager.KEY_JS_ACTION_JOB_TIMEOUT_PENALTY_BASE_PRICE }, { - EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_MAX, - EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_MAX, - EconomyManager.KEY_JS_REWARD_NOTIFICATION_INTERACTION_MAX, - EconomyManager.KEY_JS_REWARD_WIDGET_INTERACTION_MAX, - EconomyManager.KEY_JS_REWARD_OTHER_USER_INTERACTION_MAX, + EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_INSTANT, + EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_INSTANT, + EconomyManager.KEY_JS_REWARD_NOTIFICATION_INTERACTION_INSTANT, + EconomyManager.KEY_JS_REWARD_WIDGET_INTERACTION_INSTANT, + EconomyManager.KEY_JS_REWARD_OTHER_USER_INTERACTION_INSTANT, }, - // {EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_ONGOING}, + {EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_ONGOING}, { EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_MAX, EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_MAX, diff --git a/src/com/android/settings/development/tare/TareFactorController.java b/src/com/android/settings/development/tare/TareFactorController.java index 62fde6d4829..57723927510 100644 --- a/src/com/android/settings/development/tare/TareFactorController.java +++ b/src/com/android/settings/development/tare/TareFactorController.java @@ -16,6 +16,12 @@ package com.android.settings.development.tare; +import static android.app.tare.EconomyManager.CAKE_IN_ARC; +import static android.app.tare.EconomyManager.DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_WAKEUP_BASE_PRICE_CAKES; +import static android.app.tare.EconomyManager.DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_BASE_PRICE_CAKES; +import static android.app.tare.EconomyManager.DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_CTP_CAKES; +import static android.app.tare.EconomyManager.DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_WAKEUP_BASE_PRICE_CAKES; +import static android.app.tare.EconomyManager.parseCreditValue; import static android.provider.Settings.Global.TARE_ALARM_MANAGER_CONSTANTS; import static android.provider.Settings.Global.TARE_JOB_SCHEDULER_CONSTANTS; @@ -93,182 +99,180 @@ public class TareFactorController { private void initAlarmManagerMap() { mAlarmManagerMap.put(EconomyManager.KEY_AM_MIN_SATIATED_BALANCE_EXEMPTED, new TareFactorData(mResources.getString(R.string.tare_min_balance_exempted), - EconomyManager.DEFAULT_AM_MIN_SATIATED_BALANCE_EXEMPTED, + EconomyManager.DEFAULT_AM_MIN_SATIATED_BALANCE_EXEMPTED_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_MIN_SATIATED_BALANCE_HEADLESS_SYSTEM_APP, new TareFactorData(mResources.getString(R.string.tare_min_balance_headless_app), - EconomyManager.DEFAULT_AM_MIN_SATIATED_BALANCE_HEADLESS_SYSTEM_APP, + EconomyManager.DEFAULT_AM_MIN_SATIATED_BALANCE_HEADLESS_SYSTEM_APP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_MIN_SATIATED_BALANCE_OTHER_APP, new TareFactorData(mResources.getString(R.string.tare_min_balance_other_app), - EconomyManager.DEFAULT_AM_MIN_SATIATED_BALANCE_OTHER_APP, + EconomyManager.DEFAULT_AM_MIN_SATIATED_BALANCE_OTHER_APP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_MAX_SATIATED_BALANCE, new TareFactorData(mResources.getString(R.string.tare_max_satiated_balance), - EconomyManager.DEFAULT_AM_MAX_SATIATED_BALANCE, + EconomyManager.DEFAULT_AM_MAX_SATIATED_BALANCE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_INITIAL_CONSUMPTION_LIMIT, new TareFactorData(mResources.getString(R.string.tare_initial_consumption_limit), - EconomyManager.DEFAULT_AM_INITIAL_CONSUMPTION_LIMIT, + EconomyManager.DEFAULT_AM_INITIAL_CONSUMPTION_LIMIT_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_HARD_CONSUMPTION_LIMIT, new TareFactorData(mResources.getString(R.string.tare_hard_consumption_limit), - EconomyManager.DEFAULT_AM_HARD_CONSUMPTION_LIMIT, + EconomyManager.DEFAULT_AM_HARD_CONSUMPTION_LIMIT_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_INSTANT, new TareFactorData(mResources.getString(R.string.tare_top_activity), - EconomyManager.DEFAULT_AM_REWARD_TOP_ACTIVITY_INSTANT, + EconomyManager.DEFAULT_AM_REWARD_TOP_ACTIVITY_INSTANT_CAKES, + POLICY_ALARM_MANAGER)); + mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_ONGOING, + new TareFactorData(mResources.getString(R.string.tare_top_activity), + EconomyManager.DEFAULT_AM_REWARD_TOP_ACTIVITY_ONGOING_CAKES, POLICY_ALARM_MANAGER)); - // TODO: Add support to handle floats - // mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_ONGOING, - // new TareFactorData(mResources.getString(R.string.tare_top_activity), - // EconomyManager.DEFAULT_AM_REWARD_TOP_ACTIVITY_ONGOING)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_MAX, new TareFactorData(mResources.getString(R.string.tare_top_activity), - EconomyManager.DEFAULT_AM_REWARD_TOP_ACTIVITY_MAX, POLICY_ALARM_MANAGER)); + EconomyManager.DEFAULT_AM_REWARD_TOP_ACTIVITY_MAX_CAKES, + POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_INSTANT, new TareFactorData(mResources.getString(R.string.tare_notification_seen), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_INSTANT, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_INSTANT_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_ONGOING, new TareFactorData(mResources.getString(R.string.tare_notification_seen), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_ONGOING, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_ONGOING_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_MAX, new TareFactorData(mResources.getString(R.string.tare_notification_seen), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_MAX, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_MAX_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_INSTANT, new TareFactorData(mResources.getString(R.string.tare_notification_seen_15_min), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_INSTANT, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_INSTANT_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_ONGOING, new TareFactorData(mResources.getString(R.string.tare_notification_seen_15_min), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_ONGOING, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_ONGOING_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_MAX, new TareFactorData(mResources.getString(R.string.tare_notification_seen_15_min), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_MAX, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_SEEN_WITHIN_15_MAX_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_INTERACTION_INSTANT, new TareFactorData(mResources.getString(R.string.tare_notification_interaction), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_INTERACTION_INSTANT, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_INTERACTION_INSTANT_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_INTERACTION_ONGOING, new TareFactorData(mResources.getString(R.string.tare_notification_interaction), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_INTERACTION_ONGOING, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_INTERACTION_ONGOING_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_NOTIFICATION_INTERACTION_MAX, new TareFactorData(mResources.getString(R.string.tare_notification_interaction), - EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_INTERACTION_MAX, + EconomyManager.DEFAULT_AM_REWARD_NOTIFICATION_INTERACTION_MAX_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_WIDGET_INTERACTION_INSTANT, new TareFactorData(mResources.getString(R.string.tare_widget_interaction), - EconomyManager.DEFAULT_AM_REWARD_WIDGET_INTERACTION_INSTANT, + EconomyManager.DEFAULT_AM_REWARD_WIDGET_INTERACTION_INSTANT_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_WIDGET_INTERACTION_ONGOING, new TareFactorData(mResources.getString(R.string.tare_widget_interaction), - EconomyManager.DEFAULT_AM_REWARD_WIDGET_INTERACTION_ONGOING, + EconomyManager.DEFAULT_AM_REWARD_WIDGET_INTERACTION_ONGOING_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_WIDGET_INTERACTION_MAX, new TareFactorData(mResources.getString(R.string.tare_widget_interaction), - EconomyManager.DEFAULT_AM_REWARD_WIDGET_INTERACTION_MAX, + EconomyManager.DEFAULT_AM_REWARD_WIDGET_INTERACTION_MAX_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_OTHER_USER_INTERACTION_INSTANT, new TareFactorData(mResources.getString(R.string.tare_other_interaction), - EconomyManager.DEFAULT_AM_REWARD_OTHER_USER_INTERACTION_INSTANT, + EconomyManager.DEFAULT_AM_REWARD_OTHER_USER_INTERACTION_INSTANT_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_OTHER_USER_INTERACTION_ONGOING, new TareFactorData(mResources.getString(R.string.tare_other_interaction), - EconomyManager.DEFAULT_AM_REWARD_OTHER_USER_INTERACTION_ONGOING, + EconomyManager.DEFAULT_AM_REWARD_OTHER_USER_INTERACTION_ONGOING_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_REWARD_OTHER_USER_INTERACTION_MAX, new TareFactorData(mResources.getString(R.string.tare_other_interaction), - EconomyManager.DEFAULT_AM_REWARD_OTHER_USER_INTERACTION_MAX, + EconomyManager.DEFAULT_AM_REWARD_OTHER_USER_INTERACTION_MAX_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_WAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_wakeup_exact_idle), - EconomyManager.DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_WAKEUP_CTP, + EconomyManager + .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_WAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_WAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_wakeup_inexact_idle), EconomyManager - .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_WAKEUP_CTP, + .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_WAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_EXACT_WAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_wakeup_exact), - EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_CTP, + EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_INEXACT_WAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_wakeup_inexact), - EconomyManager.DEFAULT_AM_ACTION_ALARM_INEXACT_WAKEUP_CTP, + EconomyManager.DEFAULT_AM_ACTION_ALARM_INEXACT_WAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put( EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_NONWAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_nonwakeup_exact_idle), EconomyManager - .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_NONWAKEUP_CTP, + .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_NONWAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_EXACT_NONWAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_nonwakeup_exact), - EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_NONWAKEUP_CTP, + EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_NONWAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put( EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_nonwakeup_inexact_idle), - EconomyManager - .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_CTP, + DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_INEXACT_NONWAKEUP_CTP, new TareFactorData(mResources.getString(R.string.tare_nonwakeup_inexact), - EconomyManager.DEFAULT_AM_ACTION_ALARM_INEXACT_NONWAKEUP_CTP, + EconomyManager.DEFAULT_AM_ACTION_ALARM_INEXACT_NONWAKEUP_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_ALARMCLOCK_CTP, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager.DEFAULT_AM_ACTION_ALARM_ALARMCLOCK_CTP, + EconomyManager.DEFAULT_AM_ACTION_ALARM_ALARMCLOCK_CTP_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put( EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_WAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager - .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_WAKEUP_BASE_PRICE, + DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_WAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put( EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_WAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager - .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_WAKEUP_BASE_PRICE, + DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_WAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE, + EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_INEXACT_WAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE, + EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put( EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_EXACT_NONWAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE, + EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_EXACT_NONWAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE, + EconomyManager.DEFAULT_AM_ACTION_ALARM_EXACT_WAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put( EconomyManager.KEY_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager - .DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_BASE_PRICE, + DEFAULT_AM_ACTION_ALARM_ALLOW_WHILE_IDLE_INEXACT_NONWAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_INEXACT_NONWAKEUP_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager.DEFAULT_AM_ACTION_ALARM_INEXACT_NONWAKEUP_BASE_PRICE, + EconomyManager.DEFAULT_AM_ACTION_ALARM_INEXACT_NONWAKEUP_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); mAlarmManagerMap.put(EconomyManager.KEY_AM_ACTION_ALARM_ALARMCLOCK_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_alarm_clock), - EconomyManager.DEFAULT_AM_ACTION_ALARM_ALARMCLOCK_BASE_PRICE, + EconomyManager.DEFAULT_AM_ACTION_ALARM_ALARMCLOCK_BASE_PRICE_CAKES, POLICY_ALARM_MANAGER)); } @@ -279,180 +283,181 @@ public class TareFactorController { private void initJobSchedulerMap() { mJobSchedulerMap.put(EconomyManager.KEY_JS_MIN_SATIATED_BALANCE_EXEMPTED, new TareFactorData(mResources.getString(R.string.tare_min_balance_exempted), - EconomyManager.DEFAULT_JS_MIN_SATIATED_BALANCE_EXEMPTED, + EconomyManager.DEFAULT_JS_MIN_SATIATED_BALANCE_EXEMPTED_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_MIN_SATIATED_BALANCE_HEADLESS_SYSTEM_APP, new TareFactorData(mResources.getString(R.string.tare_min_balance_headless_app), - EconomyManager.DEFAULT_JS_MIN_SATIATED_BALANCE_HEADLESS_SYSTEM_APP, + EconomyManager.DEFAULT_JS_MIN_SATIATED_BALANCE_HEADLESS_SYSTEM_APP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_MIN_SATIATED_BALANCE_OTHER_APP, new TareFactorData(mResources.getString(R.string.tare_min_balance_other_app), - EconomyManager.DEFAULT_JS_MIN_SATIATED_BALANCE_OTHER_APP, + EconomyManager.DEFAULT_JS_MIN_SATIATED_BALANCE_OTHER_APP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_MAX_SATIATED_BALANCE, new TareFactorData(mResources.getString(R.string.tare_max_satiated_balance), - EconomyManager.DEFAULT_JS_MAX_SATIATED_BALANCE, + EconomyManager.DEFAULT_JS_MAX_SATIATED_BALANCE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_INITIAL_CONSUMPTION_LIMIT, new TareFactorData(mResources.getString(R.string.tare_initial_consumption_limit), - EconomyManager.DEFAULT_JS_INITIAL_CONSUMPTION_LIMIT, + EconomyManager.DEFAULT_JS_INITIAL_CONSUMPTION_LIMIT_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_HARD_CONSUMPTION_LIMIT, new TareFactorData(mResources.getString(R.string.tare_hard_consumption_limit), - EconomyManager.DEFAULT_JS_HARD_CONSUMPTION_LIMIT, + EconomyManager.DEFAULT_JS_HARD_CONSUMPTION_LIMIT_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_INSTANT, new TareFactorData(mResources.getString(R.string.tare_top_activity), - EconomyManager.DEFAULT_JS_REWARD_TOP_ACTIVITY_INSTANT, + EconomyManager.DEFAULT_JS_REWARD_TOP_ACTIVITY_INSTANT_CAKES, + POLICY_JOB_SCHEDULER)); + mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_ONGOING, + new TareFactorData(mResources.getString(R.string.tare_top_activity), + EconomyManager.DEFAULT_JS_REWARD_TOP_ACTIVITY_ONGOING_CAKES, POLICY_JOB_SCHEDULER)); - // TODO: Add support to handle floats - // mAlarmManagerMap.put(EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_ONGOING, - // new TareFactorData(mResources.getString(R.string.tare_top_activity), - // EconomyManager.DEFAULT_JS_REWARD_TOP_ACTIVITY_ONGOING)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_MAX, new TareFactorData(mResources.getString(R.string.tare_top_activity), - EconomyManager.DEFAULT_JS_REWARD_TOP_ACTIVITY_MAX, POLICY_JOB_SCHEDULER)); + EconomyManager.DEFAULT_JS_REWARD_TOP_ACTIVITY_MAX_CAKES, + POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_INSTANT, new TareFactorData(mResources.getString(R.string.tare_notification_seen), - EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_SEEN_INSTANT, + EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_SEEN_INSTANT_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_ONGOING, new TareFactorData(mResources.getString(R.string.tare_notification_seen), - EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_SEEN_ONGOING, + EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_SEEN_ONGOING_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_MAX, new TareFactorData(mResources.getString(R.string.tare_notification_seen), - EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_SEEN_MAX, + EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_SEEN_MAX_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_NOTIFICATION_INTERACTION_INSTANT, new TareFactorData(mResources.getString(R.string.tare_notification_interaction), - EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_INTERACTION_INSTANT, + EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_INTERACTION_INSTANT_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_NOTIFICATION_INTERACTION_ONGOING, new TareFactorData(mResources.getString(R.string.tare_notification_interaction), - EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_INTERACTION_ONGOING, + EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_INTERACTION_ONGOING_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_NOTIFICATION_INTERACTION_MAX, new TareFactorData(mResources.getString(R.string.tare_notification_interaction), - EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_INTERACTION_MAX, + EconomyManager.DEFAULT_JS_REWARD_NOTIFICATION_INTERACTION_MAX_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_WIDGET_INTERACTION_INSTANT, new TareFactorData(mResources.getString(R.string.tare_widget_interaction), - EconomyManager.DEFAULT_JS_REWARD_WIDGET_INTERACTION_INSTANT, + EconomyManager.DEFAULT_JS_REWARD_WIDGET_INTERACTION_INSTANT_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_WIDGET_INTERACTION_ONGOING, new TareFactorData(mResources.getString(R.string.tare_widget_interaction), - EconomyManager.DEFAULT_JS_REWARD_WIDGET_INTERACTION_ONGOING, + EconomyManager.DEFAULT_JS_REWARD_WIDGET_INTERACTION_ONGOING_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_WIDGET_INTERACTION_MAX, new TareFactorData(mResources.getString(R.string.tare_widget_interaction), - EconomyManager.DEFAULT_JS_REWARD_WIDGET_INTERACTION_MAX, + EconomyManager.DEFAULT_JS_REWARD_WIDGET_INTERACTION_MAX_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_OTHER_USER_INTERACTION_INSTANT, new TareFactorData(mResources.getString(R.string.tare_other_interaction), - EconomyManager.DEFAULT_JS_REWARD_OTHER_USER_INTERACTION_INSTANT, + EconomyManager.DEFAULT_JS_REWARD_OTHER_USER_INTERACTION_INSTANT_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_OTHER_USER_INTERACTION_ONGOING, new TareFactorData(mResources.getString(R.string.tare_other_interaction), - EconomyManager.DEFAULT_JS_REWARD_OTHER_USER_INTERACTION_ONGOING, + EconomyManager.DEFAULT_JS_REWARD_OTHER_USER_INTERACTION_ONGOING_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_REWARD_OTHER_USER_INTERACTION_MAX, new TareFactorData(mResources.getString(R.string.tare_other_interaction), - EconomyManager.DEFAULT_JS_REWARD_OTHER_USER_INTERACTION_MAX, + EconomyManager.DEFAULT_JS_REWARD_OTHER_USER_INTERACTION_MAX_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_MAX_START_CTP, new TareFactorData(mResources.getString(R.string.tare_job_max_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_START_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_START_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_MAX_RUNNING_CTP, new TareFactorData(mResources.getString(R.string.tare_job_max_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_RUNNING_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_RUNNING_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_HIGH_START_CTP, new TareFactorData(mResources.getString(R.string.tare_job_high_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_START_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_START_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_HIGH_RUNNING_CTP, new TareFactorData(mResources.getString(R.string.tare_job_high_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_RUNNING_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_RUNNING_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_DEFAULT_START_CTP, new TareFactorData(mResources.getString(R.string.tare_job_default_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_START_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_START_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_DEFAULT_RUNNING_CTP, new TareFactorData(mResources.getString(R.string.tare_job_default_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_RUNNING_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_RUNNING_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_LOW_START_CTP, new TareFactorData(mResources.getString(R.string.tare_job_low_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_START_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_START_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put( EconomyManager.KEY_JS_ACTION_JOB_LOW_RUNNING_CTP, new TareFactorData(mResources.getString(R.string.tare_job_low_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_RUNNING_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_RUNNING_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_MIN_START_CTP, new TareFactorData(mResources.getString(R.string.tare_job_min_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_START_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_START_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put( EconomyManager.KEY_JS_ACTION_JOB_MIN_RUNNING_CTP, new TareFactorData(mResources.getString(R.string.tare_job_min_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_RUNNING_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_RUNNING_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_TIMEOUT_PENALTY_CTP, new TareFactorData(mResources.getString(R.string.tare_job_timeout_penalty), - EconomyManager.DEFAULT_JS_ACTION_JOB_TIMEOUT_PENALTY_CTP, + EconomyManager.DEFAULT_JS_ACTION_JOB_TIMEOUT_PENALTY_CTP_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_MAX_START_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_max_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_START_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_START_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put( EconomyManager.KEY_JS_ACTION_JOB_MAX_RUNNING_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_max_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_RUNNING_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_MAX_RUNNING_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put( EconomyManager.KEY_JS_ACTION_JOB_HIGH_START_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_high_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_START_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_START_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_HIGH_RUNNING_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_high_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_RUNNING_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_HIGH_RUNNING_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_DEFAULT_START_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_default_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_START_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_START_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put( EconomyManager.KEY_JS_ACTION_JOB_DEFAULT_RUNNING_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_default_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_RUNNING_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_DEFAULT_RUNNING_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_LOW_START_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_low_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_START_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_START_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put( EconomyManager.KEY_JS_ACTION_JOB_LOW_RUNNING_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_low_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_RUNNING_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_LOW_RUNNING_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_MIN_START_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_min_start), - EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_START_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_START_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_MIN_RUNNING_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_min_running), - EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_RUNNING_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_MIN_RUNNING_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); mJobSchedulerMap.put(EconomyManager.KEY_JS_ACTION_JOB_TIMEOUT_PENALTY_BASE_PRICE, new TareFactorData(mResources.getString(R.string.tare_job_timeout_penalty), - EconomyManager.DEFAULT_JS_ACTION_JOB_TIMEOUT_PENALTY_BASE_PRICE, + EconomyManager.DEFAULT_JS_ACTION_JOB_TIMEOUT_PENALTY_BASE_PRICE_CAKES, POLICY_JOB_SCHEDULER)); } @@ -480,7 +485,7 @@ public class TareFactorController { for (int i = map.size() - 1; i >= 0; --i) { final String key = map.keyAt(i); final TareFactorData data = map.valueAt(i); - data.currentValue = mParser.getInt(key, data.defaultValue); + data.currentValue = parseCreditValue(mParser.getString(key, null), data.defaultValue); } } @@ -513,7 +518,7 @@ public class TareFactorController { * @param key the key of the factor you want to get the default value of * @param factorPolicy the policy you want the current value of */ - private int getCurrentValue(String key, int factorPolicy) { + private long getCurrentValue(String key, int factorPolicy) { final ArrayMap currentMap = getMap(factorPolicy); return currentMap.get(key).currentValue; } @@ -535,7 +540,7 @@ public class TareFactorController { return currentMap.get(key).factorPolicy; } - int getValue(String key) { + long getValue(String key) { final int policy = getFactorType(key); return getCurrentValue(key, policy); } @@ -548,7 +553,7 @@ public class TareFactorController { * @param editedValue the value entered by the user in the dialog * @param factorPolicy policy being updated */ - public void updateValue(String key, int editedValue, int factorPolicy) { + public void updateValue(String key, long editedValue, int factorPolicy) { final ArrayMap map = getMap(factorPolicy); final TareFactorData data = map.get(key); @@ -592,8 +597,16 @@ public class TareFactorController { constantsStringBuilder .append(factorMap.keyAt(i)) - .append("=") - .append(factor.currentValue); + .append("="); + if (factor.currentValue % CAKE_IN_ARC == 0) { + constantsStringBuilder + .append(factor.currentValue / CAKE_IN_ARC) + .append("A"); + } else { + constantsStringBuilder + .append(factor.currentValue) + .append("ck"); + } } Settings.Global.putString(mContentResolver, settingsKey, constantsStringBuilder.toString()); @@ -615,11 +628,11 @@ public class TareFactorController { */ private static class TareFactorData { public final String title; - public final int defaultValue; + public final long defaultValue; public final int factorPolicy; - public int currentValue; + public long currentValue; - TareFactorData(String title, int defaultValue, int factorPolicy) { + TareFactorData(String title, long defaultValue, int factorPolicy) { this.title = title; this.defaultValue = defaultValue; this.factorPolicy = factorPolicy; diff --git a/src/com/android/settings/development/tare/TareFactorDialogFragment.java b/src/com/android/settings/development/tare/TareFactorDialogFragment.java index 8d2f3415651..6d2f5ca3713 100644 --- a/src/com/android/settings/development/tare/TareFactorDialogFragment.java +++ b/src/com/android/settings/development/tare/TareFactorDialogFragment.java @@ -16,6 +16,8 @@ package com.android.settings.development.tare; +import static android.app.tare.EconomyManager.CAKE_IN_ARC; + import android.annotation.NonNull; import android.app.AlertDialog; import android.app.Dialog; @@ -26,7 +28,10 @@ import android.text.InputType; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.EditText; +import android.widget.Spinner; import com.android.settings.R; import com.android.settings.Utils; @@ -35,39 +40,35 @@ import com.android.settings.Utils; * Dialog Fragment for changing tare factor values */ public class TareFactorDialogFragment extends DialogFragment { - private static final String TAG = "TareDialogFragment"; + // This follows the order in strings.xml:tare_units array. + private static final int UNIT_IDX_ARC = 0; + private static final int UNIT_IDX_CAKE = 1; + private final String mFactorKey; private final String mFactorTitle; - private final int mFactorValue; + private final long mFactorValue; private final int mFactorPolicy; - private int mFactorEditedValue; + private final TareFactorController mTareFactorController; private EditText mFactorValueView; - private TareFactorController mTareFactorController; + private Spinner mUnitSpinner; /** * @param title the title that will show at the top of the Dialog for the Factor * @param key the key of the Factor being initialized. - * @param defaultValue the initial value set for the Factor before any changes + * @param currentValue the current value set for the Factor */ - public TareFactorDialogFragment(@NonNull String title, @NonNull String key, int defaultValue, + public TareFactorDialogFragment(@NonNull String title, @NonNull String key, long currentValue, int factorPolicy, TareFactorController tareFactorController) { mFactorTitle = title; mFactorKey = key; - mFactorValue = defaultValue; + mFactorValue = currentValue; mFactorPolicy = factorPolicy; mTareFactorController = tareFactorController; } - /** - * Gets the current value of the Factor - */ - private String getFactorValue() { - return Integer.toString(mFactorValue); - } - @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -78,15 +79,18 @@ public class TareFactorDialogFragment extends DialogFragment { .setPositiveButton(R.string.tare_dialog_confirm_button_title, (dialog, which) -> { final String stringValue = mFactorValueView.getText().toString(); - mFactorEditedValue = mFactorValue; + long newVal = mFactorValue; try { - mFactorEditedValue = Integer.parseInt(stringValue); + newVal = Long.parseLong(stringValue); + if (mUnitSpinner.getSelectedItemPosition() == UNIT_IDX_ARC) { + // Convert ARC to cake + newVal *= CAKE_IN_ARC; + } } catch (NumberFormatException e) { - Log.e(TAG, "Error converting '" + stringValue + "' to integer. Using " + Log.e(TAG, "Error parsing '" + stringValue + "'. Using " + mFactorValue + " instead", e); } - mTareFactorController.updateValue(mFactorKey, mFactorEditedValue, - mFactorPolicy); + mTareFactorController.updateValue(mFactorKey, newVal, mFactorPolicy); }) .setNegativeButton(android.R.string.cancel, (dialog, which) -> { // When the negative button is clicked do nothing @@ -102,12 +106,58 @@ public class TareFactorDialogFragment extends DialogFragment { private View createDialogView() { final LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View layout = layoutInflater.inflate(R.layout.dialog_edittext, null); + View layout = layoutInflater.inflate(R.layout.dialog_edittext_dropdown, null); mFactorValueView = layout.findViewById(R.id.edittext); mFactorValueView.setInputType(InputType.TYPE_CLASS_NUMBER); - mFactorValueView.setText(getFactorValue()); - Utils.setEditTextCursorPosition(mFactorValueView); + mUnitSpinner = layout.findViewById(R.id.spinner); + final String[] units = getResources().getStringArray(R.array.tare_units); + ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>( + getActivity(), android.R.layout.simple_spinner_item, units); + mUnitSpinner.setAdapter(spinnerArrayAdapter); + + final int unitIdx; + if (mFactorValue % CAKE_IN_ARC == 0) { + mFactorValueView.setText(String.format("%d", mFactorValue / CAKE_IN_ARC)); + unitIdx = UNIT_IDX_ARC; + } else { + mFactorValueView.setText(String.format("%d", mFactorValue)); + unitIdx = UNIT_IDX_CAKE; + } + mUnitSpinner.setSelection(unitIdx); + mUnitSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + private int mSelectedPosition = unitIdx; + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + if (mSelectedPosition == position) { + return; + } + mSelectedPosition = position; + final String stringValue = mFactorValueView.getText().toString(); + + try { + long newVal = Long.parseLong(stringValue); + if (mUnitSpinner.getSelectedItemPosition() == UNIT_IDX_ARC) { + // Convert cake to ARC + newVal /= CAKE_IN_ARC; + } else { + // Convert ARC to cake + newVal *= CAKE_IN_ARC; + } + mFactorValueView.setText(String.format("%d", newVal)); + } catch (NumberFormatException e) { + Log.e(TAG, "Error parsing '" + stringValue + "'", e); + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + Utils.setEditTextCursorPosition(mFactorValueView); return layout; } } diff --git a/src/com/android/settings/development/tare/TareFactorExpandableListAdapter.java b/src/com/android/settings/development/tare/TareFactorExpandableListAdapter.java index 8fe4c058207..79b7d41f9ec 100644 --- a/src/com/android/settings/development/tare/TareFactorExpandableListAdapter.java +++ b/src/com/android/settings/development/tare/TareFactorExpandableListAdapter.java @@ -16,6 +16,8 @@ package com.android.settings.development.tare; +import static android.app.tare.EconomyManager.CAKE_IN_ARC; + import android.annotation.NonNull; import android.annotation.SuppressLint; import android.view.LayoutInflater; @@ -130,12 +132,32 @@ public class TareFactorExpandableListAdapter extends BaseExpandableListAdapter { TextView value = convertView.findViewById(R.id.factor_number); factor.setText(getChild(groupPosition, childPosition).toString()); - value.setText(String.valueOf( + value.setText(cakeToString( mFactorController.getValue(getKey(groupPosition, childPosition)))); return convertView; } + @NonNull + private static String cakeToString(long cakes) { + // Resources.getQuantityString doesn't handle floating point numbers, so doing this manually + if (cakes == 0) { + return "0"; + } + final long sub = cakes % CAKE_IN_ARC; + final long arcs = (int) (cakes / CAKE_IN_ARC); + if (arcs == 0) { + return sub + " c"; + } + StringBuilder sb = new StringBuilder(); + sb.append(arcs); + if (sub > 0) { + sb.append(".").append(String.format("%03d", sub / (CAKE_IN_ARC / 1000))); + } + sb.append(" A"); + return sb.toString(); + } + @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; diff --git a/src/com/android/settings/nearby/FastPairSettingsFragment.java b/src/com/android/settings/nearby/FastPairSettingsFragment.java deleted file mode 100644 index a92833a3db7..00000000000 --- a/src/com/android/settings/nearby/FastPairSettingsFragment.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.nearby; - -import android.app.settings.SettingsEnums; -import android.content.ComponentName; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.os.Bundle; -import android.provider.Settings; -import android.text.TextUtils; -import android.util.Log; - -import androidx.annotation.Nullable; -import androidx.preference.Preference; - -import com.android.settings.R; -import com.android.settings.SettingsPreferenceFragment; -import com.android.settings.search.BaseSearchIndexProvider; -import com.android.settingslib.search.SearchIndexable; -import com.android.settingslib.widget.MainSwitchPreference; - -import java.util.Objects; - -/** - * Fragment with the top level fast pair settings. - */ -@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) -public class FastPairSettingsFragment extends SettingsPreferenceFragment { - - private static final String TAG = "FastPairSettingsFrag"; - - private static final String SCAN_SWITCH_KEY = "fast_pair_scan_switch"; - private static final String SAVED_DEVICES_PREF_KEY = "saved_devices"; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - MainSwitchPreference mainSwitchPreference = Objects.requireNonNull( - findPreference(SCAN_SWITCH_KEY)); - mainSwitchPreference.setChecked(false); - - Preference savedDevicePref = Objects.requireNonNull( - findPreference(SAVED_DEVICES_PREF_KEY)); - savedDevicePref.setOnPreferenceClickListener(preference -> { - Intent savedDevicesIntent = getSavedDevicesIntent(); - if (savedDevicesIntent != null && getActivity() != null) { - getActivity().startActivity(savedDevicesIntent); - } - return true; - }); - } - - @Override - public int getMetricsCategory() { - return SettingsEnums.CONNECTION_DEVICE_ADVANCED_FAST_PAIR; - } - - @Override - public int getHelpResource() { - return 0; - } - - @Override - protected int getPreferenceScreenResId() { - return R.xml.fast_pair_settings; - } - - public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = - new BaseSearchIndexProvider(R.xml.fast_pair_settings); - - @Nullable - private ComponentName getSavedDevicesComponent() { - String savedDevicesComponent = Settings.Secure.getString( - getContentResolver(), - Settings.Secure.NEARBY_FAST_PAIR_SETTINGS_DEVICES_COMPONENT); - if (TextUtils.isEmpty(savedDevicesComponent)) { - savedDevicesComponent = getString( - com.android.internal.R.string.config_defaultNearbyFastPairSettingsDevicesComponent); - } - - if (TextUtils.isEmpty(savedDevicesComponent)) { - return null; - } - - return ComponentName.unflattenFromString(savedDevicesComponent); - } - - @Nullable - private Intent getSavedDevicesIntent() { - ComponentName componentName = getSavedDevicesComponent(); - if (componentName == null) { - return null; - } - - PackageManager pm = getPackageManager(); - Intent intent = getIntent(); - intent.setAction(Intent.ACTION_VIEW); - intent.setComponent(componentName); - - final ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.GET_META_DATA); - if (resolveInfo == null || resolveInfo.activityInfo == null) { - Log.e(TAG, "Device-specified fast pair component (" + componentName - + ") not available"); - return null; - } - return intent; - } -} diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java index 218e3ecb4ba..44ad411c832 100644 --- a/src/com/android/settings/network/SubscriptionsPreferenceController.java +++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java @@ -232,11 +232,11 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl connectCarrierNetwork(); return true; }); - - mSubsGearPref.setOnGearClickListener(p -> - MobileNetworkUtils.launchMobileNetworkSettings(mContext, subInfo)); } + mSubsGearPref.setOnGearClickListener(p -> + MobileNetworkUtils.launchMobileNetworkSettings(mContext, subInfo)); + if (!(mContext.getSystemService(UserManager.class)).isAdminUser()) { mSubsGearPref.setGearEnabled(false); } diff --git a/src/com/android/settings/widget/SettingsMainSwitchPreference.java b/src/com/android/settings/widget/SettingsMainSwitchPreference.java index 0e17d3f8e90..b7c69017404 100644 --- a/src/com/android/settings/widget/SettingsMainSwitchPreference.java +++ b/src/com/android/settings/widget/SettingsMainSwitchPreference.java @@ -199,9 +199,10 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements * Set the OnBeforeCheckedChangeListener. */ public void setOnBeforeCheckedChangeListener(OnBeforeCheckedChangeListener listener) { - if (mMainSwitchBar == null) { + if (!mBeforeCheckedChangeListeners.contains(listener)) { mBeforeCheckedChangeListeners.add(listener); - } else { + } + if (mMainSwitchBar != null) { mMainSwitchBar.setOnBeforeCheckedChangeListener(listener); } } @@ -210,9 +211,10 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements * Adds a listener for switch changes */ public void addOnSwitchChangeListener(OnMainSwitchChangeListener listener) { - if (mMainSwitchBar == null) { + if (!mSwitchChangeListeners.contains(listener)) { mSwitchChangeListeners.add(listener); - } else { + } + if (mMainSwitchBar != null) { mMainSwitchBar.addOnSwitchChangeListener(listener); } } @@ -221,9 +223,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements * Remove a listener for switch changes */ public void removeOnSwitchChangeListener(OnMainSwitchChangeListener listener) { - if (mMainSwitchBar == null) { - mSwitchChangeListeners.remove(listener); - } else { + mSwitchChangeListeners.remove(listener); + if (mMainSwitchBar != null) { mMainSwitchBar.removeOnSwitchChangeListener(listener); } } diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingFragmentBaseControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/TextReadingFragmentBaseControllerTest.java new file mode 100644 index 00000000000..ad6a895498a --- /dev/null +++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingFragmentBaseControllerTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EXTRA_LAUNCHED_FROM; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.ACCESSIBILITY_SETTINGS; +import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.UNKNOWN_ENTRY; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; + +import androidx.preference.Preference; +import androidx.test.core.app.ApplicationProvider; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; + +/** + * Tests for {@link TextReadingFragmentBaseController}. + */ +@RunWith(RobolectricTestRunner.class) +public class TextReadingFragmentBaseControllerTest { + private static final String FRAGMENT_PREF_KEY = "FRAGMENT_PREF_KEY"; + private final Context mContext = ApplicationProvider.getApplicationContext(); + + @Test + public void handlePreferenceClick_getExtraWithA11ySettingsEntryPoint() { + final Preference a11ySettingsPreference = new Preference(mContext); + a11ySettingsPreference.setKey(FRAGMENT_PREF_KEY); + final TextReadingFragmentBaseController mA11ySettingsFragmentController = + new TextReadingFragmentBaseController(mContext, FRAGMENT_PREF_KEY, + ACCESSIBILITY_SETTINGS); + + mA11ySettingsFragmentController.handlePreferenceTreeClick(a11ySettingsPreference); + + assertThat(a11ySettingsPreference.getExtras().getInt(EXTRA_LAUNCHED_FROM, + UNKNOWN_ENTRY)).isEqualTo(ACCESSIBILITY_SETTINGS); + } +} diff --git a/tests/unit/src/com/android/settings/nearby/FastPairPreferenceControllerTest.java b/tests/unit/src/com/android/settings/nearby/FastPairPreferenceControllerTest.java deleted file mode 100644 index f06be4b2288..00000000000 --- a/tests/unit/src/com/android/settings/nearby/FastPairPreferenceControllerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.nearby; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.spy; - -import android.content.Context; -import android.os.Looper; - -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -public class FastPairPreferenceControllerTest { - - private Context mContext; - private FastPairPreferenceController mController; - - @Before - public void setUp() { - mContext = spy(ApplicationProvider.getApplicationContext()); - mController = new FastPairPreferenceController(mContext); - if (Looper.myLooper() == null) { - Looper.prepare(); - } - } - - @Test - public void isAvailable_shouldBeTrue() { - assertThat(mController.isAvailable()).isTrue(); - } -} diff --git a/tests/unit/src/com/android/settings/nearby/FastPairSettingsFragmentTest.java b/tests/unit/src/com/android/settings/nearby/FastPairSettingsFragmentTest.java deleted file mode 100644 index faabe8fd9fe..00000000000 --- a/tests/unit/src/com/android/settings/nearby/FastPairSettingsFragmentTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.nearby; - -import static com.google.common.truth.Truth.assertThat; - -import android.app.Instrumentation; -import android.app.settings.SettingsEnums; - -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -public class FastPairSettingsFragmentTest { - - private FastPairSettingsFragment mFragment; - - @Before - public void setUp() { - final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); - instrumentation.runOnMainSync(() -> mFragment = new FastPairSettingsFragment()); - } - - @Test - public void getCategoryKey_isNetwork() { - assertThat(mFragment.getMetricsCategory()) - .isEqualTo(SettingsEnums.CONNECTION_DEVICE_ADVANCED_FAST_PAIR); - } -}