Skip to content

Commit

Permalink
Fix permissions view for xapk files
Browse files Browse the repository at this point in the history
  • Loading branch information
alesimula committed Feb 15, 2022
1 parent d880d9c commit c4888f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 10 additions & 4 deletions lib/android/permissions.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// All permissions available at https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/AndroidManifest.xml

import 'dart:collection';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/cupertino.dart';
import 'package:mdi/mdi.dart';
import 'package:wsa_pacman/utils/locale_utils.dart';
import 'package:collection/collection.dart';

enum AndroidPermission {
NONE,
Expand All @@ -27,12 +29,16 @@ enum AndroidPermission {

extension AndroidPermissionList on AndroidPermission {

static AndroidPermission? get(String name) => _permissions[name];
//AndroidPermission? operator [] (String name) => _permissions[name];
int coso() {
return 1;
static Set<AndroidPermission> fromNames(Iterable<String> names) {
final permissions = SplayTreeSet<AndroidPermission>((a,b)=> a.index - b.index)
..addAll(names.map((perm) => AndroidPermissionList.get(perm)).whereNotNull());
if (permissions.isEmpty) permissions.add(AndroidPermission.NONE);
return permissions;
}

static AndroidPermission? get(String name) => _permissions[name];


Icon get icon {switch (this) {
case AndroidPermission.NONE: return const Icon(Mdi.gitlab);
case AndroidPermission.X_ADMIN_BRICK: return const Icon(Mdi.bugOutline);
Expand Down
3 changes: 1 addition & 2 deletions lib/android/reader_xapk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ class XapkReader extends IsolateRunner<String, APK_READER_FLAGS> {
if (manifestFile == null) return;
log("READING MANIFEST");
final manifest = _decodeManifest(manifestFile.content as List<int>);
Set<AndroidPermission> permissions = manifest.permissions.map((perm) => AndroidPermissionList.get(perm)).whereNotNull().toSet();
if (permissions.isEmpty) permissions.add(AndroidPermission.NONE);
final permissions = AndroidPermissionList.fromNames(manifest.permissions);
updateManifest(manifest, permissions);
String iconFile = manifest.icon.isNotEmpty ? manifest.icon : "icon.png";
final icon = archive.findFile(iconFile);
Expand Down

0 comments on commit c4888f5

Please sign in to comment.