Fix NPE in slice data generation

NPE will be occurred when clients gives invalid slice uri for Settings.
We have defined some rules in getPathData() and it will return null
object when the invalid uri was given. NPE will be happened in next.

Change-Id: I6ebadd4383aee6e69b1c2eb6c84071c961fd72a7
Fixes: 120259627
Test: robotests
This commit is contained in:
Yanting Yang
2018-11-30 17:58:45 +08:00
parent 0173c5f532
commit b8850fc679

View File

@@ -71,6 +71,9 @@ public class SlicesDatabaseAccessor {
*/
public SliceData getSliceDataFromUri(Uri uri) {
Pair<Boolean, String> pathData = SliceBuilderUtils.getPathData(uri);
if (pathData == null) {
throw new IllegalStateException("Invalid Slices uri: " + uri);
}
Cursor cursor = getIndexedSliceData(pathData.second /* key */);
return buildSliceData(cursor, uri, pathData.first /* isIntentOnly */);
}