import android.content.Context;
import android.content.SharedPreferences;
import android.service.settings.suggestions.Suggestion;
-import android.util.Pair;
+
+import androidx.annotation.NonNull;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.suggestions.SuggestionControllerMixinCompat;
import java.util.List;
-import androidx.annotation.NonNull;
-
/** Interface should be implemented if you have added new suggestions */
public interface SuggestionFeatureProvider {
*/
ComponentName getSuggestionServiceComponent();
- /**
- * Returns true if smart suggestion should be used instead of xml based SuggestionParser.
- */
- boolean isSmartSuggestionEnabled(Context context);
-
/** Return true if the suggestion has already been completed and does not need to be shown */
boolean isSuggestionComplete(Context context, @NonNull ComponentName suggestion);
*/
void dismissSuggestion(Context context, SuggestionControllerMixinCompat suggestionMixin,
Suggestion suggestion);
-
- /**
- * Returns common tagged data for suggestion logging.
- */
- Pair<Integer, Object>[] getLoggingTaggedData(Context context);
}
import android.content.SharedPreferences;
import android.service.settings.suggestions.Suggestion;
import android.util.Log;
-import android.util.Pair;
+
+import androidx.annotation.NonNull;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.Settings.NightDisplaySuggestionActivity;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollSuggestionActivity;
import com.android.settings.biometrics.fingerprint.FingerprintSuggestionActivity;
import java.util.List;
-import androidx.annotation.NonNull;
-
public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider {
private static final String TAG = "SuggestionFeature";
}
@Override
- public boolean isSmartSuggestionEnabled(Context context) {
- return false;
- }
-
- @Override
public boolean isSuggestionComplete(Context context, @NonNull ComponentName component) {
final String className = component.getClassName();
if (className.equals(WallpaperSuggestionActivity.class.getName())) {
suggestion.getId());
mixin.dismissSuggestion(suggestion);
}
-
- @Override
- public Pair<Integer, Object>[] getLoggingTaggedData(Context context) {
- final boolean isSmartSuggestionEnabled = isSmartSuggestionEnabled(context);
- return new Pair[] {Pair.create(
- MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED,
- isSmartSuggestionEnabled ? 1 : 0)};
- }
}
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.service.settings.suggestions.Suggestion;
-import android.util.Pair;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
assertThat(suggestions).hasSize(3);
}
-
- @Test
- public void testGetSmartSuggestionEnabledTaggedData_disabled() {
- assertThat(mProvider.getLoggingTaggedData(mContext)).asList().containsExactly(
- Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
- }
-
- @Test
- public void testGetSmartSuggestionEnabledTaggedData_enabled() {
- final SuggestionFeatureProvider provider = spy(mProvider);
- when(provider.isSmartSuggestionEnabled(any(Context.class))).thenReturn(true);
-
- assertThat(provider.getLoggingTaggedData(mContext)).asList().containsExactly(
- Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 1));
- }
}