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

Commit 3d1d6c8c authored by Hui Yu's avatar Hui Yu
Browse files

DevicePolicy changes after bindService flags extended to 64 bits.

Bug: 191785864
Test: atest cts/tests/app/src/android/app/cts/ServiceTest.java#testBindServiceFlags
atest cts/tests/app/src/android/app/cts/ServiceTest.java
atest cts/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java

Change-Id: I1898a2e6670e03403b1e8fbf197863398fdcc956
parent 57c7aa90
Loading
Loading
Loading
Loading
+27 −5
Original line number Diff line number Diff line
@@ -14159,18 +14159,40 @@ public class DevicePolicyManager {
     * @see Context#bindService(Intent, ServiceConnection, int)
     * @see #getBindDeviceAdminTargetUsers(ComponentName)
     */
    public boolean bindDeviceAdminServiceAsUser(
            @NonNull ComponentName admin,  Intent serviceIntent, @NonNull ServiceConnection conn,
            @Context.BindServiceFlags int flags, @NonNull UserHandle targetUser) {
    public boolean bindDeviceAdminServiceAsUser(@NonNull ComponentName admin,
            @NonNull Intent serviceIntent, @NonNull ServiceConnection conn,
            @Context.BindServiceFlagsBits int flags, @NonNull UserHandle targetUser) {
        throwIfParentInstance("bindDeviceAdminServiceAsUser");
        // Keep this in sync with ContextImpl.bindServiceCommon.
        try {
            final IServiceConnection sd = mContext.getServiceDispatcher(
                    conn, mContext.getMainThreadHandler(), flags);
                    conn, mContext.getMainThreadHandler(), Integer.toUnsignedLong(flags));
            serviceIntent.prepareToLeaveProcess(mContext);
            return mService.bindDeviceAdminServiceAsUser(admin,
                    mContext.getIApplicationThread(), mContext.getActivityToken(), serviceIntent,
                    sd, flags, targetUser.getIdentifier());
                    sd, Integer.toUnsignedLong(flags), targetUser.getIdentifier());
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }
    /**
     * See {@link #bindDeviceAdminServiceAsUser(ComponentName, Intent, ServiceConnection, int,
     *       UserHandle)}.
     * Call {@link Context.BindServiceFlags#of(long)} to obtain a BindServiceFlags object.
     */
    public boolean bindDeviceAdminServiceAsUser(@NonNull ComponentName admin,
            @NonNull Intent serviceIntent, @NonNull ServiceConnection conn,
            @NonNull Context.BindServiceFlags flags, @NonNull UserHandle targetUser) {
        throwIfParentInstance("bindDeviceAdminServiceAsUser");
        // Keep this in sync with ContextImpl.bindServiceCommon.
        try {
            final IServiceConnection sd = mContext.getServiceDispatcher(
                    conn, mContext.getMainThreadHandler(), flags.getValue());
            serviceIntent.prepareToLeaveProcess(mContext);
            return mService.bindDeviceAdminServiceAsUser(admin,
                    mContext.getIApplicationThread(), mContext.getActivityToken(), serviceIntent,
                    sd, flags.getValue(), targetUser.getIdentifier());
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
+1 −1
Original line number Diff line number Diff line
@@ -453,7 +453,7 @@ interface IDevicePolicyManager {

    boolean bindDeviceAdminServiceAsUser(in ComponentName admin,
        IApplicationThread caller, IBinder token, in Intent service,
        IServiceConnection connection, int flags, int targetUserId);
        IServiceConnection connection, long flags, int targetUserId);
    List<UserHandle> getBindDeviceAdminTargetUsers(in ComponentName admin);
    boolean isEphemeralUser(in ComponentName admin);

+1 −1
Original line number Diff line number Diff line
@@ -16697,7 +16697,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    public boolean bindDeviceAdminServiceAsUser(
            @NonNull ComponentName admin, @NonNull IApplicationThread caller,
            @Nullable IBinder activtiyToken, @NonNull Intent serviceIntent,
            @NonNull IServiceConnection connection, int flags, @UserIdInt int targetUserId) {
            @NonNull IServiceConnection connection, long flags, @UserIdInt int targetUserId) {
        if (!mHasFeature) {
            return false;
        }