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

Commit 7988bd46 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Add multi-user support to Controls

This commit adds multi-user support by doing the following:
* Listening when user changes and switching the controllers user (and
context).
* Using activities that show for all users and are finished on user
switched.

The setting has to be enabled for each user separately.

Also:
* fixes calling subscribe when on load to the ControlsProviderService.
* better dumps.

Test: atest
Test: check that files are not shared between users
Test: check that user folder is removed when user is deleted
Bug:147732882
Change-Id: I349b0136473016e6bd6b71e26045f11a839272d1
parent c5f436ec
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -646,6 +646,7 @@
                  android:label="Controls Providers"
                  android:theme="@style/Theme.SystemUI"
                  android:exported="true"
                  android:showForAllUsers="true"
                  android:excludeFromRecents="true"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
                  android:visibleToInstantApps="true">
@@ -655,6 +656,7 @@
                  android:parentActivityName=".controls.management.ControlsProviderSelectorActivity"
                  android:theme="@style/Theme.SystemUI"
                  android:excludeFromRecents="true"
                  android:showForAllUsers="true"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
                  android:visibleToInstantApps="true">
        </activity>
+5 −1
Original line number Diff line number Diff line
@@ -18,4 +18,8 @@ package com.android.systemui.controls

import android.service.controls.Control

data class ControlStatus(val control: Control, val favorite: Boolean, val removed: Boolean = false)
 No newline at end of file
data class ControlStatus(
    val control: Control,
    val favorite: Boolean,
    val removed: Boolean = false
)
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import com.android.settingslib.applications.DefaultAppInfo

class ControlsServiceInfo(
    context: Context,
    serviceInfo: ServiceInfo
    val serviceInfo: ServiceInfo
) : DefaultAppInfo(
    context,
    context.packageManager,
+25 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.systemui.controls

import android.os.UserHandle

interface UserAwareController {

    fun changeUser(newUser: UserHandle) {}
    val currentUserId: Int
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@ package com.android.systemui.controls.controller
import android.content.ComponentName
import android.service.controls.Control
import android.service.controls.actions.ControlAction
import com.android.systemui.controls.UserAwareController

interface ControlsBindingController {
interface ControlsBindingController : UserAwareController {
    fun bindAndLoad(component: ComponentName, callback: (List<Control>) -> Unit)
    fun bindServices(components: List<ComponentName>)
    fun subscribe(controls: List<ControlInfo>)
Loading