android-debloat-list/update_uad.php
Muntashir Al-Islam 216b39e196 Sort lists by ID
2022-08-09 12:31:04 +06:00

51 lines
1.5 KiB
PHP

<?php
/* SPDX-License-Identifier: GPL-3.0-or-later */
const LIST_JSON = 'https://raw.githubusercontent.com/0x192/universal-android-debloater/master/resources/assets/uad_lists.json';
$list = json_decode(file_get_contents(LIST_JSON), true);
$new_list = array();
foreach ($list as $item) {
$new_item = array();
$new_item['id'] = $item['id'];
$new_item['description'] = $item['description'];
$new_item['removal'] = get_removal($item['removal']);
if ($item['dependencies'] != null) {
$new_item['dependencies'] = $item['dependencies'];
}
if ($item['neededBy'] != null) {
$new_item['required_by'] = $item['neededBy'];
}
$list_type = strtolower($item['list']);
if (!isset($new_list[$list_type])) {
$new_list[$list_type] = array();
}
// For now, exclude `unsafe` items
if ($new_item['removal'] != 'unsafe') {
$new_list[$list_type][] = $new_item;
}
}
# Save to dir
foreach ($new_list as $list_type => $list) {
usort($list, function ($o1, $o2) {
return $o1['id'] <=> $o2['id'];
});
file_put_contents(__DIR__ . '/' . $list_type . '.json', json_encode($list, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
}
function get_removal(string $uad_removal): string {
switch ($uad_removal) {
default:
case "Recommended":
return "delete";
case "Advanced":
return "replace";
case "Expert":
return "caution";
case "Unsafe":
return "unsafe";
}
}