Snap for 8513644 from cb72c82a18 to tm-qpr1-release
Change-Id: Iaacda89be6047e931703a7e8a88ac2120e571687
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.65,19.27c-0.35,0-0.69-0.13-0.96-0.4l-8.66-8.66c-0.53-0.53-0.53-1.38,0-1.91 c0.53-0.53,1.38-0.53,1.91,0l8.66,8.66c0.53,0.53,0.53,1.38,0,1.91C21.34,19.14,20.99,19.27,20.65,19.27z" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12.01,16.09c-0.35,0-0.69-0.13-0.96-0.4L2.4,7.04c-0.53-0.53-0.53-1.38,0-1.91s1.38-0.53,1.91,0l8.66,8.66 c0.53,0.53,0.53,1.38,0,1.91C12.7,15.96,12.36,16.09,12.01,16.09z" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M6.32,19.06c0-0.34,0.13-0.69,0.4-0.95l1.85-1.85c0.53-0.53,1.38-0.53,1.91,0c0.53,0.53,0.53,1.38,0,1.91 l-1.85,1.85c-0.53,0.53-1.38,0.53-1.91,0C6.45,19.75,6.32,19.4,6.32,19.06z" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M13.13,6.79c0-0.34,0.13-0.69,0.4-0.95l1.85-1.85c0.53-0.53,1.38-0.53,1.91,0c0.53,0.53,0.53,1.38,0,1.91 l-1.85,1.85c-0.53,0.53-1.38,0.53-1.91,0C13.27,7.48,13.13,7.13,13.13,6.79z" />
|
||||
</vector>
|
||||
42
res/layout/dialog_edittext_dropdown.xml
Normal file
42
res/layout/dialog_edittext_dropdown.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edittext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:inputType="textCapSentences"
|
||||
android:minHeight="@dimen/min_tap_target_size"
|
||||
android:maxLength="50"
|
||||
android:singleLine="true" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/min_tap_target_size" />
|
||||
</LinearLayout>
|
||||
@@ -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" />
|
||||
<TextView
|
||||
android:id="@+id/alarmmanager"
|
||||
|
||||
@@ -5978,19 +5978,6 @@
|
||||
<!-- List of synonyms used in the settings search bar to find the “Voice Access”. [CHAR LIMIT=NONE] -->
|
||||
<string name="keywords_voice_access"></string>
|
||||
|
||||
<!-- Fast Pair settings -->
|
||||
<skip />
|
||||
|
||||
<!-- Title in main settings screen for Fast Pair settings [CHAR LIMIT=15] -->
|
||||
<string name="fast_pair_settings">Fast Pair</string>
|
||||
|
||||
<!-- Fast Pair setting summary in settings screen [CHAR LIMIT=50] -->
|
||||
<string name="fast_pair_settings_summary">Nearby detection of Fast Pair bluetooth devices.</string>
|
||||
<!-- Title for Fast Pair main switch preferences. [CHAR LIMIT=50] -->
|
||||
<string name="fast_pair_main_switch_title">Scan for nearby devices</string>
|
||||
<!-- Title for Fast Pair saved devices preferences. [CHAR LIMIT=50] -->
|
||||
<string name="fast_pair_saved_devices_title">Saved devices</string>
|
||||
<!-- Printing settings -->
|
||||
<skip />
|
||||
|
||||
<!-- Title in main settings screen for printing settings [CHAR LIMIT=15] -->
|
||||
@@ -8434,9 +8421,6 @@
|
||||
<!-- List of synonyms for the Bluetooth setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
||||
<string name="keywords_bluetooth_settings">connected, device, headphones, headset, speaker, wireless, pair, earbuds, music, media </string>
|
||||
|
||||
<!-- List of synonyms for the Fast Pair setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
||||
<string name="keywords_fast_pair">pair, earbuds, bluetooth</string>
|
||||
|
||||
<!-- List of synonyms for the Wallpaper picker setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
||||
<string name="keywords_wallpaper">background, theme, grid, customize, personalize</string>
|
||||
|
||||
@@ -13870,6 +13854,10 @@
|
||||
<!-- TARE settings title in developer options; "TARE" is the name of the feature and cannot be
|
||||
translated. [CHAR LIMIT=40] -->
|
||||
<string name="tare_settings">TARE Settings</string>
|
||||
<!-- Summary for the TARE feature being on (ie. enabled) [CHAR LIMIT=NONE] -->
|
||||
<string name="tare_on">On</string>
|
||||
<!-- Summary for the TARE feature being off (ie. disabled) [CHAR LIMIT=NONE] -->
|
||||
<string name="tare_off">Off</string>
|
||||
<!-- Allows user to revert the TARE settings to their default values [CHAR LIMIT=40] -->
|
||||
<string name="tare_revert">Revert to Default Settings</string>
|
||||
<!-- Allows user to view AlarmManager policy factors. Alarm in this context is referring to the
|
||||
@@ -13920,7 +13908,7 @@
|
||||
<string name="tare_rewards_instantaneous">Rewards per single event</string>
|
||||
<!-- Title for the rewards apps can obtain for the total duration (in seconds) of an event that
|
||||
implies the user finds the app behavior useful. [CHAR LIMIT=40]-->
|
||||
<string name="tare_rewards_ongoing">Rewards for total event duration</string>
|
||||
<string name="tare_rewards_ongoing">Rewards per second of event duration</string>
|
||||
<!-- Title for the max rewards apps can obtain within a 24 hour period for different actions
|
||||
that benefit the user. [CHAR LIMIT=40]-->
|
||||
<string name="tare_rewards_max">Maximum Rewards Per Day</string>
|
||||
@@ -14087,6 +14075,13 @@
|
||||
</string-array>
|
||||
<!-- TARE dialog button to proceed with a value change [CHAR LIMIT=none] -->
|
||||
<string name="tare_dialog_confirm_button_title">Confirm</string>
|
||||
<!-- Array used to populate dropdown menu to select the units of the factor value. Not
|
||||
translatable since they're base units. [CHAR LIMIT=40]-->
|
||||
<string-array name="tare_units" translatable="false">
|
||||
<item>ARC</item>
|
||||
<item>Cake</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Button to preview the selected screensaver in settings [CHAR LIMIT=40] -->
|
||||
<string name="dream_preview_button_title">Preview</string>
|
||||
<!-- The title of the category to show for the screensaver selector in settings [CHAR LIMIT=none] -->
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.ColorAndMotionFragment"
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
android:key="text_reading_options"
|
||||
android:persistent="false"
|
||||
android:title="@string/accessibility_text_reading_options_title"
|
||||
settings:keywords="text_reading_options" />
|
||||
settings:keywords="text_reading_options"
|
||||
settings:controller="com.android.settings.accessibility.TextReadingFragmentForSuwController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
|
||||
|
||||
@@ -67,15 +67,6 @@
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.uwb.UwbPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="connected_device_fast_pair"
|
||||
android:title="@string/fast_pair_settings"
|
||||
android:summary="@string/fast_pair_settings_summary"
|
||||
android:icon="@drawable/ic_fast_pair_24dp"
|
||||
android:fragment="com.android.settings.nearby.FastPairSettingsFragment"
|
||||
settings:controller="com.android.settings.nearby.FastPairPreferenceController"
|
||||
android:order="-2"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="-8"/>
|
||||
|
||||
@@ -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"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/fast_pair_settings"
|
||||
settings:keywords="@string/keywords_fast_pair">
|
||||
|
||||
<com.android.settingslib.widget.MainSwitchPreference
|
||||
android:key="fast_pair_scan_switch"
|
||||
android:title="@string/fast_pair_main_switch_title" />
|
||||
|
||||
<Preference
|
||||
android:key="saved_devices"
|
||||
android:title="@string/fast_pair_saved_devices_title" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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}.
|
||||
*
|
||||
* <p>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<ResetStateListener> mResetStateListeners;
|
||||
@@ -91,6 +121,8 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
updateEntryPoint();
|
||||
|
||||
final List<AbstractPreferenceController> 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<String> 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.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<String, TareFactorData> 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<String, TareFactorData> 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;
|
||||
|
||||
@@ -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<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user