Merge "Wrap old search index update logic behind FeatureProvider."

This commit is contained in:
TreeHugger Robot
2017-01-06 19:13:06 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 6 deletions

View File

@@ -462,10 +462,7 @@ public class SettingsActivity extends SettingsDrawerActivity
if (mIsShowingDashboard) {
// Run the Index update only if we have some space
if (!Utils.isLowStorage(this)) {
long indexStartTime = System.currentTimeMillis();
Index.getInstance(getApplicationContext()).update();
if (DEBUG_TIMING) Log.d(LOG_TAG, "Index.update() took "
+ (System.currentTimeMillis() - indexStartTime) + " ms");
mSearchFeatureProvider.updateIndex(getApplicationContext());
} else {
Log.w(LOG_TAG, "Cannot update the Indexer as we are running low on storage space!");
}

View File

@@ -19,19 +19,21 @@ package com.android.settings.search2;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.android.settings.R;
import com.android.settings.search.Index;
import com.android.settings.applications.PackageManagerWrapperImpl;
import com.android.settings.search.Index;
/**
* FeatureProvider for the refactored search code.
*/
public class SearchFeatureProviderImpl implements SearchFeatureProvider {
private static final String TAG = "SearchFeatureProvider";
private DatabaseIndexingManager mDatabaseIndexingManager;
@Override
@@ -81,10 +83,12 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {
@Override
public void updateIndex(Context context) {
long indexStartTime = System.currentTimeMillis();
if (isEnabled(context)) {
getIndexingManager(context).update();
} else {
Index.getInstance(context).update();
}
Log.d(TAG, "Index.update() took " + (System.currentTimeMillis() - indexStartTime) + " ms");
}
}