Add the impl for the ability to query non-public Slices

Apps get Settings Slices through onGetSliceDescendants(), so adding some
codes here to make us be capable returning non-public Slices. As these
SliceData come from slice_index.db, where SliceDatabaseAccessor is the
middleman for us to access those data, so adding a parameter in
getSliceUris() to determine what data should be returned.

Bug: 141088937
Test: robotests
Change-Id: I411eb1ff194b7c8915b9e7309c684046dbde29fb
This commit is contained in:
Yi-Ling Chuang
2019-11-21 14:48:14 +08:00
parent 1a359b5b22
commit d57e5a5d1a
7 changed files with 254 additions and 28 deletions

View File

@@ -88,16 +88,18 @@ public class SlicesDatabaseAccessor {
}
/**
* @return a list of Slice {@link Uri}s matching {@param authority}.
* @return a list of Slice {@link Uri}s based on their visibility {@param isPublicSlice } and
* {@param authority}.
*/
public List<Uri> getSliceUris(String authority) {
public List<Uri> getSliceUris(String authority, boolean isPublicSlice) {
verifyIndexing();
final List<Uri> uris = new ArrayList<>();
final String whereClause = IndexColumns.PUBLIC_SLICE + (isPublicSlice ? "=1" : "=0");
final SQLiteDatabase database = mHelper.getReadableDatabase();
final String[] columns = new String[]{IndexColumns.SLICE_URI};
try (final Cursor resultCursor = database.query(TABLE_SLICES_INDEX, columns,
null /* where */, null /* selection */, null /* groupBy */, null /* having */,
null /* orderBy */)) {
try (Cursor resultCursor = database.query(TABLE_SLICES_INDEX, columns,
whereClause /* where */, null /* selection */, null /* groupBy */,
null /* having */, null /* orderBy */)) {
if (!resultCursor.moveToFirst()) {
return uris;
}