summaryrefslogtreecommitdiffstats
path: root/updater_sample/src/com/example/android/systemupdatersample/util/UpdateConfigs.java
diff options
context:
space:
mode:
authorZhomart Mukhamejanov <zhomart@google.com>2018-04-23 20:38:54 +0200
committerZhomart Mukhamejanov <zhomart@google.com>2018-05-08 23:12:33 +0200
commit0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92 (patch)
tree54ee79783c840c9dea16973abeb99602aef66881 /updater_sample/src/com/example/android/systemupdatersample/util/UpdateConfigs.java
parentMerge "recovery: Remove unneeded include of minui.h." (diff)
downloadandroid_bootable_recovery-0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92.tar
android_bootable_recovery-0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92.tar.gz
android_bootable_recovery-0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92.tar.bz2
android_bootable_recovery-0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92.tar.lz
android_bootable_recovery-0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92.tar.xz
android_bootable_recovery-0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92.tar.zst
android_bootable_recovery-0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92.zip
Diffstat (limited to '')
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/util/UpdateConfigs.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/updater_sample/src/com/example/android/systemupdatersample/util/UpdateConfigs.java b/updater_sample/src/com/example/android/systemupdatersample/util/UpdateConfigs.java
index 71d4df8ab..5080cb6d8 100644
--- a/updater_sample/src/com/example/android/systemupdatersample/util/UpdateConfigs.java
+++ b/updater_sample/src/com/example/android/systemupdatersample/util/UpdateConfigs.java
@@ -26,14 +26,16 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
/**
* Utility class for working with json update configurations.
*/
public final class UpdateConfigs {
- private static final String UPDATE_CONFIGS_ROOT = "configs/";
+ public static final String UPDATE_CONFIGS_ROOT = "configs/";
/**
* @param configs update configs
@@ -48,13 +50,12 @@ public final class UpdateConfigs {
* @return configs root directory
*/
public static String getConfigsRoot(Context context) {
- return Paths.get(context.getFilesDir().toString(),
- UPDATE_CONFIGS_ROOT).toString();
+ return Paths
+ .get(context.getFilesDir().toString(), UPDATE_CONFIGS_ROOT)
+ .toString();
}
/**
- * It parses only {@code .json} files.
- *
* @param context application context
* @return list of configs from directory {@link UpdateConfigs#getConfigsRoot}
*/
@@ -80,5 +81,20 @@ public final class UpdateConfigs {
return configs;
}
+ /**
+ * @param filename searches by given filename
+ * @param config searches in {@link UpdateConfig#getStreamingMetadata()}
+ * @return offset and size of {@code filename} in the package zip file
+ * stored as {@link UpdateConfig.PackageFile}.
+ */
+ public static Optional<UpdateConfig.PackageFile> getPropertyFile(
+ final String filename,
+ UpdateConfig config) {
+ return Arrays
+ .stream(config.getStreamingMetadata().getPropertyFiles())
+ .filter(file -> filename.equals(file.getFilename()))
+ .findFirst();
+ }
+
private UpdateConfigs() {}
}