Pass component name into SuggestionFeatureProvider
So that the provider can be used for more than one suggestion. Test: Robolectric test for implementation of the provider Bug: 62039057 Change-Id: Ibea41ea6d98e67c55ec157556675e854f3ea31c4
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.settings.dashboard.suggestions;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.suggestions.SuggestionParser;
|
||||
@@ -31,11 +33,11 @@ public interface SuggestionFeatureProvider {
|
||||
*/
|
||||
boolean isSmartSuggestionEnabled(Context context);
|
||||
|
||||
/** Return true if className is the name of a class of one of your newly added suggestion. */
|
||||
boolean isPresent(String className);
|
||||
/** Return true if {@code suggestion} is managed by this provider. */
|
||||
boolean isPresent(@NonNull ComponentName suggestion);
|
||||
|
||||
/** Return true if the suggestion has already been completed and does not need to be shown */
|
||||
boolean isSuggestionCompleted(Context context);
|
||||
boolean isSuggestionCompleted(Context context, @NonNull ComponentName suggestion);
|
||||
|
||||
/**
|
||||
* Ranks the list of suggestions in place.
|
||||
|
@@ -16,8 +16,10 @@
|
||||
|
||||
package com.android.settings.dashboard.suggestions;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
@@ -42,12 +44,12 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent(String className) {
|
||||
public boolean isPresent(@NonNull ComponentName component) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuggestionCompleted(Context context) {
|
||||
public boolean isSuggestionCompleted(Context context, @NonNull ComponentName component) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import android.app.KeyguardManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.WallpaperManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.provider.Settings;
|
||||
@@ -56,7 +57,8 @@ public class SuggestionsChecks {
|
||||
}
|
||||
|
||||
public boolean isSuggestionComplete(Tile suggestion) {
|
||||
String className = suggestion.intent.getComponent().getClassName();
|
||||
ComponentName component = suggestion.intent.getComponent();
|
||||
String className = component.getClassName();
|
||||
if (className.equals(ZenModeAutomationSuggestionActivity.class.getName())) {
|
||||
return hasEnabledZenAutoRules();
|
||||
} else if (className.equals(WallpaperSuggestionActivity.class.getName())) {
|
||||
@@ -79,8 +81,8 @@ public class SuggestionsChecks {
|
||||
|
||||
SuggestionFeatureProvider provider =
|
||||
FeatureFactory.getFactory(mContext).getSuggestionFeatureProvider(mContext);
|
||||
if (provider != null && provider.isPresent(className)) {
|
||||
return provider.isSuggestionCompleted(mContext);
|
||||
if (provider != null && provider.isPresent(component)) {
|
||||
return provider.isSuggestionCompleted(mContext, component);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user