Skip to content
This repository was archived by the owner on Dec 30, 2019. It is now read-only.

Commit dff30e8

Browse files
committed
Update apkL to return currently running ROM
1 parent 98398d2 commit dff30e8

3 files changed

Lines changed: 61 additions & 5 deletions

File tree

main.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,29 @@ int main(int argc, const char *argv[])
6868
// can manipulate them
6969

7070
int i;
71+
int active = 0;
7172
struct multirom_status s;
7273
memset(&s, 0, sizeof(struct multirom_status));
7374

7475
multirom_apk_get_roms(&s);
7576

7677
for(i = 0; s.roms && s.roms[i]; ++i)
7778
{
79+
if(s.current_rom)
80+
active = (s.roms[i] == s.current_rom);
81+
7882
if (!s.roms[i]->partition)
7983
{
8084
// Internal ROMs
81-
printf("ROM: name=%s base=%s icon=%s\n",
85+
printf("ROM:%d name=%s base=%s icon=%s\n",
86+
active,
8287
s.roms[i]->name, s.roms[i]->base_path, s.roms[i]->icon_path);
8388
}
8489
else
8590
{
8691
// External ROMs
87-
printf("ROM: name=%s base=%s icon=%s part_name=%s part_mount=%s part_uuid=%s part_fs=%s\n",
92+
printf("ROM:%d name=%s base=%s icon=%s part_name=%s part_mount=%s part_uuid=%s part_fs=%s\n",
93+
active,
8894
s.roms[i]->name, s.roms[i]->base_path, s.roms[i]->icon_path,
8995
s.roms[i]->partition->name, s.roms[i]->partition->mount_path, s.roms[i]->partition->uuid, s.roms[i]->partition->fs);
9096
}

multirom.c

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,45 @@ int multirom_apk_get_roms(struct multirom_status *s)
626626
return -1;
627627
}
628628

629+
char current_rom[256] = { 0 };
630+
s->curr_rom_part = NULL;
631+
632+
/* Read multirom.ini to find current_rom */
633+
char arg[256];
634+
sprintf(arg, "%s/multirom.ini", mrom_dir());
635+
636+
FILE *f = fopen(arg, "re");
637+
if(f)
638+
{
639+
char line[1024];
640+
641+
char name[64];
642+
char *pch;
643+
644+
while((fgets(line, sizeof(line), f)))
645+
{
646+
pch = strtok (line, "=\n");
647+
if(!pch) continue;
648+
strcpy(name, pch);
649+
pch = strtok (NULL, "=\n");
650+
if(!pch) continue;
651+
strcpy(arg, pch);
652+
653+
if(strstr(name, "current_rom"))
654+
strcpy(current_rom, arg);
655+
else if(strstr(name, "curr_rom_part"))
656+
s->curr_rom_part = strdup(arg);
657+
}
658+
659+
printf("current_rom='%s' curr_rom_part='%s'\n", current_rom, (s->curr_rom_part ? s->curr_rom_part : ""));
660+
661+
fclose(f);
662+
}
663+
else
664+
{
665+
printf("Failed to open config file, setting current_rom to null!\n");
666+
}
667+
629668
/* Get Internal ROM */
630669
char roms_path[256];
631670
sprintf(roms_path, "%s/roms/"INTERNAL_ROM_NAME, mrom_dir());
@@ -702,11 +741,22 @@ int multirom_apk_get_roms(struct multirom_status *s)
702741
multirom_update_partitions(s);
703742

704743
int i;
705-
for(i = 0; s->partitions && s->partitions[i]; ++i) {
706-
//printf("part=%s\n", s->partitions[i]->mount_path);
744+
pthread_mutex_lock(&parts_mutex);
745+
for(i = 0; s->partitions && s->partitions[i]; ++i)
746+
{
707747
s->partitions[i]->keep_mounted = 1; // don't unmount on exit, the APK will need access to the folders
708748
multirom_scan_partition_for_roms(s, s->partitions[i]);
709749
}
750+
pthread_mutex_unlock(&parts_mutex);
751+
752+
753+
s->current_rom = multirom_get_rom(s, current_rom, s->curr_rom_part);
754+
if(!s->current_rom)
755+
{
756+
printf("Failed to find current rom (%s, part %s)!\n", current_rom, (s->curr_rom_part) ? s->curr_rom_part : "");
757+
free(s->curr_rom_part);
758+
s->curr_rom_part = NULL;
759+
}
710760

711761
return 0;
712762
}

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define VERSION_H
2020
#define VERSION_MULTIROM 33
2121
#define VERSION_TRAMPOLINE 27
22-
#define VERSION_APKL 2
22+
#define VERSION_APKL 3
2323

2424
// For device-specific fixes. Use letters, the version will then be like "12a"
2525
#ifdef MR_DEVICE_SPECIFIC_VERSION

0 commit comments

Comments
 (0)