8

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:)

Anonym..
  • 333
  • 1
  • 5
  • 18
  • Is it because you wan't to launch the browser on a certain page? – Anders Metnik Sep 10 '12 at 13:15
  • @AndersMetnik I dont really understand what you mean. I want to set the homepage of the browser by code. Not to launch a url. – Anonym.. Sep 10 '12 at 13:37
  • You mean you want to set the default homepage ? – Anders Metnik Sep 11 '12 at 06:24
  • Yes, i want to be able to set the "default" homepage by code like the user can in the preference activity of the browser – Anonym.. Sep 11 '12 at 12:27
  • 1
    Doubt you are able to change another programs settings, it would surely be a hack if you did. If they have added such an option to some browsers it will be done by an intent – Anders Metnik Sep 11 '12 at 14:16
  • 1
    Do you have any example that I can download and check if they change the default home page? I don't think it's possible. – Akash Kava Sep 19 '12 at 07:06
  • @AkashKava Yes, have a look at this link: https://play.google.com/store/apps/details?id=ch.wanddstudios.startapp – Anonym.. Sep 20 '12 at 15:42
  • @Anonym..: The app you link to here does not change the home page of Browser or Chrome on a Nexus S running Android 4.1. – CommonsWare Oct 06 '12 at 13:25
  • @CommonsWare hmm, I have tried it on htc aria 2.2 and Samsung S2 running 4.0.4. Both of these are non-rooted. The application manage to change the homepage. Be aware that there is a delay of the changin. It takes about 20-30 before the changing take place. Any idea on how this is done? – Anonym.. Oct 08 '12 at 20:24
  • With luck, it has simply been blocked. Apps should not be able to attack other apps this way. – CommonsWare Oct 08 '12 at 20:25
  • Yes, i totally agreed. If you have time to look at a file and see if you find the anwser i will give u 100 rep. Curious :) http://www.mediafire.com/?j4bqrguuqha4403 – Anonym.. Oct 08 '12 at 20:33

3 Answers3

3

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).

tinsukE
  • 930
  • 9
  • 20
1

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.

AndDev
  • 316
  • 1
  • 2
  • 7
0

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.

cprogcr
  • 469
  • 2
  • 7
  • 21