Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04e7bdef authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

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
parent 780782b7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
        <permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
        <permission name="android.permission.OBSERVE_NETWORK_POLICY"/>
        <permission name="android.permission.OVERRIDE_WIFI_CONFIG"/>
        <permission name="android.permission.PACKAGE_USAGE_STATS" />
        <permission name="android.permission.READ_DREAM_STATE"/>
        <permission name="android.permission.READ_FRAME_BUFFER"/>
        <permission name="android.permission.READ_NETWORK_USAGE_HISTORY"/>
+21 −0
Original line number Diff line number Diff line
@@ -180,6 +180,8 @@

    <!-- Adding Controls to SystemUI -->
    <uses-permission android:name="android.permission.BIND_CONTROLS" />
    <!-- Check foreground controls applications -->
    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />

    <!-- Quick Settings tile: Night Mode / Dark Theme -->
    <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE" />
@@ -686,6 +688,25 @@
                  android:visibleToInstantApps="true">
        </activity>

        <receiver android:name=".controls.management.ControlsRequestReceiver">
            <intent-filter>
                <action android:name="android.service.controls.action.ADD_CONTROL" />
            </intent-filter>
        </receiver>

        <!-- started from ControlsFavoritingActivity -->
        <activity
            android:name=".controls.management.ControlsRequestDialog"
            android:exported="true"
            android:theme="@style/Theme.ControlsRequestDialog"
            android:finishOnCloseSystemDialogs="true"
            android:showForAllUsers="true"
            android:clearTaskOnLaunch="true"
            android:launchMode="singleTask"
            android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
            android:excludeFromRecents="true"
            android:visibleToInstantApps="true"/>

        <!-- Doze with notifications, run in main sysui process for every user  -->
        <service
            android:name=".doze.DozeService"
+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2020 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.
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="@dimen/controls_dialog_padding"
    android:layout_margin="@dimen/controls_dialog_padding"
    >

    <include
        android:id="@+id/control"
        layout="@layout/controls_base_item"
        android:layout_width="@dimen/controls_dialog_control_width"
        android:layout_height="@dimen/control_height"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="@dimen/controls_dialog_padding"
        android:layout_marginBottom="@dimen/controls_dialog_padding"
    />
</FrameLayout>
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -1249,6 +1249,10 @@
    <dimen name="controls_app_divider_side_margin">32dp</dimen>

    <dimen name="controls_card_margin">2dp</dimen>
    <item name="control_card_elevation" type="dimen" format="float">15</item>

    <dimen name="controls_dialog_padding">8dp</dimen>
    <dimen name="controls_dialog_control_width">200dp</dimen>

    <!-- Screen Record -->
    <dimen name="screenrecord_dialog_padding">18dp</dimen>
+7 −0
Original line number Diff line number Diff line
@@ -2639,4 +2639,11 @@
    <string name="controls_favorite_load_error">The list of all controls could not be loaded.</string>
    <!-- Controls management controls screen header for Other zone [CHAR LIMIT=60] -->
    <string name="controls_favorite_other_zone_header">Other</string>

    <!-- Controls dialog title [CHAR LIMIT=30] -->
    <string name="controls_dialog_title">Add to Quick Controls</string>
    <!-- Controls dialog add to favorites [CHAR LIMIT=30] -->
    <string name="controls_dialog_ok">Add to favorites</string>
    <!-- Controls dialog message [CHAR LIMIT=NONE] -->
    <string name="controls_dialog_message"><xliff:g id="app" example="System UI">%s</xliff:g> suggested this control to add to your favorites.</string>
</resources>
Loading