Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8267,6 +8267,8 @@ package android.companion { method public void associate(android.companion.AssociationRequest, android.companion.CompanionDeviceManager.Callback, android.os.Handler); method public void disassociate(java.lang.String); method public java.util.List<java.lang.String> getAssociations(); method public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); field public static final java.lang.String EXTRA_DEVICE = "android.companion.extra.DEVICE"; } api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8761,6 +8761,8 @@ package android.companion { method public void associate(android.companion.AssociationRequest, android.companion.CompanionDeviceManager.Callback, android.os.Handler); method public void disassociate(java.lang.String); method public java.util.List<java.lang.String> getAssociations(); method public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); field public static final java.lang.String EXTRA_DEVICE = "android.companion.extra.DEVICE"; } api/test-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8298,6 +8298,8 @@ package android.companion { method public void associate(android.companion.AssociationRequest, android.companion.CompanionDeviceManager.Callback, android.os.Handler); method public void disassociate(java.lang.String); method public java.util.List<java.lang.String> getAssociations(); method public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); field public static final java.lang.String EXTRA_DEVICE = "android.companion.extra.DEVICE"; } core/java/android/companion/CompanionDeviceManager.java +35 −8 Original line number Diff line number Diff line Loading @@ -22,11 +22,13 @@ import static com.android.internal.util.Preconditions.checkNotNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.IntentSender; import android.content.pm.PackageManager; import android.os.Handler; import android.os.RemoteException; import android.service.notification.NotificationListenerService; import android.util.Log; import java.util.Collections; Loading Loading @@ -195,22 +197,47 @@ public final class CompanionDeviceManager { } } /** @hide */ public void requestNotificationAccess() { /** * Request notification access for the given component. * * The given component must follow the protocol specified in {@link NotificationListenerService} * * Only components from the same {@link ComponentName#getPackageName package} as the calling app * are allowed. * * Your app must have an association with a device before calling this API */ public void requestNotificationAccess(ComponentName component) { if (!checkFeaturePresent()) { return; } //TODO implement throw new UnsupportedOperationException("Not yet implemented"); try { mService.requestNotificationAccess(component).send(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } catch (PendingIntent.CanceledException e) { throw new RuntimeException(e); } } /** @hide */ public boolean haveNotificationAccess() { /** * Check whether the given component can access the notifications via a * {@link NotificationListenerService} * * Your app must have an association with a device before calling this API * * @param component the name of the component * @return whether the given component has the notification listener permission */ public boolean hasNotificationAccess(ComponentName component) { if (!checkFeaturePresent()) { return false; } //TODO implement throw new UnsupportedOperationException("Not yet implemented"); try { return mService.hasNotificationAccess(component); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } private boolean checkFeaturePresent() { Loading core/java/android/companion/ICompanionDeviceManager.aidl +4 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package android.companion; import android.app.PendingIntent; import android.companion.IFindDeviceCallback; import android.companion.AssociationRequest; import android.content.ComponentName; /** * Interface for communication with the core companion device manager service. Loading @@ -32,7 +34,6 @@ interface ICompanionDeviceManager { List<String> getAssociations(String callingPackage, int userId); void disassociate(String deviceMacAddress, String callingPackage); //TODO add these // boolean haveNotificationAccess(String packageName); // oneway void requestNotificationAccess(String packageName); boolean hasNotificationAccess(in ComponentName component); PendingIntent requestNotificationAccess(in ComponentName component); } Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8267,6 +8267,8 @@ package android.companion { method public void associate(android.companion.AssociationRequest, android.companion.CompanionDeviceManager.Callback, android.os.Handler); method public void disassociate(java.lang.String); method public java.util.List<java.lang.String> getAssociations(); method public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); field public static final java.lang.String EXTRA_DEVICE = "android.companion.extra.DEVICE"; }
api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8761,6 +8761,8 @@ package android.companion { method public void associate(android.companion.AssociationRequest, android.companion.CompanionDeviceManager.Callback, android.os.Handler); method public void disassociate(java.lang.String); method public java.util.List<java.lang.String> getAssociations(); method public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); field public static final java.lang.String EXTRA_DEVICE = "android.companion.extra.DEVICE"; }
api/test-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8298,6 +8298,8 @@ package android.companion { method public void associate(android.companion.AssociationRequest, android.companion.CompanionDeviceManager.Callback, android.os.Handler); method public void disassociate(java.lang.String); method public java.util.List<java.lang.String> getAssociations(); method public boolean hasNotificationAccess(android.content.ComponentName); method public void requestNotificationAccess(android.content.ComponentName); field public static final java.lang.String EXTRA_DEVICE = "android.companion.extra.DEVICE"; }
core/java/android/companion/CompanionDeviceManager.java +35 −8 Original line number Diff line number Diff line Loading @@ -22,11 +22,13 @@ import static com.android.internal.util.Preconditions.checkNotNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.IntentSender; import android.content.pm.PackageManager; import android.os.Handler; import android.os.RemoteException; import android.service.notification.NotificationListenerService; import android.util.Log; import java.util.Collections; Loading Loading @@ -195,22 +197,47 @@ public final class CompanionDeviceManager { } } /** @hide */ public void requestNotificationAccess() { /** * Request notification access for the given component. * * The given component must follow the protocol specified in {@link NotificationListenerService} * * Only components from the same {@link ComponentName#getPackageName package} as the calling app * are allowed. * * Your app must have an association with a device before calling this API */ public void requestNotificationAccess(ComponentName component) { if (!checkFeaturePresent()) { return; } //TODO implement throw new UnsupportedOperationException("Not yet implemented"); try { mService.requestNotificationAccess(component).send(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } catch (PendingIntent.CanceledException e) { throw new RuntimeException(e); } } /** @hide */ public boolean haveNotificationAccess() { /** * Check whether the given component can access the notifications via a * {@link NotificationListenerService} * * Your app must have an association with a device before calling this API * * @param component the name of the component * @return whether the given component has the notification listener permission */ public boolean hasNotificationAccess(ComponentName component) { if (!checkFeaturePresent()) { return false; } //TODO implement throw new UnsupportedOperationException("Not yet implemented"); try { return mService.hasNotificationAccess(component); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } private boolean checkFeaturePresent() { Loading
core/java/android/companion/ICompanionDeviceManager.aidl +4 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package android.companion; import android.app.PendingIntent; import android.companion.IFindDeviceCallback; import android.companion.AssociationRequest; import android.content.ComponentName; /** * Interface for communication with the core companion device manager service. Loading @@ -32,7 +34,6 @@ interface ICompanionDeviceManager { List<String> getAssociations(String callingPackage, int userId); void disassociate(String deviceMacAddress, String callingPackage); //TODO add these // boolean haveNotificationAccess(String packageName); // oneway void requestNotificationAccess(String packageName); boolean hasNotificationAccess(in ComponentName component); PendingIntent requestNotificationAccess(in ComponentName component); }