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

Commit 04458859 authored by Alex Chau's avatar Alex Chau
Browse files

Introduce logout button and DevicePolicyManager API to enable it

Bug: 67843538
Test: Manual test with CloudDpc that logout button can be controlled by DevicePolicyManager API and only enabled in shared userse
Test: Logout button can actually exit the user and ActivityManager log shows that user is stopped
Test: CTS is tracked in b/67843605
Change-Id: I9f27050654958ce55f574dd05ff80609255ffeb4
parent 5826e469
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6388,6 +6388,7 @@ package android.app.admin {
    method public deprecated boolean isCallerApplicationRestrictionsManagingPackage();
    method public boolean isDeviceOwnerApp(java.lang.String);
    method public boolean isLockTaskPermitted(java.lang.String);
    method public boolean isLogoutButtonEnabled();
    method public boolean isManagedProfile(android.content.ComponentName);
    method public boolean isMasterVolumeMuted(android.content.ComponentName);
    method public boolean isNetworkLoggingEnabled(android.content.ComponentName);
@@ -6430,6 +6431,7 @@ package android.app.admin {
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
    method public void setLockTaskFeatures(android.content.ComponentName, int);
    method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
    method public void setLogoutButtonEnabled(android.content.ComponentName, boolean);
    method public void setLongSupportMessage(android.content.ComponentName, java.lang.CharSequence);
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
+32 −0
Original line number Diff line number Diff line
@@ -8443,6 +8443,38 @@ public class DevicePolicyManager {
        }
    }

    /**
     * Called by a device owner to specify whether a logout button is enabled for all secondary
     * users. The system may show a logout button that stops the user and switches back to the
     * primary user.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param enabled whether logout button should be enabled or not.
     * @throws SecurityException if {@code admin} is not a device owner.
     */
    public void setLogoutButtonEnabled(@NonNull ComponentName admin, boolean enabled) {
        throwIfParentInstance("setLogoutButtonEnabled");
        try {
            mService.setLogoutButtonEnabled(admin, enabled);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Returns whether logout button is enabled by a device owner.
     *
     * @return {@code true} if logout button is enabled by device owner, {@code false} otherwise.
     */
    public boolean isLogoutButtonEnabled() {
        throwIfParentInstance("isLogoutButtonEnabled");
        try {
            return mService.isLogoutButtonEnabled();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Callback used in {@link #clearApplicationUserData}
     * to indicate that the clearing of an application's user data is done.
+3 −0
Original line number Diff line number Diff line
@@ -365,4 +365,7 @@ interface IDevicePolicyManager {
    StringParceledListSlice getOwnerInstalledCaCerts(in UserHandle user);

    boolean clearApplicationUserData(in ComponentName admin, in String packageName, in IPackageDataObserver callback);

    void setLogoutButtonEnabled(in ComponentName admin, boolean enabled);
    boolean isLogoutButtonEnabled();
}
+15 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <group>
        <clip-path android:pathData="M0,0h24v24H0V0z M 0,0" />
    <path
        android:fillColor="#FF000000"
        android:pathData="M17.0,7.0l-1.4099998,1.4099998l2.58,2.5900002l-10.17,0.0l0.0,2.0l10.17,0.0l-2.58,2.58l1.4099998,1.4200001l5.0,-5.0z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M4,5h8V3H4C2.9,3,2,3.9,2,5v14c0,1.1,0.9,2,2,2h8v-2H4V5z"/>
    </group>
</vector>
+2 −0
Original line number Diff line number Diff line
@@ -2441,10 +2441,12 @@
         "users" = list of users
         "restart" = restart device
         "lockdown" = Lock down device until the user authenticates
         "logout" =  Logout the current user
         -->
    <string-array translatable="false" name="config_globalActionsList">
        <item>power</item>
        <item>restart</item>
        <item>logout</item>
        <item>bugreport</item>
        <item>users</item>
        <item>lockdown</item>
Loading