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

Commit 4af392fe authored by Eugene Susla's avatar Eugene Susla Committed by Android (Google) Code Review
Browse files

Merge "Provide CDM API to associate without prompt" into sc-dev

parents 8d95267e 120de6c1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2180,6 +2180,7 @@ package android.bluetooth.le {
package android.companion {
  public final class CompanionDeviceManager {
    method @RequiresPermission("android.permission.ASSOCIATE_COMPANION_DEVICES") public boolean associate(@NonNull String, @NonNull android.net.MacAddress);
    method @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") public boolean canPairWithoutPrompt(@NonNull String, @NonNull String, int);
    method @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") public boolean isDeviceAssociatedForWifiConnection(@NonNull String, @NonNull android.net.MacAddress, @NonNull android.os.UserHandle);
  }
+26 −0
Original line number Diff line number Diff line
@@ -425,6 +425,32 @@ public final class CompanionDeviceManager {
                    mContext.getPackageName(), deviceAddress);
        } catch (RemoteException e) {
            ExceptionUtils.propagateIfInstanceOf(e.getCause(), DeviceNotAssociatedException.class);
        }
    }

    /**
     * Associates given device with given app for the given user directly, without UI prompt.
     *
     * @return whether successful
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.ASSOCIATE_COMPANION_DEVICES)
    public boolean associate(
            @NonNull String packageName,
            @NonNull MacAddress macAddress) {
        if (!checkFeaturePresent()) {
            return false;
        }
        Objects.requireNonNull(packageName, "package name cannot be null");
        Objects.requireNonNull(macAddress, "mac address cannot be null");

        UserHandle user = android.os.Process.myUserHandle();
        try {
            return mService.createAssociation(
                    packageName, macAddress.toString(), user.getIdentifier());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
+2 −0
Original line number Diff line number Diff line
@@ -51,4 +51,6 @@ interface ICompanionDeviceManager {
    void unregisterDevicePresenceListenerService(in String packageName, in String deviceAddress);

    boolean canPairWithoutPrompt(in String packageName, in String deviceMacAddress, int userId);

    boolean createAssociation(in String packageName, in String macAddress, int userId);
}
+5 −0
Original line number Diff line number Diff line
@@ -4227,6 +4227,11 @@
    <permission android:name="android.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE"
                android:protectionLevel="normal" />

    <!-- Allows an application to create new companion device associations.
         @hide -->
    <permission android:name="android.permission.ASSOCIATE_COMPANION_DEVICES"
        android:protectionLevel="internal|role" />

    <!-- @SystemApi Allows an application to use SurfaceFlinger's low level features.
         <p>Not for use by third-party applications.
         @hide
+7 −0
Original line number Diff line number Diff line
@@ -3732,6 +3732,13 @@
     -->
    <string name="config_defaultWellbeingPackage" translatable="false"></string>

    <!-- The package name for the companion provider app.
         This package must be trusted, as it has the permissions to associate apps with devices
         without a UI prompt.
         Example: "com.google.android.gms"
     -->
    <string name="config_companionProviderPackage" translatable="false"></string>

    <!-- The component name for the default system attention service.
         This service must be trusted, as it can be activated without explicit consent of the user.
         See android.attention.AttentionManagerService.
Loading