Fix NotificationAssistantPreferenceController constructor

Fix flaky test due to the constructor must either only take Context, or
(Context, String).

Bug: 187998873
Test: CodeInspectionTest, NotificationAssistantPreferenceControllerTest
Change-Id: Ie383ea6773afda05adfb7aa9d7de9e27676f6b29
This commit is contained in:
Chloris Kuo
2021-06-03 15:26:50 -07:00
parent 52ee33df19
commit 5028e6e6a6
4 changed files with 30 additions and 15 deletions

View File

@@ -30,6 +30,8 @@ import com.google.common.annotations.VisibleForTesting;
public class NotificationAssistantPreferenceController extends TogglePreferenceController {
private static final String TAG = "NASPreferenceController";
private static final String KEY_NAS = "notification_assistant";
private static final int AVAILABLE = 1;
private final UserManager mUserManager;
private Fragment mFragment;
@@ -38,11 +40,8 @@ public class NotificationAssistantPreferenceController extends TogglePreferenceC
@VisibleForTesting
protected NotificationBackend mNotificationBackend;
public NotificationAssistantPreferenceController(Context context, NotificationBackend backend,
Fragment fragment, String preferenceKey) {
super(context, preferenceKey);
mNotificationBackend = backend;
mFragment = fragment;
public NotificationAssistantPreferenceController(Context context) {
super(context, KEY_NAS);
mUserManager = UserManager.get(context);
}
@@ -87,4 +86,13 @@ public class NotificationAssistantPreferenceController extends TogglePreferenceC
NotificationAssistantDialogFragment.newInstance(mFragment, cn);
dialogFragment.show(mFragment.getFragmentManager(), TAG);
}
public void setFragment(Fragment fragment) {
mFragment = fragment;
}
@VisibleForTesting
void setBackend(NotificationBackend backend) {
mNotificationBackend = backend;
}
}