Commit Graph

36 Commits

Author SHA1 Message Date
Kweku Adams
2d2db1f711 Use updated flag.
Link to the main TARE flag and default value instead of the Settings
default.

Bug: 158300259
Test: atest CtsAlarmManagerTestCases
Test: atest CtsBatterySavingTestCases
Test: atest CtsJobSchedulerTestCases
Test: atest SettingsBackupTest
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/alarm
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/tare
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/tare
Test: Interact with UI and check settings via adb
Change-Id: I6afd0bdf56f39758076b6182fc4893a37760428b
2023-02-02 17:38:13 +00:00
Kweku Adams
f6f9a4b7b2 Allow modifying minimum consumption limit.
Create separate fields for minimum and initial consumption limits so
that they can be modified independently.

Bug: 255321890
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/tare
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/tare
Test: manually change in Developer Options UI
Change-Id: I82c146a18b54a18313de590038f2f807a2310aa0
2022-10-31 14:20:58 +00:00
Kweku Adams
f55726842a Allow updating app updater balance increments.
Bug: 243987091
Test: modify values in UI and confirm settings values changed via adb
Change-Id: I054246cada5200c1ae663ac42117a3f0ba958b61
2022-09-27 18:20:05 +00:00
Kweku Adams
fbded716fd Allow updating app install reward values.
Bug: 243987091
Test: modify values in UI and confirm settings values changed via adb
Change-Id: I4d2a4409883ec06b93f4fa55e3a46829e06fe68e
2022-09-14 19:58:00 +00:00
Kweku Adams
cda2d13a3c Properly reflect the default value.
The switch should be on if the default state is on. Also, make sure the
revert button is accessible if the default value is on.

Bug: 240726265
Test: Toggle the switch and then Revert to Defaults with the default value as on
Change-Id: I07d1713316281b0590fab7f1581e15d9f5e57969
2022-08-17 17:34:30 +00:00
Kweku Adams
d7189cc7ce 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
2022-04-27 17:57:01 +00:00
Kweku Adams
058796b7eb Update enable toggle processing.
1. Use a ContentObserver so the UI is always up-to-date.
2. Don't write a value when it would effectively be putting the default
   value and the current value is null. This allows us to have a "use
   default" option so that DeviceConfig can take over if a user ever
   resets to default settings.

Bug: 158300259
Bug: 189850067
Bug: 205624100
Test: manually toggle and look at logcat for expected values
Change-Id: I429977d37cd8afc2ce12b89cbac002503484ad7e
2022-03-23 16:43:39 +00:00
Kweku Adams
10ef599170 Make reward constants configurable.
Make it possible to configure the instant and max values of all
supported actions. Ongoing rewards will be enabled later.

Bug: 158300259
Bug: 189850067
Bug: 191876714
Bug: 191877052
Test: Manual
Change-Id: Ia854f18820f3fe95b3b1448c5fa8411853859052
2022-03-22 17:37:07 +00:00
Kweku Adams
6525ff3d79 Make action constants configurable.
Make it possible to configure the base price and cost to produce of all
supported actions.

Bug: 158300259
Bug: 189850067
Bug: 191876714
Bug: 191877052
Test: Manual
Change-Id: I2dcd3382f7404655fb0d10538a426071c157ea18
2022-03-18 18:54:00 +00:00
TreeHugger Robot
2164070f4a Merge "Update TARE UI." into tm-dev 2022-02-24 01:27:56 +00:00
TreeHugger Robot
42156e7ba9 Merge "Reset all TARE constants." into tm-dev 2022-02-23 21:34:34 +00:00
Kweku Adams
2d12b846d4 Update TARE UI.
1. Connect the UI and controller components so that users can make
   changes and the changes will be written to settings and properly read
   back.
2. Update string constants to reflect changes from TIP1.
3. Refactor components slightly to reduce duplicate code.
4. Hide unsupported factors for now. They'll be added back later.

Bug: 158300259
Test: Manually change factors and check settings constant via adb
Change-Id: I2b70e7013c4766ea50f1f013da582eca74015c6b
2022-02-23 21:20:25 +00:00
TreeHugger Robot
78d917cc14 Merge "Clean up code." into tm-dev 2022-02-23 19:16:39 +00:00
Kweku Adams
bc3304b6a2 Clean up code.
1. Create a method for duplicate code.
2. Address style/lint issues.
3. Properly parse settings constant string. The original iteration
   wouldn't reset values to their default if the constant string didn't
   have a value set.

Bug: 158300259
Test: manual
Change-Id: I994b872ba16f12c8e06ce85aedc526b84e5fa31b
2022-02-23 16:30:08 +00:00
Kweku Adams
ba685c0be0 Switch from androidx to android.
The rest of the TARE classes use pure Android Fragments and will have an
issue trying to create an androidx Fragment, so switch from using an
androidx Fragment to an android Fragment.

Bug: 158300259
Test: manual
Change-Id: I4c27198a66bd51b3822421116b46ae3d80d589ff
2022-02-23 16:04:45 +00:00
Kweku Adams
a6693df48d Reset all TARE constants.
Reset all TARE constants, not just the enabled status, when a user
clicks on "Reset to defaults."

Bug: 158300259
Test: manual
Change-Id: I5328c7790729e3358751e703271a6ffd386bb33f
2022-02-23 16:03:10 +00:00
Kweku Adams
82b0e1ccdb Simplifying settings string generation.
Remove duplicate code for generating the settings constant strings, and
make sure not to write redundant data (setting a value to its default).

Bug: 158300259
Test: Android builds
Change-Id: Id79bae3685bfecb4858574ee38b67b2a554823fe
2022-02-22 18:52:35 +00:00
Kweku Adams
2a51b8bfe0 Update constant names.
Updating references based on changes for TIP1. This change is just to
keep things building properly. Updates to the UI and functionality will
be done separately.

Bug: 158300259
Test: Android builds
Change-Id: I3a50c028fe69a6180ae842d3117b5cdfd712e0fd
(cherry picked from commit b05665fa83)
2022-02-18 21:55:13 +00:00
Edgar Wang
fa5ab2e268 Replace SettingsSpinner with Spinner
Bug: 219610512
Test: manual
Change-Id: Ib8562a64299a6cb36f8225199f9432cb81e8e9f2
2022-02-17 02:16:27 +08:00
Joshua Lewis
d16c016142 Merge "Add JobScheduler support in factor controller" 2021-08-14 01:04:34 +00:00
Joshua
76ca8923ab Add JobScheduler support in factor controller
Initializes the JobScheduler constants string in Global Settings and
takes it through the parsing of creating a map with the key:value pairs
linked to the JobScheduler policy. Also changes the way the getter
methods work to take a factor policy so we can know what policy to
change.

Bug: 195056296
Bug: 195056102
Bug: 195055895

Test: Manual
Change-Id: Id82101b2a045dd14bb8eacfbe51c363b4bafb1ce
2021-08-13 23:44:59 +00:00
Joshua Lewis
a162022d31 Merge "Update AlarmManager Global Settings String" 2021-08-13 22:00:30 +00:00
Joshua
347f58ad6e Update AlarmManager Global Settings String
Implements methods that update the AlarmManager Global Settings String
when the user confirms a value in the Dialog. updateAlarmManagerValue
takes the key of the factor being edited and the edited value enterd by
the user in the dialog assigning it as the current value of the key.
This a new string is then rebuilt with the updated values and assigned
to be the new Settings Global String.

Bug: 195056102
Bug: 195055895

Test: Manual
Change-Id: I5776822c665bdfa052f23099d367ba8cf29743df
2021-08-13 19:16:20 +00:00
Joshua Lewis
385d36ac2d Merge "Parse AM Constants to get keys:value for Dialog" 2021-08-13 16:46:31 +00:00
Joshua
7b2293ef9a Parse AM Constants to get keys:value for Dialog
Takes the AlarmManager csv string and parsees it for key:value
pairs. These key value pairs are then used to fill in information that
the DialogFragment class needs to display information. An ArrayMap is
used to initialize and store a key and the values associated with it
through a data object class. This data can be retrived in updated by
providing only a key.

Bug: 195056296
Bug: 195056102
Bug: 195055428

Test: Manual
Change-Id: Ia11f41bdd1790f7f3483d33148c251c58243e890
2021-08-13 00:12:24 +00:00
TreeHugger Robot
1d441b72c5 Merge "Update UI when TARE settings revert to default" 2021-08-12 22:52:55 +00:00
Joshua Lewis
144f222afb Merge "Create Dialog to edit TARE factors" 2021-08-11 16:54:45 +00:00
Joshua
5ebb245618 Create Dialog to edit TARE factors
This CL is the base framework for creating and adjusting TARE factor
values. TareFactorDialogFragment sets the basic outline for a factor
that uses a DialogBox to adjust the value. It takes the "title" or name
of the factor, the key that will be associated with the factor, and an
initial value for the factor; then sets up everything so that the factor
value can be easily changed and stored. These factors are also
registered into the settings observer class.

Bug: 195055619
Bug: 193238774

Test: Manual (Made a temporary class instance of the DialogFragment and
showed it in inactive apps onResume())

Change-Id: I3bb67717175e70eab3bbb11f4a42ee63a42f60bc
2021-08-09 19:45:25 +00:00
alinasuarez
9dc7f45725 Update UI when TARE settings revert to default
When the TARE revert to default button is clicked, the TARE homepage
updates to the value of the DEFAULT_ENABLE_TARE global variable with this code.

Bug: 195543827

Test: Manual (Settings -> developer options -> TARE -> click revert to
default settings and see the page disabled)

Change-Id: Ia4d126d97ebfb35fbf831bb29cee302acad92e7c
2021-08-06 15:44:41 +00:00
alinasuarez
1031bb2693 TARE Global Toggle
Add functionality to the global toggle within the TARE homepage in the
developer settings. This allows for users and developers to turn these
settings on/off.

Bug: 195552339

Test: Manual (open Settings > System > Developer Options > TARE > turn
on/off the global toggle and leave and go back and make sure it is being
kept track of correctly)

Change-Id: Ifb8dee1aeb04d2b6883ee9e449ed8ab0493dc27a
2021-08-05 15:33:52 +00:00
alinasuarez
e2d2f44888 Revert to Default Settings
Add functionality to the revert default settings button. This currently
writes a null value to the ENABLE_TARE constant. In the future this will
also make the AlarmManager and JobScheduler constants null so that the
default values are used instead of custom config values.

Bug: 195543827

Test: Click on revert to default settings button, check that the value
for ENABLE_TARE is null by running "adb shell settings get global
enable_tare" in the command line

Change-Id: I558e8f1121021eca3224e4bc9b26bbe0dd2467c7
2021-08-04 20:39:09 +00:00
alinasuarez
8073d4eb92 Job Scheduler TARE page implementation
A Job Scheduler policy page is needed in the TARE developer options
settings to allow developers to both view and edit the current values of
all the factors under the job scheduler policy. The page uses a dropdown
so that the user can easily switch between the different policies. For
the factors with subfactors, the user simply clicks on the factor and
the subfactors wil pop up under it.

Bug: 191877052

Test: Manual (open Settings > System > Developer Options > TARE >
JobScheduler and verify all factors are there)

Change-Id: Icea6cda5e4b59d1736f85defcb9532839c3720f5
2021-08-03 02:26:19 +00:00
alinasuarez
aef6ac2889 Alarm Manager policy TARE page implementation
An alarm manager policy page is needed in the TARE developer option
settings to allow developers to both view and edit the current values of
all the factors under the alarm manager policy. The page uses a dropdown
so that the user can easily switch between the different policies. For
the factors with subfactors, the user simply clicks on the factor and
the subfactors will pop up under it.

Bug: 191876714
Bug: 191876567

Test: Manual (open Settings > System > Developer Options > TARE > Alarm
Manger and verify all factors are there)

Change-Id: Ie036e26df80947d23041bedfd5b1385e48069b6b
2021-08-02 17:39:36 +00:00
alinasuarez
1a075e874f TARE string clarification
Clarify the strings used for the TARE homepage. Update
comments so that the translators understand that TARE is not
translatable and that AlarmManager and JobScheduler are Android system
services.

Bug: 191876567

Test: Manual (open Settings > System > Developer Options > TARE and
verify tabs and menus are there)

Change-Id: I935cd0ab9e8e6e5591875a1e7f8ed9f58d8abd9c
2021-07-28 20:17:41 +00:00
alinasuarez
6ffa9dad04 Add TARE button and homepage to developer options.
A TARE button is needed in the developer options in settings to allow
users and developers to change the default settings it will come with.
When clicked, it opens an activity of the TARE homepage with a toggle
and the two policies (Alarm Manager and Job Scheduler) to choose between. It also contains a revert to default settings button.

Bug: 191876567

Test: Manual (open Settings > System > Developer Options > TARE and
verify tabs and menus are there)

Change-Id: Id14bc9c1dcbaaf2aeb74ba7efb0168ab424f5d0c
2021-07-22 20:52:06 +00:00
Kweku Adams
1e7914460a Add OWNERS file for TARE.
Bug: 189850067
Test: N/A
Change-Id: I786da04d0806c045977a7517fe6a65f162a22543
2021-06-03 16:33:17 -07:00