Jimmy,
Your app cannot use SystemProperties.put() unless it has one of the
few specific UID. You can see this in system/core/init/
property_service.c:
struct {
const char *prefix; unsigned int uid; unsigned int gid;
} property_perms[] = {
...
{ "hw.", AID_SYSTEM, 0 },
{ "sys.", AID_SYSTEM, 0 },
{ "service.", AID_SYSTEM, 0 },
{ "dhcp.", AID_DHCP, 0 },
{ "vpn.", AID_SYSTEM, 0 },
{ "vpn.", AID_VPN, 0 },
{ "debug.", AID_SHELL, 0 },
{ "log.", AID_SHELL, 0 },
....
{ NULL, 0, 0 }
};
If you're building your own platform, there is probably a painful way
to modify property_service.c to do what you want, but I would not
recommend it.
There is actually a little known method in the Andorid SDK that allows
any APK to create a world readable file (it can be read by any APKs).
So if you have one "main" APK that creates some shared settings, and
other APKs need to read these settings, you can try this:
SharedPreferences pref = mActivity.getSharedPreferences("foo",
Context.MODE_WORLD_READABLE);
SharedPreferences.Editor editor = pref.edit();
editor.putInt("junk", 0);
editor.commit();
File world_readable_file = mActivity.getFilesDir().getParent() + "/
shared_prefs/foo.xml";
FileOutputStream fout = new FileOutputStream(world_readable_file);
fout.write(....)
Other APKs can simply read this file using
FileInputStream fin = new FileInputStream("/data/data/
com.foobar.main/shared_prefs/foo.xml");
Hope this helps
On Dec 22, 7:54 pm, Jiangyun Li <
lijy...@gmail.com> wrote:
> Hi Frank & Raymond,
>
> My case is only to provide a simple information, actually a string.
> According to this string, other APKs have different appearance. With your
> recommendations there are many solutions:
> 1. Intent mechanism: First other APKs send an intent to fetch the
> information string, then I send back an intent with it; I think this way is
> a little trivial and not efficient;
> 2. AIDL mechanism: As my module is just an app, actually just a homescreen,
> modified from android default Launcher app, so I donot want to do much
> modification to the architecture of it;
> 3. SystemProperties mechanism: I think this is the simplest way, I set and
> update the property in my module, the other APKs could get the information
> string at any time as needed;
>
> When I changed the information string, Intent is a good choice to notify
> other APKs to change their appearance. On the other side, When some APK
> tries to get the information string so as to display corresponding
> appearance at the first time it runs, I think SystemProperties is a batter
> choice, as only one record, more efficient;
>
> BestRegards
> JimmyLi
>
> 2010/12/22 Raymond.Wen <
rx.wen...@gmail.com>
>
>
>
>
>
>
>
> > Hi Frank,
>
> > I found the number from the source code. Be accurately, it's 247.
>
> > By external usage, I mean a standard application made by 3rd party. It's
> > not good for an application intended to run different devices to rely on
> > unstable apis. Of course, it's a different story if Jimmy is working on his
> > own board or some platform stuffs.
>
> > Yes, I agree that this api is not likely to change. But I'd prefer to do
> > things in the way that google guarantees to be stable. Anyway, we don't want
> > to take the risk, unless we have no better choice.
>
> > Best Regards,
> > Raymond Wen
>
> >
http://rxwen.blogspot.com
>
> >> > >
http://groups.google.com/group/android-platform?hl=en.-Zitierten Text
> >> ausblenden -
>
> >> > - Zitierten Text anzeigen -
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "android-platform" group.
> >> To post to this group, send email to
android-...@googlegroups.com.
> >> To unsubscribe from this group, send email to