Android Web browser homepage

回眸只為那壹抹淺笑 提交于 2019-12-04 20:25:17

问题


I have seen several apps and advertising networks like startapp changing the android web browser homepage by code. How is this possible?

I have taken a look at the startapp sdk but i have not managed to find the part where they change the homepage.

I have also taken a look at the BrowserSettings in com.android.browser.BrowserSettings

In BrowserSettings, there is a interface called setHomepage(Context, String).

public void setHomePage(Context context, String url) {
    Editor ed = PreferenceManager.
            getDefaultSharedPreferences(context).edit();
    ed.putString(PREF_HOMEPAGE, url);
    ed.commit();
    homeUrl = url;
}

I dont know a lot java/android, so correct me if i am wrong: The setHomepage() is not declared static so it can not be called from other activities. So i can not use this.

I cant see any Mode applied to the Shared Preferences so it means that it will by default take Private as is Mode and i cant edit the Shared Preferences or ?

Some people have said that it may would be possible to do with contentProvider/Resolver.

Link for BrowserSettings.java

Any help or thoughts would be appreciated:)


回答1:


I'm with Diane HackBorn (Google's Android Engineer) on this one: this shouldn't be possible, as it would be a platform security flaw.

If it happens to be possible, would be through some sort of hack (i.e.: an App with root access that can write into the Browser app Settings file directly).




回答2:


I see that you mentioned startapp. I have looked through their decompiled SDK but i cant find anything about the "changing homepage part".

Also i know that they do this but i cant find it in the SDK. Maybe somebody with better understanding for android can take a look at it. I have a android phone with 2.2 without root access and they managed to change the homepage.




回答3:


With root permissions, you can go to the /data/app/com.android.browser/shared_prefs

you have there the XML file for the shared preferences.

You just need to edit PREF_HOMEPAGE xml entry.

without root it is impossible, since you will need root permissions to access that directory.



来源:https://stackoverflow.com/questions/12352452/android-web-browser-homepage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!