GCX-HCI / tray

a SharedPreferences replacement for Android with multiprocess support
Apache License 2.0
2.29k stars 273 forks source link

ContentProvider on a customized process #115

Open vliux opened 7 years ago

vliux commented 7 years ago

tray Version (E.g. 0.12.0)

The Provider of Tray is running at main process. In our app we'd like to have it running in a ":service" process so that the UI process is free to be terminated by Android in background.

Seems at present there is no way to customize this.

I tried to manifest merger to add android:process=":service" to the Provider in manifest. But it crashed the app due to:

net.grandcentrix.tray.core.TrayRuntimeException: Internal tray error Caused by: net.grandcentrix.tray.core.TrayRuntimeException: Internal tray error. Could not find the provider authority. Please fill an issue at https://github.com/grandcentrix/tray/issues 07-26 10:56:24.111 22418 22418 E AndroidRuntime: at net.grandcentrix.tray.provider.TrayContract.getAuthority(TrayContract.java:138) 07-26 10:56:24.111 22418 22418 E AndroidRuntime: at net.grandcentrix.tray.provider.TrayContract.generateContentUri(TrayContract.java:109) 07-26 10:56:24.111 22418 22418 E AndroidRuntime: at net.grandcentrix.tray.provider.TrayContract.generateContentUri(TrayContract.java:80) 07-26 10:56:24.111 22418 22418 E AndroidRuntime: at net.grandcentrix.tray.provider.TrayUri.(TrayUri.java:75) 07-26 10:56:24.111 22418 22418 E AndroidRuntime: at net.grandcentrix.tray.provider.ContentProviderStorage.(ContentProviderStorage.java:146)

This is because TrayContract.getAuthority() forces the query of providers in current process: getPackageManager() .queryContentProviders(context.getPackageName(), Process.myUid(), 0);

vliux commented 7 years ago

I have created a pull request for this issue. Pls check.

OUCHUNYU commented 6 years ago

Same issue here