Make final factors configurable.
1. Add configuration support for the ongoing rewards (that are normally less than 1 ARC). 2. Fix key/configuration of instant rewards 3. Fix UI string issue Bug: 158300259 Bug: 189850067 Bug: 191876714 Bug: 191877052 Test: Use UI to change factors. Check Settings via adb and TARE dumpsys Change-Id: I571e188faa6915ea74826b725c9883a825ab152a
This commit is contained in:
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"
|
||||
|
@@ -13858,6 +13858,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
|
||||
@@ -13908,7 +13912,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>
|
||||
@@ -14075,6 +14079,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] -->
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user