Nothing Special   »   [go: up one dir, main page]

Page MenuHomePhabricator

Unable to trigger search in SearchActivity by intent
Closed, ResolvedPublic1 Estimated Story Points

Description

Steps to reproduce

  1. Install Wikipedia android app with version 2.7.50431 or above
  2. Run any of the following command s
adb shell am start -a android.intent.action.SEND -f 32768 -t text/plain -n org.wikipedia/.search.SearchActivity -e android.intent.extra.TEXT example
adb shell am start -a android.intent.action.PROCESS_TEXT -f 32768 -t text/plain -n org.wikipedia/.search.SearchActivity -e android.intent.extra.PROCESS_TEXT example

Expected results

I expected to be navigated to SearchActivity with inflated SearchFragment which would trigger the search on the query supplied in the extra parameters, then show the results of the search without any further interaction. This was working in Wikipedia app 2.7.50428 and before.

Actual results

I'm navigated to SearchActivity with inflated SearchFragment the query is being put into search bar but the search is not triggered and no results are shown

Stack trace

(Optional logcat output)

Adidional dev info

I was able to fix the bug with the following hack but it lacks the code quality to be submitted in PR.

class SearchResultsViewModel : ViewModel() {

    private val batchSize = 20
    private val delayMillis = 200L
    private val totalResults = mutableListOf<SearchResult>()
    var resultsCount = mutableListOf<Int>()
    @Volatile var searchTerm: String? = null
    var languageCode: String? = null

    @OptIn(FlowPreview::class) // TODO: revisit if the debounce method changed.
    val searchResultsFlow = Pager(PagingConfig(pageSize = batchSize, initialLoadSize = batchSize)) {
        SearchResultsPagingSource({ searchTerm }, { languageCode }, resultsCount, totalResults)
...
    class SearchResultsPagingSource(
            val searchTermInvo: () -> String?,
            val languageCodeInvo: () -> String?,
            var resultsCount: MutableList<Int>?,
            var totalResults: MutableList<SearchResult>?
    ) : PagingSource<MwQueryResponse.Continuation, SearchResult>() {

        private var prefixSearch = true

        override suspend fun load(params: LoadParams<MwQueryResponse.Continuation>): LoadResult<MwQueryResponse.Continuation, SearchResult> {
            return try {
                val searchTerm = searchTermInvo.invoke()
                val languageCode = languageCodeInvo.invoke()

Environments observed

App version: 2.7.50431, 2.7.50437
Android OS versions: 13
Device model: OnePlus 9 Pro
Device language: en_EN

Event Timeline

Dbrant triaged this task as Medium priority.
Dbrant subscribed.

Good catch -- this should be a pretty simple fix.

@Psrokowski - Hello, I was attempting to reproduce this one to verify the fix, but I am having some trouble running the command. If you have some time, could you please install this beta version of the Android App and let us know if it appears to be fixed?

The APK - https://releases.wikimedia.org/mobile/android/wikipedia/betas/wikipedia-2.7.50440-beta-2023-04-19.apk

The APK posted is build in beta variant which doesn't serves the intents mentioned in adb commands above.
To test this I've checked out the commit on the master which includes the fix:

git checkout 6a32c8f0eb4ec26c828e840a3e5a26ffac40749b

I've build the APK in AS in prodDebug and installed on OnePlus 7T.

Run the command to launch intent:

adb shell am start -a android.intent.action.SEND -f 32768 -t text/plain -n org.wikipedia/.search.SearchActivity -e android.intent.extra.TEXT example

The fix works. Attaching viedo of testing -