Adding setting suggestion ranker.

Test: RunSettingsGoogleRoboTests
This is currently behind a flag and it is no-op CL.

Change-Id: Ieed3e5a9c3c2fbb0ce1bfea77c588b04778540eb
This commit is contained in:
Soroosh Mariooryad
2017-01-17 18:19:41 -08:00
parent 88c0364ace
commit b1922dbc39
9 changed files with 663 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ public class MetricsFeatureProviderImpl implements MetricsFeatureProvider {
protected void installLogWriters() {
mLoggerWriters.add(new EventLogWriter());
mLoggerWriters.add(new SettingSuggestionsLogWriter());
}
@Override

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.core.instrumentation;
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.logging.MetricsLogger;
import com.android.settings.suggestions.EventStore;
/**
* {@link LogWriter} that writes setting suggestion related logs.
*/
public class SettingSuggestionsLogWriter implements LogWriter {
private EventStore mEventStore;
@Override
public void visible(Context context, int category) {
}
@Override
public void hidden(Context context, int category) {
}
@Override
public void action(Context context, int category) {
}
@Override
public void action(Context context, int category, int value) {
}
@Override
public void action(Context context, int category, boolean value) {
}
@Override
public void action(Context context, int category, String pkg) {
if (mEventStore == null) {
mEventStore = new EventStore(context);
}
switch (category) {
case MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION:
mEventStore.writeEvent(pkg, EventStore.EVENT_SHOWN);
break;
case MetricsEvent.ACTION_SETTINGS_DISMISS_SUGGESTION:
mEventStore.writeEvent(pkg, EventStore.EVENT_DISMISSED);
break;
case MetricsEvent.ACTION_SETTINGS_SUGGESTION:
mEventStore.writeEvent(pkg, EventStore.EVENT_CLICKED);
break;
}
}
@Override
public void count(Context context, String name, int value) {
}
@Override
public void histogram(Context context, String name, int bucket) {
}
}