How to create a content provider through user profiles?

For an embedded project based on the AOSP source, I have a large chunk of data in one (system) application, which should be available for other applications. Yes, I know: typical work for a content or service provider, but ... the same data (the same separate instance of this large fragment) should be available for applications on all PROFILES USERS on the device!

I already realized that Android offers the android: singleUser = "true" attribute for services, content providers and receivers, but it has an annoying side effect that it causes Android: exported = "false"! Therefore, I suggest that one of the solutions could be the presence of one content provider in my manifest using the android: singleUser = "true", and the second - android: exported = "true", and this second one asks for the actual data that the other application it may be necessary, but ... it seems so ugly in my case too - when an application with content providers and services already exists for single-user Android, this will require quite a few changes.

I also tried to mark my full (system) application as an android: persistent = "true", but this led to problems with access to some parts / data / data where a large piece of data is located (what I need to debug further go to the root cause) .

So my question is: is there a simple / recommended way to create a content provider (the same issue for services and receivers in one application) so that the application really acts as a single element for several users (not being a System Service, since we don’t want to affect system stability by running our stuff as part of SystemServer)?

+4
source share
2 answers

android: singleUser = "true" android: exported = "true" - , .

, ActivityManagerService ( isSingleton) , INTERACT_ACCROSS_USERS.

( , ), ( "LOCAL_PRIVILEGED_MODULE: = true" Android.mk). PackageParser "android: exported".

 if (sa.getBoolean(
        com.android.internal.R.styleable.AndroidManifestProvider_singleUser,
        false)) {
    p.info.flags |= ProviderInfo.FLAG_SINGLE_USER;
    if (p.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) {
        Slog.w(TAG, "Provider exported request ignored due to singleUser: " 
                + p.className + " at " + mArchiveSourcePath + " " 
                + parser.getPositionDescription());
        p.info.exported = false;
    }
}

. , .


UPDATE. , , , Android 5.0 . .

+8

= "" , singleUser = "true".

+1

All Articles