Baidu seem to have moved their suggestions API as the old path
returns a 302 ("Moved Temporarily") error. After looking at
various sources, this one still works and returns the same
JSONArray.
A screenshot from my own browser will about the same implementation
for search suggestions proves that this works:
https://i.imgur.com/BcLiwBU.png
Change-Id: Ia8bdb59a68c7fd8c24146002d9bf09611eb57935
(cherry picked from commit d1945e2db132c4f682112af37cfb82a80205c5c0)
This ensures that mWebView has been initialized before accessing it.
Also, setUiMode calls applyThemeColor
Observed crash in logs without this patch:
05-10 20:43:53.341 12698 12698 D AndroidRuntime: Shutting down VM
05-10 20:43:53.342 12698 12698 E AndroidRuntime: FATAL EXCEPTION: main
05-10 20:43:53.342 12698 12698 E AndroidRuntime: Process: org.lineageos.jelly, PID: 12698
05-10 20:43:53.342 12698 12698 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.lineageos.jelly/org.lineageos.jelly.MainActivity}: kotlin.UninitializedPropertyAccessException: lateinit property mWebView has not been initialized
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3431)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5451)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5357)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7660)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: Caused by: kotlin.UninitializedPropertyAccessException: lateinit property mWebView has not been initialized
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at org.lineageos.jelly.MainActivity.applyThemeColor(MainActivity.kt:595)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at org.lineageos.jelly.MainActivity.changeUiMode(MainActivity.kt:756)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at org.lineageos.jelly.MainActivity.setUiMode(MainActivity.kt:719)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at org.lineageos.jelly.MainActivity.onCreate(MainActivity.kt:179)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8000)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7984)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
05-10 20:43:53.342 12698 12698 E AndroidRuntime: ... 13 more
05-10 20:43:53.346 1436 15067 I DropBoxManagerService: add tag=system_app_crash isTagEnabled=true flags=0x2
05-10 20:43:53.347 1436 2480 W ActivityTaskManager: Force finishing activity org.lineageos.jelly/.MainActivity
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
Change-Id: I4d18e6123759f70a14b00156f8794ef604b9981b
The KeyEvent parameter maybe null, state it in function declaration. Else leads to a crash when the feature is used.
Test:
- Open app, load a webpage.
- Use the "Find in page" from options menu.
- Enter a keyword into the search box, press search option on keyboard, app crashes
With this change, no crash is observed, and the searched terms are highlighted on the page.
Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/2165
Change-Id: Iad453173fa1417deb01de0b85cad8876ed68ccb1