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

Commit 2aeeae8c authored by Raphael Kim's avatar Raphael Kim Committed by Android (Google) Code Review
Browse files

Merge "Add hidden API for testing application bound state"

parents 32cd0a63 1c0d605c
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -1008,6 +1008,22 @@ public final class CompanionDeviceManager {
        }
    }

    /**
     * Checks whether the calling companion application is currently bound.
     *
     * @return true if application is bound, false otherwise
     * @hide
     */
    @UserHandleAware
    public boolean isCompanionApplicationBound() {
        try {
            return mService.isCompanionApplicationBound(
                    mContext.getOpPackageName(), mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    private boolean checkFeaturePresent() {
        boolean featurePresent = mService != null;
        if (!featurePresent && DEBUG) {
+2 −0
Original line number Diff line number Diff line
@@ -80,4 +80,6 @@ interface ICompanionDeviceManager {
    void attachSystemDataTransport(String packageName, int userId, int associationId, in ParcelFileDescriptor fd);

    void detachSystemDataTransport(String packageName, int userId, int associationId);

    boolean isCompanionApplicationBound(String packageName, int userId);
}
+5 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@

package com.android.server.companion;

import static android.Manifest.permission.DELIVER_COMPANION_MESSAGES;
import static android.Manifest.permission.MANAGE_COMPANION_DEVICES;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
import static android.content.pm.PackageManager.CERT_INPUT_SHA256;
@@ -88,7 +87,6 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArraySet;
import android.util.Base64;
import android.util.ExceptionUtils;
import android.util.Log;
import android.util.Slog;
@@ -756,6 +754,11 @@ public class CompanionDeviceManagerService extends SystemService {
            mDevicePresenceMonitor.onSelfManagedDeviceDisconnected(associationId);
        }

        @Override
        public boolean isCompanionApplicationBound(String packageName, int userId) {
            return mCompanionAppController.isCompanionApplicationBound(userId, packageName);
        }

        private void registerDevicePresenceListenerActive(String packageName, String deviceAddress,
                boolean active) throws RemoteException {
            if (DEBUG) {