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

Commit cbb0f014 authored by Yuri Lin's avatar Yuri Lin
Browse files

Change bundles & summarization settings to be per-user

This change separates out settings for whether bundles & summarization are enabled for each user (full or profile), as well as distinguishing packages by the user they're associated with. Profiles inherit the specific classification types that are enabled for the associated full user.

Bug: 380290891
Flag: android.service.notification.notification_classification
Test: NotificationManagerServiceTest, NotificationAssistantsTest, manual
Change-Id: I6d5865d1f51f51fb0e0ecd9e440c5f10e12dfad2
parent b74b84d0
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -84,8 +84,9 @@ interface INotificationManager
    boolean isImportanceLocked(String pkg, int uid);

    List<String> getAllowedAssistantAdjustments(String pkg);
    void allowAssistantAdjustment(String adjustmentType);
    void disallowAssistantAdjustment(String adjustmentType);
    List<String> getAllowedAssistantAdjustmentsForUser(int userId);
    void allowAssistantAdjustment(int userId, String adjustmentType);
    void disallowAssistantAdjustment(int userId, String adjustmentType);

    boolean shouldHideSilentStatusIcons(String callingPkg);
    void setHideSilentStatusIcons(boolean hide);
@@ -268,11 +269,11 @@ interface INotificationManager
    void setAdjustmentTypeSupportedState(in INotificationListener token, String key, boolean supported);
    List<String> getUnsupportedAdjustmentTypes();

    int[] getAllowedAdjustmentKeyTypes();
    void setAssistantAdjustmentKeyTypeState(int type, boolean enabled);
    String[] getAdjustmentDeniedPackages(String key);
    boolean isAdjustmentSupportedForPackage(String key, String pkg);
    void setAdjustmentSupportedForPackage(String key, String pkg, boolean enabled);
    int[] getAllowedClassificationTypes();
    void setAssistantClassificationTypeState(int type, boolean enabled);
    String[] getAdjustmentDeniedPackages(int userId, String key);
    boolean isAdjustmentSupportedForPackage(int userId, String key, String pkg);
    void setAdjustmentSupportedForPackage(int userId, String key, String pkg, boolean enabled);

    // TODO: b/389918945 - Remove once nm_binder_perf flags are going to Nextfood.
    void incrementCounter(String metricId);
+11 −3
Original line number Diff line number Diff line
@@ -2221,7 +2221,7 @@ public class NotificationManager {
    public void allowAssistantAdjustment(@NonNull String capability) {
        INotificationManager service = service();
        try {
            service.allowAssistantAdjustment(capability);
            service.allowAssistantAdjustment(mContext.getUserId(), capability);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -2235,7 +2235,7 @@ public class NotificationManager {
    public void disallowAssistantAdjustment(@NonNull String capability) {
        INotificationManager service = service();
        try {
            service.disallowAssistantAdjustment(capability);
            service.disallowAssistantAdjustment(mContext.getUserId(), capability);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -2258,9 +2258,17 @@ public class NotificationManager {
    @TestApi
    @FlaggedApi(android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION)
    public void setAssistantAdjustmentKeyTypeState(@Adjustment.Types int type, boolean enabled) {
        setAssistantClassificationTypeState(type, enabled);
    }

    /**
     * @hide
     */
    @FlaggedApi(android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION)
    public void setAssistantClassificationTypeState(@Adjustment.Types int type, boolean enabled) {
        INotificationManager service = service();
        try {
            service.setAssistantAdjustmentKeyTypeState(type, enabled);
            service.setAssistantClassificationTypeState(type, enabled);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+3 −3
Original line number Diff line number Diff line
@@ -195,13 +195,13 @@ class BundledNotificationInfoTest : SysuiTestCase() {
        underTest.handleCloseControls(true, false)
        testableLooper.processAllMessages()
        verify(mockINotificationManager, never())
            .setAdjustmentSupportedForPackage(anyString(), anyString(), anyBoolean())
            .setAdjustmentSupportedForPackage(anyInt(), anyString(), anyString(), anyBoolean())
    }

    @Test
    fun testToggleCallsUpdate() {
        whenever(mockINotificationManager.isAdjustmentSupportedForPackage(
            anyString(), anyString())).thenReturn(true)
            anyInt(), anyString(), anyString())).thenReturn(true)

        bindNotification()

@@ -211,7 +211,7 @@ class BundledNotificationInfoTest : SysuiTestCase() {

        testableLooper.processAllMessages()
        verify(mockINotificationManager)
            .setAdjustmentSupportedForPackage(anyString(), anyString(), eq(false))
            .setAdjustmentSupportedForPackage(anyInt(), anyString(), anyString(), eq(false))
    }

    @Test
+2 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ class BundledNotificationInfo(context: Context?, attrs: AttributeSet?) :
    override fun bindInlineControls() {
        val enabled =
            mINotificationManager.isAdjustmentSupportedForPackage(
                mSbn.normalizedUserId,
                Adjustment.KEY_TYPE,
                mSbn.packageName,
            )
@@ -133,6 +134,7 @@ class BundledNotificationInfo(context: Context?, attrs: AttributeSet?) :
                    mOnUserInteractionCallback.onImportanceChanged(mEntry)
                }
                mINotificationManager.setAdjustmentSupportedForPackage(
                    mSbn.normalizedUserId,
                    Adjustment.KEY_TYPE,
                    mSbn.packageName,
                    toggle.isChecked,
+245 −104

File changed.

Preview size limit exceeded, changes collapsed.

Loading