Loading src/com/android/settings/applications/specialaccess/notificationaccess/BridgedAppsLinkPreferenceController.java +8 −2 Original line number Diff line number Diff line Loading @@ -18,10 +18,11 @@ import android.content.Context; import android.os.Build; import android.service.notification.NotificationListenerFilter; import androidx.preference.Preference; import com.android.settings.core.BasePreferenceController; import com.android.settings.notification.NotificationBackend; public class BridgedAppsLinkPreferenceController extends BasePreferenceController { private ComponentName mCn; Loading Loading @@ -61,7 +62,6 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle if (mTargetSdk > Build.VERSION_CODES.S) { return AVAILABLE; } mNlf = mNm.getListenerFilter(mCn, mUserId); if (!mNlf.areAllTypesAllowed() || !mNlf.getDisallowedPackages().isEmpty()) { return AVAILABLE; Loading @@ -69,4 +69,10 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle } return DISABLED_DEPENDENT_SETTING; } @Override public void updateState(Preference pref) { pref.setEnabled(getAvailabilityStatus() == AVAILABLE); super.updateState(pref); } } src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java +2 −10 Original line number Diff line number Diff line Loading @@ -233,11 +233,7 @@ public class NotificationAccessDetails extends DashboardFragment { apc.updateState(screen.findPreference(apc.getPreferenceKey())); getPreferenceControllers().forEach(controllers -> { controllers.forEach(controller -> { if (controller instanceof TypeFilterPreferenceController) { TypeFilterPreferenceController tfpc = (TypeFilterPreferenceController) controller; tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey())); } controller.updateState(screen.findPreference(controller.getPreferenceKey())); }); }); } Loading @@ -249,11 +245,7 @@ public class NotificationAccessDetails extends DashboardFragment { apc.updateState(screen.findPreference(apc.getPreferenceKey())); getPreferenceControllers().forEach(controllers -> { controllers.forEach(controller -> { if (controller instanceof TypeFilterPreferenceController) { TypeFilterPreferenceController tfpc = (TypeFilterPreferenceController) controller; tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey())); } controller.updateState(screen.findPreference(controller.getPreferenceKey())); }); }); } Loading tests/unit/src/com/android/settings/applications/specialaccess/notificationaccess/BridgedAppsLinkPreferenceControllerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.content.Context; import android.os.Build; import android.service.notification.NotificationListenerFilter; import androidx.preference.Preference; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; Loading Loading @@ -68,6 +69,11 @@ public class BridgedAppsLinkPreferenceControllerTest { mController.setTargetSdk(Build.VERSION_CODES.CUR_DEVELOPMENT + 1); assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING); // disables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isFalse(); } @Test Loading @@ -77,6 +83,11 @@ public class BridgedAppsLinkPreferenceControllerTest { when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter()); assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING); // disables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isFalse(); } @Test Loading @@ -88,6 +99,11 @@ public class BridgedAppsLinkPreferenceControllerTest { when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); // enables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isTrue(); } @Test Loading @@ -97,5 +113,10 @@ public class BridgedAppsLinkPreferenceControllerTest { when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter()); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); // enables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isTrue(); } } Loading
src/com/android/settings/applications/specialaccess/notificationaccess/BridgedAppsLinkPreferenceController.java +8 −2 Original line number Diff line number Diff line Loading @@ -18,10 +18,11 @@ import android.content.Context; import android.os.Build; import android.service.notification.NotificationListenerFilter; import androidx.preference.Preference; import com.android.settings.core.BasePreferenceController; import com.android.settings.notification.NotificationBackend; public class BridgedAppsLinkPreferenceController extends BasePreferenceController { private ComponentName mCn; Loading Loading @@ -61,7 +62,6 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle if (mTargetSdk > Build.VERSION_CODES.S) { return AVAILABLE; } mNlf = mNm.getListenerFilter(mCn, mUserId); if (!mNlf.areAllTypesAllowed() || !mNlf.getDisallowedPackages().isEmpty()) { return AVAILABLE; Loading @@ -69,4 +69,10 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle } return DISABLED_DEPENDENT_SETTING; } @Override public void updateState(Preference pref) { pref.setEnabled(getAvailabilityStatus() == AVAILABLE); super.updateState(pref); } }
src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java +2 −10 Original line number Diff line number Diff line Loading @@ -233,11 +233,7 @@ public class NotificationAccessDetails extends DashboardFragment { apc.updateState(screen.findPreference(apc.getPreferenceKey())); getPreferenceControllers().forEach(controllers -> { controllers.forEach(controller -> { if (controller instanceof TypeFilterPreferenceController) { TypeFilterPreferenceController tfpc = (TypeFilterPreferenceController) controller; tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey())); } controller.updateState(screen.findPreference(controller.getPreferenceKey())); }); }); } Loading @@ -249,11 +245,7 @@ public class NotificationAccessDetails extends DashboardFragment { apc.updateState(screen.findPreference(apc.getPreferenceKey())); getPreferenceControllers().forEach(controllers -> { controllers.forEach(controller -> { if (controller instanceof TypeFilterPreferenceController) { TypeFilterPreferenceController tfpc = (TypeFilterPreferenceController) controller; tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey())); } controller.updateState(screen.findPreference(controller.getPreferenceKey())); }); }); } Loading
tests/unit/src/com/android/settings/applications/specialaccess/notificationaccess/BridgedAppsLinkPreferenceControllerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.content.Context; import android.os.Build; import android.service.notification.NotificationListenerFilter; import androidx.preference.Preference; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; Loading Loading @@ -68,6 +69,11 @@ public class BridgedAppsLinkPreferenceControllerTest { mController.setTargetSdk(Build.VERSION_CODES.CUR_DEVELOPMENT + 1); assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING); // disables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isFalse(); } @Test Loading @@ -77,6 +83,11 @@ public class BridgedAppsLinkPreferenceControllerTest { when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter()); assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING); // disables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isFalse(); } @Test Loading @@ -88,6 +99,11 @@ public class BridgedAppsLinkPreferenceControllerTest { when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); // enables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isTrue(); } @Test Loading @@ -97,5 +113,10 @@ public class BridgedAppsLinkPreferenceControllerTest { when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter()); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); // enables field Preference p = new Preference(mContext); mController.updateState(p); assertThat(p.isEnabled()).isTrue(); } }