Loading core/java/android/app/ActivityManagerNative.java +20 −0 Original line number Diff line number Diff line Loading @@ -2611,6 +2611,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(); Loading Loading @@ -6154,6 +6162,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 { Loading core/java/android/app/IActivityManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading core/java/android/app/admin/DevicePolicyManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -595,7 +595,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. Loading Loading @@ -2996,7 +2996,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. Loading core/java/android/app/admin/DevicePolicyManagerInternal.java +0 −6 Original line number Diff line number Diff line Loading @@ -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); } services/core/java/com/android/server/am/ActivityManagerService.java +18 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -504,6 +502,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 { Loading Loading @@ -5134,12 +5137,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(); Loading Loading @@ -9239,6 +9238,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 Loading
core/java/android/app/ActivityManagerNative.java +20 −0 Original line number Diff line number Diff line Loading @@ -2611,6 +2611,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(); Loading Loading @@ -6154,6 +6162,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 { Loading
core/java/android/app/IActivityManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading
core/java/android/app/admin/DevicePolicyManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -595,7 +595,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. Loading Loading @@ -2996,7 +2996,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. Loading
core/java/android/app/admin/DevicePolicyManagerInternal.java +0 −6 Original line number Diff line number Diff line Loading @@ -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); }
services/core/java/com/android/server/am/ActivityManagerService.java +18 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -504,6 +502,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 { Loading Loading @@ -5134,12 +5137,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(); Loading Loading @@ -9239,6 +9238,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