Merge "Do not log Contextual card display when card is dismissed"
This commit is contained in:
@@ -39,12 +39,18 @@ public class CardContentProvider extends ContentProvider {
|
||||
|
||||
public static final String CARD_AUTHORITY = "com.android.settings.homepage.CardContentProvider";
|
||||
|
||||
public static final Uri URI = new Uri.Builder()
|
||||
public static final Uri REFRESH_CARD_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(CardContentProvider.CARD_AUTHORITY)
|
||||
.appendPath(CardDatabaseHelper.CARD_TABLE)
|
||||
.build();
|
||||
|
||||
public static final Uri DELETE_CARD_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(CardContentProvider.CARD_AUTHORITY)
|
||||
.appendPath(CardDatabaseHelper.CardColumns.CARD_DISMISSED)
|
||||
.build();
|
||||
|
||||
private static final String TAG = "CardContentProvider";
|
||||
/** URI matcher for ContentProvider queries. */
|
||||
private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
|
@@ -208,7 +208,7 @@ public class CardDatabaseHelper extends SQLiteOpenHelper {
|
||||
* Mark a specific ContextualCard with dismissal flag in the database to indicate that the
|
||||
* card has been dismissed.
|
||||
*
|
||||
* @param context Context
|
||||
* @param context Context
|
||||
* @param cardName The card name of the ContextualCard which is dismissed by user.
|
||||
* @return The number of rows updated
|
||||
*/
|
||||
@@ -220,7 +220,7 @@ public class CardDatabaseHelper extends SQLiteOpenHelper {
|
||||
final String[] selectionArgs = {cardName};
|
||||
final int rowsUpdated = database.update(CARD_TABLE, values, selection, selectionArgs);
|
||||
database.close();
|
||||
context.getContentResolver().notifyChange(CardContentProvider.URI, null);
|
||||
context.getContentResolver().notifyChange(CardContentProvider.DELETE_CARD_URI, null);
|
||||
return rowsUpdated;
|
||||
}
|
||||
}
|
||||
|
@@ -59,13 +59,16 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
private final ContentObserver mObserver = new ContentObserver(
|
||||
new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
if (isStarted()) {
|
||||
mNotifyUri = uri;
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
Uri mNotifyUri;
|
||||
private Context mContext;
|
||||
|
||||
ContextualCardLoader(Context context) {
|
||||
@@ -77,7 +80,10 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
@Override
|
||||
protected void onStartLoading() {
|
||||
super.onStartLoading();
|
||||
mContext.getContentResolver().registerContentObserver(CardContentProvider.URI,
|
||||
mNotifyUri = null;
|
||||
mContext.getContentResolver().registerContentObserver(CardContentProvider.REFRESH_CARD_URI,
|
||||
false /*notifyForDescendants*/, mObserver);
|
||||
mContext.getContentResolver().registerContentObserver(CardContentProvider.DELETE_CARD_URI,
|
||||
false /*notifyForDescendants*/, mObserver);
|
||||
}
|
||||
|
||||
@@ -156,10 +162,12 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
// Two large cards
|
||||
return visibleCards;
|
||||
} finally {
|
||||
//TODO(b/121196921): Should not call this if user click dismiss
|
||||
final ContextualCardFeatureProvider contextualCardFeatureProvider =
|
||||
FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
|
||||
contextualCardFeatureProvider.logContextualCardDisplay(visibleCards, hiddenCards);
|
||||
if (!CardContentProvider.DELETE_CARD_URI.equals(mNotifyUri)) {
|
||||
final ContextualCardFeatureProvider contextualCardFeatureProvider =
|
||||
FeatureFactory.getFactory(mContext)
|
||||
.getContextualCardFeatureProvider(mContext);
|
||||
contextualCardFeatureProvider.logContextualCardDisplay(visibleCards, hiddenCards);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -118,7 +118,8 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
sliceLiveData.observe(mLifecycleOwner, slice -> {
|
||||
if (slice == null) {
|
||||
Log.w(TAG, "Slice is null");
|
||||
mContext.getContentResolver().notifyChange(CardContentProvider.URI, null);
|
||||
mContext.getContentResolver().notifyChange(CardContentProvider.REFRESH_CARD_URI,
|
||||
null);
|
||||
return;
|
||||
} else {
|
||||
//TODO(b/120629936): Take this out once blank card issue is fixed.
|
||||
|
Reference in New Issue
Block a user