Loading core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading core/java/android/companion/CompanionDeviceManager.java +26 −0 Original line number Diff line number Diff line Loading @@ -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(); } } Loading core/java/android/companion/ICompanionDeviceManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); } core/res/AndroidManifest.xml +5 −0 Original line number Diff line number Diff line Loading @@ -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 Loading core/res/res/values/config.xml +7 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading
core/java/android/companion/CompanionDeviceManager.java +26 −0 Original line number Diff line number Diff line Loading @@ -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(); } } Loading
core/java/android/companion/ICompanionDeviceManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); }
core/res/AndroidManifest.xml +5 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
core/res/res/values/config.xml +7 −0 Original line number Diff line number Diff line Loading @@ -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