Create settings screen for Notification Assistant

Test: this atest
Test: manual: change assistant and "adb shell dumpsys notification"
Test: manual: verify persistance through reboot (including none)

Fixes:120852765
Change-Id: Ie4516c3339246d66d7b6719ac5dd1d65c4d03b57
This commit is contained in:
Fabian Kozynski
2019-02-20 12:55:10 -05:00
parent 569aa2594e
commit 01b2a635e9
11 changed files with 447 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.app.usage.IUsageStatsManager;
import android.app.usage.UsageEvents;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -410,6 +411,29 @@ public class NotificationBackend {
}
}
public ComponentName getAllowedNotificationAssistant() {
try {
return sINM.getAllowedNotificationAssistant();
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return null;
}
}
public boolean setNotificationAssistantGranted(ComponentName cn) {
try {
sINM.setNotificationAssistantAccessGranted(cn, true);
if (cn == null) {
return sINM.getAllowedNotificationAssistant() == null;
} else {
return cn.equals(sINM.getAllowedNotificationAssistant());
}
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return false;
}
}
/**
* NotificationsSentState contains how often an app sends notifications and how recently it sent
* one.