Wrap old search index update logic behind FeatureProvider.

Change-Id: I31024d2e7900a90b4f7dc8cc81951bf6a0e533fa
Fix: 34123028
Test: RunSettingsRoboTests
This commit is contained in:
Fan Zhang
2017-01-06 09:18:59 -08:00
parent a8205bb528
commit a875924100
2 changed files with 7 additions and 6 deletions

View File

@@ -462,10 +462,7 @@ public class SettingsActivity extends SettingsDrawerActivity
if (mIsShowingDashboard) { if (mIsShowingDashboard) {
// Run the Index update only if we have some space // Run the Index update only if we have some space
if (!Utils.isLowStorage(this)) { if (!Utils.isLowStorage(this)) {
long indexStartTime = System.currentTimeMillis(); mSearchFeatureProvider.updateIndex(getApplicationContext());
Index.getInstance(getApplicationContext()).update();
if (DEBUG_TIMING) Log.d(LOG_TAG, "Index.update() took "
+ (System.currentTimeMillis() - indexStartTime) + " ms");
} else { } else {
Log.w(LOG_TAG, "Cannot update the Indexer as we are running low on storage space!"); 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.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.search.Index;
import com.android.settings.applications.PackageManagerWrapperImpl; import com.android.settings.applications.PackageManagerWrapperImpl;
import com.android.settings.search.Index;
/** /**
* FeatureProvider for the refactored search code. * FeatureProvider for the refactored search code.
*/ */
public class SearchFeatureProviderImpl implements SearchFeatureProvider { public class SearchFeatureProviderImpl implements SearchFeatureProvider {
private static final String TAG = "SearchFeatureProvider";
private DatabaseIndexingManager mDatabaseIndexingManager; private DatabaseIndexingManager mDatabaseIndexingManager;
@Override @Override
@@ -81,10 +83,12 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {
@Override @Override
public void updateIndex(Context context) { public void updateIndex(Context context) {
long indexStartTime = System.currentTimeMillis();
if (isEnabled(context)) { if (isEnabled(context)) {
getIndexingManager(context).update(); getIndexingManager(context).update();
} else { } else {
Index.getInstance(context).update(); Index.getInstance(context).update();
} }
Log.d(TAG, "Index.update() took " + (System.currentTimeMillis() - indexStartTime) + " ms");
} }
} }