From 04e7bdef048c1fe330825a0977ce0cbe7897b367 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Thu, 13 Feb 2020 13:02:33 -0500 Subject: [PATCH] Add dialog for recommended controls The dialog can only be requested if the package of the controls provider is currently in the foreground. This is accomplished by querying Activity Manager about the UidImportance of that package. Added android.permission.PACKAGE_USAGE_STATS to SystemUI for this. Test: atest Test: manual Fixes: 149410221 Change-Id: Ifdf479d8dbc70502da95d362e3bfd60ad3c561fb --- data/etc/com.android.systemui.xml | 1 + packages/SystemUI/AndroidManifest.xml | 21 ++ .../SystemUI/res/layout/controls_dialog.xml | 34 ++++ packages/SystemUI/res/values/dimens.xml | 4 + packages/SystemUI/res/values/strings.xml | 7 + packages/SystemUI/res/values/styles.xml | 3 + .../controls/controller/ControlsController.kt | 12 ++ .../controller/ControlsControllerImpl.kt | 35 +++- .../controls/dagger/ControlsModule.kt | 8 + .../controls/management/ControlAdapter.kt | 5 +- .../management/ControlsFavoritingActivity.kt | 3 +- .../management/ControlsRequestDialog.kt | 179 ++++++++++++++++++ .../management/ControlsRequestReceiver.kt | 78 ++++++++ .../management/ControlsRequestReceiverTest.kt | 161 ++++++++++++++++ 14 files changed, 546 insertions(+), 5 deletions(-) create mode 100644 packages/SystemUI/res/layout/controls_dialog.xml create mode 100644 packages/SystemUI/src/com/android/systemui/controls/management/ControlsRequestDialog.kt create mode 100644 packages/SystemUI/src/com/android/systemui/controls/management/ControlsRequestReceiver.kt create mode 100644 packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsRequestReceiverTest.kt diff --git a/data/etc/com.android.systemui.xml b/data/etc/com.android.systemui.xml index 5d2e303b921eb..38e18a9419058 100644 --- a/data/etc/com.android.systemui.xml +++ b/data/etc/com.android.systemui.xml @@ -39,6 +39,7 @@ + diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 617ed4e58e774..30b461d1fe45f 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -180,6 +180,8 @@ + + @@ -686,6 +688,25 @@ android:visibleToInstantApps="true"> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 2dc0f5ff202c0..7aaf6f9a778ac 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1249,6 +1249,10 @@ 32dp 2dp + 15 + + 8dp + 200dp 18dp diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index bcf3a262697b6..5b28479ab5caf 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -2639,4 +2639,11 @@ The list of all controls could not be loaded. Other + + + Add to Quick Controls + + Add to favorites + + %s suggested this control to add to your favorites. diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 2eccf586b455c..125dd8f1d60cd 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -697,4 +697,7 @@ @color/control_list_popup_background + +