Loading src/com/android/settings/search/SearchFeatureProvider.java +7 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,13 @@ public interface SearchFeatureProvider { return false; } /** * @return smart ranking timeout in milliseconds. */ default long smartSearchRankingTimeoutMs(Context context) { return 300L; } /** * Prepare for search ranking predictions to avoid latency on the first prediction call. */ Loading src/com/android/settings/search/SearchResultsAdapter.java +2 −4 Original line number Diff line number Diff line Loading @@ -64,9 +64,6 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder> @VisibleForTesting static final int MSG_RANKING_TIMED_OUT = 1; // TODO(b/38197948): Tune this timeout based on latency of static and async rankings. Also, we // should add a gservices flag to control this. private static final long RANKING_TIMEOUT_MS = 300; private final SearchFragment mFragment; private final Context mContext; private final List<SearchResult> mSearchResults; Loading Loading @@ -245,8 +242,9 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder> mAsyncRankingState = PENDING_RESULTS; mSearchFeatureProvider.cancelPendingSearchQuery(mContext); final Handler handler = getHandler(); final long timeoutMs = mSearchFeatureProvider.smartSearchRankingTimeoutMs(mContext); handler.sendMessageDelayed( handler.obtainMessage(MSG_RANKING_TIMED_OUT), RANKING_TIMEOUT_MS); handler.obtainMessage(MSG_RANKING_TIMED_OUT), timeoutMs); mSearchFeatureProvider.querySearchResults(mContext, query, this); } else { mAsyncRankingState = DISABLED; Loading tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public class SearchResultsAdapterTest { mLoaderClassName = DatabaseResultLoader.class.getName(); when(mFragment.getContext()).thenReturn(mMockContext); when(mMockContext.getApplicationContext()).thenReturn(mContext); when(mSearchFeatureProvider.smartSearchRankingTimeoutMs(any(Context.class))) .thenReturn(300L); mAdapter = new SearchResultsAdapter(mFragment, mSearchFeatureProvider); } Loading Loading
src/com/android/settings/search/SearchFeatureProvider.java +7 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,13 @@ public interface SearchFeatureProvider { return false; } /** * @return smart ranking timeout in milliseconds. */ default long smartSearchRankingTimeoutMs(Context context) { return 300L; } /** * Prepare for search ranking predictions to avoid latency on the first prediction call. */ Loading
src/com/android/settings/search/SearchResultsAdapter.java +2 −4 Original line number Diff line number Diff line Loading @@ -64,9 +64,6 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder> @VisibleForTesting static final int MSG_RANKING_TIMED_OUT = 1; // TODO(b/38197948): Tune this timeout based on latency of static and async rankings. Also, we // should add a gservices flag to control this. private static final long RANKING_TIMEOUT_MS = 300; private final SearchFragment mFragment; private final Context mContext; private final List<SearchResult> mSearchResults; Loading Loading @@ -245,8 +242,9 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder> mAsyncRankingState = PENDING_RESULTS; mSearchFeatureProvider.cancelPendingSearchQuery(mContext); final Handler handler = getHandler(); final long timeoutMs = mSearchFeatureProvider.smartSearchRankingTimeoutMs(mContext); handler.sendMessageDelayed( handler.obtainMessage(MSG_RANKING_TIMED_OUT), RANKING_TIMEOUT_MS); handler.obtainMessage(MSG_RANKING_TIMED_OUT), timeoutMs); mSearchFeatureProvider.querySearchResults(mContext, query, this); } else { mAsyncRankingState = DISABLED; Loading
tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public class SearchResultsAdapterTest { mLoaderClassName = DatabaseResultLoader.class.getName(); when(mFragment.getContext()).thenReturn(mMockContext); when(mMockContext.getApplicationContext()).thenReturn(mContext); when(mSearchFeatureProvider.smartSearchRankingTimeoutMs(any(Context.class))) .thenReturn(300L); mAdapter = new SearchResultsAdapter(mFragment, mSearchFeatureProvider); } Loading