Closed Bug 1259558 Opened 10 years ago Closed 10 years ago

Services.search.currentEngine is not honored by Firefox mobile

Categories

(Firefox for Android Graveyard :: General, defect)

45 Branch
defect
Not set
major

Tracking

(firefox45 affected)

RESOLVED WORKSFORME
Tracking Status
firefox45 --- affected

People

(Reporter: mkaply, Assigned: Margaret)

Details

If you use the Services.search API to set a currentEngine: Services.search.currentEngine = Services.search.getEngineByName("Bing"); it has no effect on the UI or in the Search settings. If you look at the currentEngine.name, it is set to the new image. Even if you restart Firefox, currentEngine.name is still set to the new engine, but in the UI, it's still using Yahoo.
> If you look at the currentEngine.name, it is set to the new image. image->engine. Argh.
Search engine is controlled via Java, see the Search*.java files in https://dxr.mozilla.org/mozilla-central/source/mobile/android/base/java/org/mozilla/gecko/home
How have we handled this in the past where there is a Firefox API that does something, but there is other work that needs to be done in Java? Does the Places API work for bookmarks?
(In reply to Kevin Brosnan [:kbrosnan] from comment #2) > Search engine is controlled via Java, see the Search*.java files in > https://dxr.mozilla.org/mozilla-central/source/mobile/android/base/java/org/ > mozilla/gecko/home This is not true. The Java SearchEnginerManager just mirrors the gecko search service. So using the JS API should work here, I'm not sure why it's not working for you. I don't have time to look into this right now, but Florian might be able to help here. (In reply to Mike Kaply [:mkaply] from comment #3) > How have we handled this in the past where there is a Firefox API that does > something, but there is other work that needs to be done in Java? We build a JS API if it's necessary. > Does the Places API work for bookmarks? No, the Places API does not work for bookmarks. We haven't had a need for this.
Flags: needinfo?(florian)
(In reply to Mike Kaply [:mkaply] from comment #3) > How have we handled this in the past where there is a Firefox API that does > something, but there is other work that needs to be done in Java? We typically avoid this situation: our usual approach on mobile is to replace Gecko's non-renderer functionality with better Android-native implementations, giving us a more responsive interface, less cruft, better platform integration, and a smaller Gecko. Login manager is one example: we implement nsILoginManagerStorage, and nsILoginManager works fine. We also offer an add-on API that covers some stuff: https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API > Does the Places API work for bookmarks? No. We maintain a GlobalHistory interface for stuff like link highlighting, but all of the real data is owned entirely by Java-side ContentProviders, and typically isn't exposed to Gecko at all.
Maybe this is a problem with bug 1237648? I don't see us using currentEngine anywhere in the mobile code.
I tried switching to defaultEngine just for fun, but it has the same problem.
This code appears to handle the default set case: https://dxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#6560 but what it does: https://dxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#6576 Doesn't appear to be related to setting the default search in the browser.
The potentially related bugs that come to mind are bug 1237648, and bug 1238516. But given that Services.search.currentEngine is correct after a restart, I don't think this is a problem with the search service.
Flags: needinfo?(florian)
tracking-fennec: --- → ?
I'll look for some time to investigate.
Assignee: nobody → margaret.leibovic
tracking-fennec: ? → 48+
I started to look into this, but I can't reproduce the problem on my local build. I'm setting the current engine via the remote console using the code snippet from comment 0. I'm even seeing the UI update without restarting, if I leave the search UI and come back. Do you have more information about what you were doing? Could this be a problem with the add-on you were trying to build?
Flags: needinfo?(mozilla)
Remote console was how I tried it. Maybe it's been fixed? I'll check again.
Flags: needinfo?(mozilla)
It's working on trunk and beta. And I verified it's NOT working on Firefox 45, so I'm not crazy. Sorry for the firedrill.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → WORKSFORME
tracking-fennec: 48+ → ---
Version: Trunk → 45 Branch
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.