Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum PartitionType {
- BOOT, RECOVERY, FOTA
- }
- private String[] bootPartitionNames = new String[] { "boot", "kernel", "LX" };
- private String[] recoveryPartitionNames = new String[] { "recovery", "SS" };
- private String[] fotaPartitionNames = new String[] { "FOTAKernel" };
- public String getPartitionName(PartitionType partition) {
- /*
- * Read out partitions from /dev/block/platform. That is the easiest way
- * and reading fstab is not always possible.
- */
- if ((partition == PartitionType.BOOT && bootPartition == null)
- || (partition == PartitionType.RECOVERY && recoveryPartition == null)
- || (partition == PartitionType.FOTA && fotaPartition == null)) {
- String[] partitionNames = null;
- switch (partition) {
- case BOOT:
- partitionNames = bootPartitionNames;
- break;
- case RECOVERY:
- partitionNames = recoveryPartitionNames;
- break;
- case FOTA:
- partitionNames = fotaPartitionNames;
- break;
- }
- if (partitionNames != null) {
- String path = mUtils.existFile(PARTITON_PATH + "/omap") ? PARTITON_PATH
- + "/omap"
- : PARTITON_PATH;
- if (mUtils.existFile(path)) {
- File[] platforms = new File(path).listFiles();
- if (platforms.length > 0) for (File platform : platforms)
- if (platform.isDirectory()) for (File emmc : platform
- .listFiles())
- if (emmc.getName().equals("by-name")) for (File part : emmc
- .listFiles())
- for (String names : partitionNames)
- if (names.equals(part.getName())
- || names.toUpperCase().equals(
- part.getName())) {
- if (partition == PartitionType.BOOT) bootPartition = part
- .getAbsolutePath();
- if (partition == PartitionType.RECOVERY) recoveryPartition = part
- .getAbsolutePath();
- if (partition == PartitionType.FOTA) fotaPartition = part
- .getAbsolutePath();
- }
- }
- }
- }
- if (partition == PartitionType.BOOT) return bootPartition;
- if (partition == PartitionType.RECOVERY) return recoveryPartition;
- if (partition == PartitionType.FOTA) return fotaPartition;
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement