Tron metrics for special permissions

Added tron metrics for the following special permissions:
Battery optimisation
 - APP_SPECIAL_PERMISSION_BATTERY_ALLOW
 - APP_SPECIAL_PERMISSION_BATTERY_DENY
Device administrators
 - APP_SPECIAL_PERMISSION_ADMIN_ALLOW (when checked)
 - APP_SPECIAL_PERMISSION_ADMIN_DENY (when unchecked)
Do not disturb access
 - APP_SPECIAL_PERMISSION_DND_ALLOW
 - APP_SPECIAL_PERMISSION_DND_DENY
Daw over other apps
 - APP_SPECIAL_PERMISSION_APPDRAW_ALLOW
 - APP_SPECIAL_PERMISSION_APPDRAW_DENY
VR helper services
 - APP_SPECIAL_PERMISSION_VRHELPER_ALLOW
 - APP_SPECIAL_PERMISSION_VRHELPER_DENY
Modify system settings
 - APP_SPECIAL_PERMISSION_SETTINGS_CHANGE_ALLOW
 - APP_SPECIAL_PERMISSION_SETTINGS_CHANGE_DENY
Notification access
 - APP_SPECIAL_PERMISSION_NOTIVIEW_ALLOW
 - APP_SPECIAL_PERMISSION_NOTIVIEW_DENY
Premium SMS access
 - APP_SPECIAL_PERMISSION_PREMIUM_SMS_ALWAYS_ALLOW
 - APP_SPECIAL_PERMISSION_PREMIUM_SMS_ASK
 - APP_SPECIAL_PERMISSION_PREMIUM_SMS_DENY
Unrestricted data access
 - APP_SPECIAL_PERMISSION_UNL_DATA_ALLOW
 - APP_SPECIAL_PERMISSION_UNL_DATA_DENY
Usage access
 - APP_SPECIAL_PERMISSION_USAGE_VIEW_ALLOW
 - APP_SPECIAL_PERMISSION_USAGE_VIEW_DENY

Test: Manual + make RunSettingsRoboTests
Bug: 31008660
Change-Id: Id977e2c9f5aa811a2b0af036372b72c684621435
This commit is contained in:
Fyodor Kupolov
2017-01-13 15:14:24 -08:00
parent ce6bf59a9a
commit 2328946b58
21 changed files with 772 additions and 4 deletions

View File

@@ -29,9 +29,12 @@ import android.provider.Settings;
import android.service.notification.NotificationListenerService;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.utils.ManagedServiceSettings;
public class NotificationAccessSettings extends ManagedServiceSettings {
@@ -68,6 +71,7 @@ public class NotificationAccessSettings extends ManagedServiceSettings {
}
protected boolean setEnabled(ComponentName service, String title, boolean enable) {
logSpecialPermissionChange(enable, service.getPackageName());
if (!enable) {
if (!mServiceListing.isEnabled(service)) {
return true; // already disabled
@@ -82,6 +86,14 @@ public class NotificationAccessSettings extends ManagedServiceSettings {
}
}
@VisibleForTesting
void logSpecialPermissionChange(boolean enable, String packageName) {
int logCategory = enable ? MetricsEvent.APP_SPECIAL_PERMISSION_NOTIVIEW_ALLOW
: MetricsEvent.APP_SPECIAL_PERMISSION_NOTIVIEW_DENY;
FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider().action(getContext(),
logCategory, packageName);
}
private static void disable(final Context context, final NotificationAccessSettings parent,
final ComponentName cn) {
parent.mServiceListing.setEnabled(cn, false);