f6176009b1
Stages TWRP's GUI engine and standalone tooling as PawletOS-owned modules instead of a bootable/recovery fork, per the plugin-architecture finding in NOTES-ota-recovery-ab.md: stock recovery_main.cpp already dlopen()s librecovery_ui_ext.so and dlsym()s make_device() from it at runtime, so the UI layer doesn't require touching stock bootable/recovery at all. Confirmed via source grep that recovery.cpp/install.cpp have zero references into the partition manager/backup engine/GUI code and vice versa. recovery_ui/: TWRP's gui/, minuitwrp/, libpixelflinger/ (copied verbatim, GPL-3.0), plus a new device/ providing PawletTwrpUI (a ScreenRecoveryUI subclass) and make_device() — written from scratch against stock's RecoveryUI/ScreenRecoveryUI virtual-method contract, since TWRP's own fork never ships a make_device() (every real TWRP device provides its own, and no reference device tree was available to copy from). Top-level Android.bp defines librecovery_ui_pawlet_twrp, the module TARGET_RECOVERY_UI_LIB should point at. gui/Android.bp and minuitwrp/Android.bp had their include_dirs rewritten for the new paths. recovery_toolkit/: partition manager, backup engine (tar/digest/adbbu/apex), filesystem/format support (exfat/dosfstools/gpt/fuse/mtp/crypto), scripting (openrecoveryscript/orscmd/twrpinstall), shared helpers. Source only, no Android.bp yet for any of it. Known gap blocking recovery_ui from actually linking: gui/'s libguitwrp depends on libaosprecovery, built from recovery_toolkit/helpers/twrp.cpp via a Go Soong plugin (libaosprecovery_defaults.go) not yet ported. Neither repo has been build-tested — no local AOSP build environment available in this workspace. See each directory's README.md for a precise done/not-done breakdown.
104 lines
2.3 KiB
C
104 lines
2.3 KiB
C
#ifndef UTIL_LINUX_OPTUTILS_H
|
|
#define UTIL_LINUX_OPTUTILS_H
|
|
|
|
#include "c.h"
|
|
#include "nls.h"
|
|
|
|
static inline const char *option_to_longopt(int c, const struct option *opts)
|
|
{
|
|
const struct option *o;
|
|
|
|
for (o = opts; o->name; o++)
|
|
if (o->val == c)
|
|
return o->name;
|
|
return NULL;
|
|
}
|
|
|
|
#ifndef OPTUTILS_EXIT_CODE
|
|
# define OPTUTILS_EXIT_CODE EXIT_FAILURE
|
|
#endif
|
|
|
|
/*
|
|
* Check collisions between options.
|
|
*
|
|
* The conflicts between options are described in ul_excl_t array. The
|
|
* array contains groups of mutually exclusive options. For example
|
|
*
|
|
* static const ul_excl_t excl[] = {
|
|
* { 'Z','b','c' }, // first group
|
|
* { 'b','x' }, // second group
|
|
* { 0 }
|
|
* };
|
|
*
|
|
* int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
|
|
*
|
|
* while ((c = getopt_long(argc, argv, "Zbcx", longopts, NULL)) != -1) {
|
|
*
|
|
* err_exclusive_options(c, longopts, excl, excl_st);
|
|
*
|
|
* switch (c) {
|
|
* case 'Z':
|
|
* ....
|
|
* }
|
|
* }
|
|
*
|
|
* The array excl[] defines two groups of the mutually exclusive options. The
|
|
* option '-b' is in the both groups.
|
|
*
|
|
* Note that the options in the group have to be in ASCII order (ABC..abc..) and
|
|
* groups have to be also in ASCII order.
|
|
*
|
|
* The maximal number of the options in the group is 15 (size of the array is
|
|
* 16, last is zero).
|
|
*
|
|
* The current status of options is stored in excl_st array. The size of the array
|
|
* must be the same as number of the groups in the ul_excl_t array.
|
|
*
|
|
* If you're unsure then see sys-utils/mount.c or misc-utils/findmnt.c.
|
|
*/
|
|
#define UL_EXCL_STATUS_INIT { 0 }
|
|
typedef int ul_excl_t[16];
|
|
|
|
static inline void err_exclusive_options(
|
|
int c,
|
|
const struct option *opts,
|
|
const ul_excl_t *excl,
|
|
int *status)
|
|
{
|
|
int e;
|
|
|
|
for (e = 0; excl[e][0] && excl[e][0] <= c; e++) {
|
|
const int *op = excl[e];
|
|
|
|
for (; *op && *op <= c; op++) {
|
|
if (*op != c)
|
|
continue;
|
|
if (status[e] == 0)
|
|
status[e] = c;
|
|
else if (status[e] != c) {
|
|
size_t ct = 0;
|
|
|
|
fprintf(stderr, _("%s: these options are "
|
|
"mutually exclusive:"),
|
|
program_invocation_short_name);
|
|
|
|
for (op = excl[e];
|
|
ct + 1 < ARRAY_SIZE(excl[0]) && *op;
|
|
op++, ct++) {
|
|
const char *n = option_to_longopt(*op, opts);
|
|
if (n)
|
|
fprintf(stderr, " --%s", n);
|
|
else
|
|
fprintf(stderr, " -%c", *op);
|
|
}
|
|
fputc('\n', stderr);
|
|
exit(OPTUTILS_EXIT_CODE);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|