am c9548c17
: Merge "Fix bug #15460001 "Cell broadcasts" setting search suggested in wifi only device though setting is not present" into lmp-preview-dev
* commit 'c9548c17471ff7d7826a769593250ca3467a2ba5': Fix bug #15460001 "Cell broadcasts" setting search suggested in wifi only device though setting is not present
This commit is contained in:
@@ -139,6 +139,8 @@ public class Index {
|
||||
// Max number of proposed suggestions
|
||||
private static final int MAX_PROPOSED_SUGGESTIONS = 5;
|
||||
|
||||
private static final String BASE_AUTHORITY = "com.android.settings";
|
||||
|
||||
private static final String EMPTY = "";
|
||||
private static final String NON_BREAKING_HYPHEN = "\u2011";
|
||||
private static final String HYPHEN = "-";
|
||||
@@ -160,6 +162,7 @@ public class Index {
|
||||
private final AtomicBoolean mIsAvailable = new AtomicBoolean(false);
|
||||
private final UpdateData mDataToProcess = new UpdateData();
|
||||
private Context mContext;
|
||||
private final String mBaseAuthority;
|
||||
|
||||
/**
|
||||
* A private class to describe the update data for the Index database
|
||||
@@ -190,15 +193,16 @@ public class Index {
|
||||
*/
|
||||
public static Index getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new Index(context);
|
||||
sInstance = new Index(context, BASE_AUTHORITY);
|
||||
} else {
|
||||
sInstance.setContext(context);
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public Index(Context context) {
|
||||
public Index(Context context, String baseAuthority) {
|
||||
mContext = context;
|
||||
mBaseAuthority = baseAuthority;
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
@@ -286,14 +290,15 @@ public class Index {
|
||||
try {
|
||||
final int baseRank = Ranking.getBaseRankForAuthority(authority);
|
||||
|
||||
final Context packageContext = mContext.createPackageContext(packageName, 0);
|
||||
final Context context = mBaseAuthority.equals(authority) ?
|
||||
mContext : mContext.createPackageContext(packageName, 0);
|
||||
|
||||
final Uri uriForResources = buildUriForXmlResources(authority);
|
||||
addIndexablesForXmlResourceUri(packageContext, packageName, uriForResources,
|
||||
addIndexablesForXmlResourceUri(context, packageName, uriForResources,
|
||||
SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS, baseRank);
|
||||
|
||||
final Uri uriForRawData = buildUriForRawData(authority);
|
||||
addIndexablesForRawDataUri(packageContext, packageName, uriForRawData,
|
||||
addIndexablesForRawDataUri(context, packageName, uriForRawData,
|
||||
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS, baseRank);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
@@ -1137,7 +1142,12 @@ public class Index {
|
||||
final int count = dataToUpdate.size();
|
||||
for (int n = 0; n < count; n++) {
|
||||
final SearchIndexableData data = dataToUpdate.get(n);
|
||||
indexOneSearchIndexableData(database, localeStr, data, nonIndexableKeys);
|
||||
try {
|
||||
indexOneSearchIndexableData(database, localeStr, data, nonIndexableKeys);
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG,
|
||||
"Cannot index: " + data.className + " for locale: " + localeStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
final long now = System.currentTimeMillis();
|
||||
|
Reference in New Issue
Block a user