From f102ccff60d4a9b0f7480aeabf5362d4b71bb223 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 9 Sep 2016 12:50:23 +0200 Subject: [PATCH] allow install history to be read from an ContentProvider This allows a designated app to read the install history from F-Droid via a ContentProvider. The app is designated by the packageName defined in the string install_history_reader_packageName. --- app/src/main/AndroidManifest.xml | 9 +++++++++ app/src/main/java/org/fdroid/fdroid/FDroidApp.java | 11 +++++++++++ .../fdroid/installer/InstallHistoryService.java | 8 ++++++-- app/src/main/res/values/donottranslate.xml | 5 ++++- .../main/res/xml/install_history_file_provider.xml | 6 ++++++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/xml/install_history_file_provider.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d4bfaeb67..70cecf9cb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -109,6 +109,15 @@ android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/apk_file_provider" /> + + + = 19) { + modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION; + } + grantUriPermission(packageName, InstallHistoryService.LOG_URI, modeFlags); + } } @TargetApi(18) diff --git a/app/src/main/java/org/fdroid/fdroid/installer/InstallHistoryService.java b/app/src/main/java/org/fdroid/fdroid/installer/InstallHistoryService.java index a6789538b..e111b15df 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/InstallHistoryService.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/InstallHistoryService.java @@ -24,11 +24,11 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.net.Uri; import android.os.Process; import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; -import org.fdroid.fdroid.R; import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.Apk; @@ -47,6 +47,8 @@ import java.util.List; public class InstallHistoryService extends IntentService { public static final String TAG = "InstallHistoryService"; + public static final Uri LOG_URI = Uri.parse("content://org.fdroid.fdroid.installer/install_history/all"); + private static BroadcastReceiver broadcastReceiver; public static void register(Context context) { @@ -107,7 +109,9 @@ public class InstallHistoryService extends IntentService { values.add(String.valueOf(versionCode)); values.add(intent.getAction()); - File logFile = new File(getFilesDir(), getString(R.string.install_history_log_file)); + File installHistoryDir = new File(getCacheDir(), "install_history"); + installHistoryDir.mkdir(); + File logFile = new File(installHistoryDir, "all"); FileWriter fw = null; PrintWriter out = null; try { diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 33ee1d38a..cb5f3c688 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -15,7 +15,10 @@ %1$s on F-Droid - all + + 1-THIS MEANS NO APP IS GRANTED ACCESS! + @string/install_history_reader_packageName_UNSET 0 diff --git a/app/src/main/res/xml/install_history_file_provider.xml b/app/src/main/res/xml/install_history_file_provider.xml new file mode 100644 index 000000000..06e42c762 --- /dev/null +++ b/app/src/main/res/xml/install_history_file_provider.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file