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
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;
*/
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.
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;
}
@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;
}
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;
}
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())) {
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;