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

Commit 219bbafc authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Revert "Do not call into ActivityManager from DPMS within DPMS lock"

Bug 25567963

This reverts commit 53de36f9.

Change-Id: I4faaa0b4c50d75e208f37b99bc1d6e2f0fff8127
parent 53de36f9
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -2607,6 +2607,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case UPDATE_DEVICE_OWNER_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String packageName = data.readString();
            updateDeviceOwner(packageName);
            reply.writeNoException();
            return true;
        }

        case GET_PACKAGE_PROCESS_STATE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String pkg = data.readString();
@@ -6145,6 +6153,18 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    @Override
    public void updateDeviceOwner(String packageName) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeString(packageName);
        mRemote.transact(UPDATE_DEVICE_OWNER_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public int getPackageProcessState(String packageName, String callingPackage)
            throws RemoteException {
+2 −0
Original line number Diff line number Diff line
@@ -518,6 +518,7 @@ public interface IActivityManager extends IInterface {
    public void setVoiceKeepAwake(IVoiceInteractionSession session, boolean keepAwake)
            throws RemoteException;
    public void updateLockTaskPackages(int userId, String[] packages) throws RemoteException;
    public void updateDeviceOwner(String packageName) throws RemoteException;

    public int getPackageProcessState(String packageName, String callingPackage)
            throws RemoteException;
@@ -880,6 +881,7 @@ public interface IActivityManager extends IInterface {
    int NOTE_ALARM_FINISH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+292;
    int GET_PACKAGE_PROCESS_STATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+293;
    int SHOW_LOCK_TASK_ESCAPE_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+294;
    int UPDATE_DEVICE_OWNER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+295;
    int KEYGUARD_GOING_AWAY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+296;
    int REGISTER_UID_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+297;
    int UNREGISTER_UID_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+298;
+2 −2
Original line number Diff line number Diff line
@@ -569,7 +569,7 @@ public class DevicePolicyManager {
     * extra field. This will invoke a UI to bring the user through adding the profile owner admin
     * to remotely control restrictions on the user.
     *
     * <p>The intent must be invoked via {@link Activity#startActivityForResult} to receive the
     * <p>The intent must be invoked via {@link Activity#startActivityForResult()} to receive the
     * result of whether or not the user approved the action. If approved, the result will
     * be {@link Activity#RESULT_OK} and the component will be set as an active admin as well
     * as a profile owner.
@@ -2970,7 +2970,7 @@ public class DevicePolicyManager {

    /**
     * @hide
     * @param userId The user for whom to fetch the profile owner name, if any.
     * @param user The user for whom to fetch the profile owner name, if any.
     * @return the human readable name of the organisation associated with this profile owner or
     *         null if one is not set.
     * @throws IllegalArgumentException if the userId is invalid.
+0 −6
Original line number Diff line number Diff line
@@ -80,10 +80,4 @@ public abstract class DevicePolicyManagerInternal {
     * This method always returns a new {@link Bundle}.
     */
    public abstract Bundle getComposedUserRestrictions(int userId, Bundle inBundle);

    /**
     * @return true if a package is a device admin (possibly DO or PO) running on
     * user {@code userId}.
     */
    public abstract boolean isDeviceAdminPackage(int userId, String packageName);
}
+18 −8
Original line number Diff line number Diff line
@@ -55,8 +55,6 @@ import android.app.IActivityContainerCallback;
import android.app.IAppTask;
import android.app.ITaskStackListener;
import android.app.ProfilerInfo;
import android.app.admin.DevicePolicyManagerInternal;
import android.app.admin.IDevicePolicyManager;
import android.app.assist.AssistContent;
import android.app.assist.AssistStructure;
import android.app.usage.UsageEvents;
@@ -502,6 +500,11 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    SparseArray<String[]> mLockTaskPackages = new SparseArray<>();
    /**
     * The package name of the DeviceOwner. This package is not permitted to have its data cleared.
     */
    String mDeviceOwnerName;
    final UserController mUserController;
    public class PendingAssistExtras extends Binder implements Runnable {
@@ -5132,12 +5135,8 @@ public final class ActivityManagerService extends ActivityManagerNative
    public boolean clearApplicationUserData(final String packageName,
            final IPackageDataObserver observer, int userId) {
        enforceNotIsolatedCaller("clearApplicationUserData");
        final DevicePolicyManagerInternal dpmi =
                LocalServices.getService(DevicePolicyManagerInternal.class);
        if (dpmi != null && dpmi.isDeviceAdminPackage(userId, packageName)) {
            throw new SecurityException(
                    "Clearing DeviceAdmin/DeviceOwner/ProfileOwner data is forbidden.");
        if (packageName != null && packageName.equals(mDeviceOwnerName)) {
            throw new SecurityException("Clearing DeviceOwner data is forbidden.");
        }
        int uid = Binder.getCallingUid();
        int pid = Binder.getCallingPid();
@@ -9216,6 +9215,17 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public void updateDeviceOwner(String packageName) {
        final int callingUid = Binder.getCallingUid();
        if (callingUid != 0 && callingUid != Process.SYSTEM_UID) {
            throw new SecurityException("updateDeviceOwner called from non-system process");
        }
        synchronized (this) {
            mDeviceOwnerName = packageName;
        }
    }
    @Override
    public void updateLockTaskPackages(int userId, String[] packages) {
        final int callingUid = Binder.getCallingUid();
Loading