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

Commit 31d06ba6 authored by Hai Zhang's avatar Hai Zhang
Browse files

Add listeners to observe role holders changes.

This change adds the ability to add listeners to observe role holder
changes. This will be used by the new role management UI and other
system components that used to put the default app in settings and
observe settings change.

Bug: 110557011
Test: manual
Change-Id: I2a8eb39220081e3be801adb970b60c55ebc297c7
parent 833960a4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ java_defaults {
        "core/java/android/app/backup/IRestoreObserver.aidl",
        "core/java/android/app/backup/IRestoreSession.aidl",
        "core/java/android/app/backup/ISelectBackupTransportCallback.aidl",
        "core/java/android/app/role/IOnRoleHoldersChangedListener.aidl",
        "core/java/android/app/role/IRoleManager.aidl",
        "core/java/android/app/role/IRoleManagerCallback.aidl",
        "core/java/android/app/slice/ISliceManager.aidl",
+7 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ package android {
    field public static final java.lang.String NOTIFICATION_DURING_SETUP = "android.permission.NOTIFICATION_DURING_SETUP";
    field public static final java.lang.String NOTIFY_TV_INPUTS = "android.permission.NOTIFY_TV_INPUTS";
    field public static final java.lang.String OBSERVE_APP_USAGE = "android.permission.OBSERVE_APP_USAGE";
    field public static final java.lang.String OBSERVE_ROLE_HOLDERS = "android.permission.OBSERVE_ROLE_HOLDERS";
    field public static final java.lang.String OVERRIDE_WIFI_CONFIG = "android.permission.OVERRIDE_WIFI_CONFIG";
    field public static final java.lang.String PACKAGE_USAGE_STATS = "android.permission.PACKAGE_USAGE_STATS";
    field public static final java.lang.String PACKAGE_VERIFICATION_AGENT = "android.permission.PACKAGE_VERIFICATION_AGENT";
@@ -884,12 +885,18 @@ package android.app.job {

package android.app.role {

  public abstract interface OnRoleHoldersChangedListener {
    method public abstract void onRoleHoldersChanged(java.lang.String, android.os.UserHandle);
  }

  public final class RoleManager {
    method public void addOnRoleHoldersChangedListenerAsUser(java.util.concurrent.Executor, android.app.role.OnRoleHoldersChangedListener, android.os.UserHandle);
    method public void addRoleHolderAsUser(java.lang.String, java.lang.String, android.os.UserHandle, java.util.concurrent.Executor, android.app.role.RoleManagerCallback);
    method public boolean addRoleHolderFromController(java.lang.String, java.lang.String);
    method public void clearRoleHoldersAsUser(java.lang.String, android.os.UserHandle, java.util.concurrent.Executor, android.app.role.RoleManagerCallback);
    method public java.util.List<java.lang.String> getRoleHolders(java.lang.String);
    method public java.util.List<java.lang.String> getRoleHoldersAsUser(java.lang.String, android.os.UserHandle);
    method public void removeOnRoleHoldersChangedListenerAsUser(android.app.role.OnRoleHoldersChangedListener, android.os.UserHandle);
    method public void removeRoleHolderAsUser(java.lang.String, java.lang.String, android.os.UserHandle, java.util.concurrent.Executor, android.app.role.RoleManagerCallback);
    method public boolean removeRoleHolderFromController(java.lang.String, java.lang.String);
    method public void setRoleNamesFromController(java.util.List<java.lang.String>);
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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 android.app.role;

/**
 * @hide
 */
oneway interface IOnRoleHoldersChangedListener {

    void onRoleHoldersChanged(String roleName, int userId);
}
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app.role;

import android.app.role.IOnRoleHoldersChangedListener;
import android.app.role.IRoleManagerCallback;

/**
@@ -37,6 +38,11 @@ interface IRoleManager {

    void clearRoleHoldersAsUser(in String roleName, int userId, in IRoleManagerCallback callback);

    void addOnRoleHoldersChangedListenerAsUser(IOnRoleHoldersChangedListener listener, int userId);

    void removeOnRoleHoldersChangedListenerAsUser(IOnRoleHoldersChangedListener listener,
            int userId);

    void setRoleNamesFromController(in List<String> roleNames);

    boolean addRoleHolderFromController(in String roleName, in String packageName);
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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 android.app.role;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.UserHandle;

/**
 * Listener for role holder changes.
 *
 * @hide
 */
@SystemApi
public interface OnRoleHoldersChangedListener {

    /**
     * Called when the holders of roles are changed.
     *
     * @param roleName the name of the role whose holders are changed
     * @param user the user for this role holder change
     */
    void onRoleHoldersChanged(@NonNull String roleName, @NonNull UserHandle user);
}
Loading