Loading services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -152,6 +152,8 @@ public class CompanionDeviceManagerService extends SystemService { final UserManager userManager = context.getSystemService(UserManager.class); final PowerManagerInternal powerManagerInternal = LocalServices.getService( PowerManagerInternal.class); final NotificationManager notificationManager = context.getSystemService( NotificationManager.class); final AssociationDiskStore associationDiskStore = new AssociationDiskStore(); mAssociationStore = new AssociationStore(context, userManager, associationDiskStore); Loading Loading @@ -179,7 +181,8 @@ public class CompanionDeviceManagerService extends SystemService { mDisassociationProcessor = new DisassociationProcessor(context, activityManager, mAssociationStore, packageManagerInternal, mDevicePresenceProcessor, mCompanionAppBinder, mSystemDataTransferRequestStore, mTransportManager); mCompanionAppBinder, mSystemDataTransferRequestStore, mTransportManager, notificationManager); mSystemDataTransferProcessor = new SystemDataTransferProcessor(this, packageManagerInternal, mAssociationStore, Loading services/companion/java/com/android/server/companion/association/DisassociationProcessor.java +27 −2 Original line number Diff line number Diff line Loading @@ -28,12 +28,16 @@ import android.annotation.NonNull; import android.annotation.SuppressLint; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.NotificationManager; import android.companion.AssociationInfo; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.os.Binder; import android.os.SystemProperties; import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.util.Slog; import com.android.server.companion.datatransfer.SystemDataTransferRequestStore; Loading @@ -41,6 +45,8 @@ import com.android.server.companion.devicepresence.CompanionAppBinder; import com.android.server.companion.devicepresence.DevicePresenceProcessor; import com.android.server.companion.transport.CompanionTransportManager; import java.util.List; /** * This class responsible for disassociation. */ Loading Loading @@ -76,6 +82,7 @@ public class DisassociationProcessor { private final CompanionTransportManager mTransportManager; private final OnPackageVisibilityChangeListener mOnPackageVisibilityChangeListener; private final ActivityManager mActivityManager; private final NotificationManager mNotificationManager; public DisassociationProcessor(@NonNull Context context, @NonNull ActivityManager activityManager, Loading @@ -84,7 +91,8 @@ public class DisassociationProcessor { @NonNull DevicePresenceProcessor devicePresenceMonitor, @NonNull CompanionAppBinder applicationController, @NonNull SystemDataTransferRequestStore systemDataTransferRequestStore, @NonNull CompanionTransportManager companionTransportManager) { @NonNull CompanionTransportManager companionTransportManager, @NonNull NotificationManager notificationManager) { mContext = context; mActivityManager = activityManager; mAssociationStore = associationStore; Loading @@ -95,12 +103,12 @@ public class DisassociationProcessor { mCompanionAppController = applicationController; mSystemDataTransferRequestStore = systemDataTransferRequestStore; mTransportManager = companionTransportManager; mNotificationManager = notificationManager; } /** * Disassociate an association by id. */ // TODO: also revoke notification access public void disassociate(int id, String reason) { Slog.i(TAG, "Disassociating id=[" + id + "]..."); Loading Loading @@ -135,6 +143,23 @@ public class DisassociationProcessor { mSystemDataTransferRequestStore.removeRequestsByAssociationId(userId, id); mAssociationStore.removeAssociation(association.getId(), reason); // Revoke NLS if the last association has been removed for the package Binder.withCleanCallingIdentity(() -> { if (mAssociationStore.getAssociationsByPackage(userId, packageName).isEmpty()) { Intent nlsIntent = new Intent( NotificationListenerService.SERVICE_INTERFACE); List<ResolveInfo> matchedServiceList = mContext.getPackageManager() .queryIntentServicesAsUser(nlsIntent, /* flags */ 0, userId); for (ResolveInfo service : matchedServiceList) { if (service.getComponentInfo().getComponentName().getPackageName() .equals(packageName)) { mNotificationManager.setNotificationListenerAccessGranted( service.getComponentInfo().getComponentName(), false); } } } }); // If role is not in use by other associations, revoke the role. // Do not need to remove the system role since it was pre-granted by the system. if (!isRoleInUseByOtherAssociations && deviceProfile != null && !deviceProfile.equals( Loading Loading
services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -152,6 +152,8 @@ public class CompanionDeviceManagerService extends SystemService { final UserManager userManager = context.getSystemService(UserManager.class); final PowerManagerInternal powerManagerInternal = LocalServices.getService( PowerManagerInternal.class); final NotificationManager notificationManager = context.getSystemService( NotificationManager.class); final AssociationDiskStore associationDiskStore = new AssociationDiskStore(); mAssociationStore = new AssociationStore(context, userManager, associationDiskStore); Loading Loading @@ -179,7 +181,8 @@ public class CompanionDeviceManagerService extends SystemService { mDisassociationProcessor = new DisassociationProcessor(context, activityManager, mAssociationStore, packageManagerInternal, mDevicePresenceProcessor, mCompanionAppBinder, mSystemDataTransferRequestStore, mTransportManager); mCompanionAppBinder, mSystemDataTransferRequestStore, mTransportManager, notificationManager); mSystemDataTransferProcessor = new SystemDataTransferProcessor(this, packageManagerInternal, mAssociationStore, Loading
services/companion/java/com/android/server/companion/association/DisassociationProcessor.java +27 −2 Original line number Diff line number Diff line Loading @@ -28,12 +28,16 @@ import android.annotation.NonNull; import android.annotation.SuppressLint; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.NotificationManager; import android.companion.AssociationInfo; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.os.Binder; import android.os.SystemProperties; import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.util.Slog; import com.android.server.companion.datatransfer.SystemDataTransferRequestStore; Loading @@ -41,6 +45,8 @@ import com.android.server.companion.devicepresence.CompanionAppBinder; import com.android.server.companion.devicepresence.DevicePresenceProcessor; import com.android.server.companion.transport.CompanionTransportManager; import java.util.List; /** * This class responsible for disassociation. */ Loading Loading @@ -76,6 +82,7 @@ public class DisassociationProcessor { private final CompanionTransportManager mTransportManager; private final OnPackageVisibilityChangeListener mOnPackageVisibilityChangeListener; private final ActivityManager mActivityManager; private final NotificationManager mNotificationManager; public DisassociationProcessor(@NonNull Context context, @NonNull ActivityManager activityManager, Loading @@ -84,7 +91,8 @@ public class DisassociationProcessor { @NonNull DevicePresenceProcessor devicePresenceMonitor, @NonNull CompanionAppBinder applicationController, @NonNull SystemDataTransferRequestStore systemDataTransferRequestStore, @NonNull CompanionTransportManager companionTransportManager) { @NonNull CompanionTransportManager companionTransportManager, @NonNull NotificationManager notificationManager) { mContext = context; mActivityManager = activityManager; mAssociationStore = associationStore; Loading @@ -95,12 +103,12 @@ public class DisassociationProcessor { mCompanionAppController = applicationController; mSystemDataTransferRequestStore = systemDataTransferRequestStore; mTransportManager = companionTransportManager; mNotificationManager = notificationManager; } /** * Disassociate an association by id. */ // TODO: also revoke notification access public void disassociate(int id, String reason) { Slog.i(TAG, "Disassociating id=[" + id + "]..."); Loading Loading @@ -135,6 +143,23 @@ public class DisassociationProcessor { mSystemDataTransferRequestStore.removeRequestsByAssociationId(userId, id); mAssociationStore.removeAssociation(association.getId(), reason); // Revoke NLS if the last association has been removed for the package Binder.withCleanCallingIdentity(() -> { if (mAssociationStore.getAssociationsByPackage(userId, packageName).isEmpty()) { Intent nlsIntent = new Intent( NotificationListenerService.SERVICE_INTERFACE); List<ResolveInfo> matchedServiceList = mContext.getPackageManager() .queryIntentServicesAsUser(nlsIntent, /* flags */ 0, userId); for (ResolveInfo service : matchedServiceList) { if (service.getComponentInfo().getComponentName().getPackageName() .equals(packageName)) { mNotificationManager.setNotificationListenerAccessGranted( service.getComponentInfo().getComponentName(), false); } } } }); // If role is not in use by other associations, revoke the role. // Do not need to remove the system role since it was pre-granted by the system. if (!isRoleInUseByOtherAssociations && deviceProfile != null && !deviceProfile.equals( Loading