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

Commit 53de36f9 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Do not call into ActivityManager from DPMS within DPMS lock

This will allow AMS to call into DPMS within the AMS lock instead,
which will help  I1537bd57b34696768ee81a979d53bb396efbc12a.

- AM.clearApplicationUserData() will not be allowed for any DA
apps.

Bug 25567963

Change-Id: I9f0d071c815a011be4f4c85c502c39d0fe0fe5e8
parent 6d2beef6
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -2607,14 +2607,6 @@ 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();
@@ -6153,18 +6145,6 @@ 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 {
+0 −2
Original line number Diff line number Diff line
@@ -518,7 +518,6 @@ 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;
@@ -881,7 +880,6 @@ 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 user The user for whom to fetch the profile owner name, if any.
     * @param userId 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.
+6 −0
Original line number Diff line number Diff line
@@ -80,4 +80,10 @@ 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);
}
+8 −18
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ 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;
@@ -500,11 +502,6 @@ 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 {
@@ -5135,8 +5132,12 @@ public final class ActivityManagerService extends ActivityManagerNative
    public boolean clearApplicationUserData(final String packageName,
            final IPackageDataObserver observer, int userId) {
        enforceNotIsolatedCaller("clearApplicationUserData");
        if (packageName != null && packageName.equals(mDeviceOwnerName)) {
            throw new SecurityException("Clearing DeviceOwner data is forbidden.");
        final DevicePolicyManagerInternal dpmi =
                LocalServices.getService(DevicePolicyManagerInternal.class);
        if (dpmi != null && dpmi.isDeviceAdminPackage(userId, packageName)) {
            throw new SecurityException(
                    "Clearing DeviceAdmin/DeviceOwner/ProfileOwner data is forbidden.");
        }
        int uid = Binder.getCallingUid();
        int pid = Binder.getCallingPid();
@@ -9215,17 +9216,6 @@ 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