我尝试从https://github.com/LineageOS/android_packages_apps_Jelly/blob/lineage-16.0/app/src/main/res/values/search_engines.xml覆盖两个 XML 字符串 [] 内容:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2017 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string-array name="pref_search_engine_entries" translatable="false">
<item>Baidu</item>
<item>Bing</item>
<item>DuckDuckGo</item>
<item>Google</item>
<item>Google encrypted</item>
<item>Yahoo</item>
<item>Yandex</item>
</string-array>
<string-array name="pref_search_engine_entryvalues" translatable="false">
<item>https://www.baidu.com/s?wd={searchTerms}</item>
<item>https://www.bing.com/search?q={searchTerms}</item>
<item>https://duckduckgo.com/?q={searchTerms}</item>
<item>https://google.com/search?ie=UTF-8&source=android-browser&q={searchTerms}</item>
<item>https://encrypted.google.com/search?q={searchTerms}</item>
<item>https://search.yahoo.com/p={searchTerms}</item>
<item>https://yandex.com/?q={searchTerms}</item>
</string-array>
</resources>
to:(照顾鸭鸭)
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2017 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string-array name="pref_search_engine_entries" translatable="false">
<item>Baidu</item>
<item>Bing</item>
<item>DuckDuckGo</item>
<item>Ecosia</item>
<item>Google</item>
<item>Google encrypted</item>
<item>Yahoo</item>
<item>Yandex</item>
</string-array>
<string-array name="pref_search_engine_entryvalues" translatable="false">
<item>https://www.baidu.com/s?wd={searchTerms}</item>
<item>https://www.bing.com/search?q={searchTerms}</item>
<item>https://duckduckgo.com/?q={searchTerms}</item>
<item>https://www.ecosia.org/search?q={searchTerms}
<item>https://google.com/search?ie=UTF-8&source=android-browser&q={searchTerms}</item>
<item>https://encrypted.google.com/search?q={searchTerms}</item>
<item>https://search.yahoo.com/p={searchTerms}</item>
<item>https://yandex.com/?q={searchTerms}</item>
</string-array>
</resources>
我的代码:
package org.nift4.xposed.misc;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import static de.robv.android.xposed.XposedHelpers.*;
import de.robv.android.xposed.XposedBridge;
public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResources
{
@Override
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable
{
if (resparam.packageName.equals("org.lineageos.jelly")) {
XposedBridge.log("found jelly '" + resparam.packageName + "'");
resparam.res.setReplacement("org.lineageos.jelly", "string-array", "pref_search_engine_entries", new String[]{"Baidu", "Bing", "DuckDuckGo", "Ecosia", "Google", "Google encrypted", "Yahoo", "Yandex"});
resparam.res.setReplacement("org.lineageos.jelly", "string-array", "pref_search_engine_entryvalues", new String[]{"https://www.baidu.com/s?wd={searchTerms}", "https://www.bing.com/search?q={searchTerms}", "https://duckduckgo.com/?q={searchTerms}", "https://www.ecosia.org/search?q={searchTerms}", "https://google.com/search?ie=UTF-8&source=android-browser&q={searchTerms}", "https://encrypted.google.com/search?q={searchTerms}", "https://search.yahoo.com/p={searchTerms}", "https://yandex.com/?q={searchTerms}"});
}
}
@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
}
}
错误:
09-27 21:00:45.302 23339 23339 I EdXposed-Bridge: found jelly 'org.lineageos.jelly'
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: android.content.res.Resources$NotFoundException: org.lineageos.jelly:string-array/pref_search_engine_entries
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.content.res.XResources.setReplacement(XResources.java:503)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at org.nift4.xposed.misc.Main.handleInitPackageResources(Main.java:19)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at de.robv.android.xposed.IXposedHookInitPackageResources$Wrapper.handleInitPackageResources(IXposedHookInitPackageResources.java:37)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at de.robv.android.xposed.callbacks.XC_InitPackageResources.call(XC_InitPackageResources.java:55)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:117)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at de.robv.android.xposed.XposedInit.cloneToXResources(XposedInit.java:288)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at de.robv.android.xposed.XposedInit.access$000(XposedInit.java:61)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at de.robv.android.xposed.XposedInit$2.afterHookedMethod(XposedInit.java:146)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at de.robv.android.xposed.XC_MethodHook.callAfterHookedMethod(XC_MethodHook.java:68)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.swift.sandhook.xposedcompat.hookstub.HookStubManager.hookBridge(HookStubManager.java:313)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.swift.sandhook.xposedcompat.hookstub.MethodHookerStubs64.stub_hook_0(MethodHookerStubs64.java:558)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.app.ResourcesManager.getResources(ResourcesManager.java:870)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.app.LoadedApk.getResources(LoadedApk.java:1029)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5798)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at java.lang.reflect.Method.invoke(Native Method)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.swift.sandhook.SandHook.callOriginMethod(SandHook.java:176)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.swift.sandhook.SandHook.callOriginMethod(SandHook.java:154)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.swift.sandhook.xposedcompat.hookstub.HookStubManager.hookBridge(HookStubManager.java:299)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.swift.sandhook.xposedcompat.hookstub.MethodHookerStubs64.stub_hook_0(MethodHookerStubs64.java:198)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.app.ActivityThread.access$1100(ActivityThread.java:200)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.os.Handler.dispatchMessage(Handler.java:106)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.os.Looper.loop(Looper.java:193)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at android.app.ActivityThread.main(ActivityThread.java:6718)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at java.lang.reflect.Method.invoke(Native Method)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
09-27 21:00:45.304 23339 23339 E EdXposed-Bridge: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
我试图覆盖其中的值search_engines.xml
以将 Ecosia 添加到 Jelly 浏览器。
但是上面的错误总是抛出,果冻浏览器可以工作,但不知道 Ecosia。
我错了什么?