Search in sources :

Example 1 with ApkFile

use of io.github.muntashirakon.AppManager.apk.ApkFile in project AppManager by MuntashirAkon.

the class AppExplorerViewModel method loadFiles.

@AnyThread
public void loadFiles(@Nullable Uri uri) {
    executor.submit(() -> {
        if (apkFile == null) {
            try {
                int key = ApkFile.createInstance(apkUri, null);
                apkFile = ApkFile.getInstance(key);
                ApkFile.Entry baseEntry = apkFile.getBaseEntry();
                File cachedFile = baseEntry.getRealCachedFile();
                cachedFiles.add(cachedFile);
                int vfsId = VirtualFileSystem.mount(new VirtualFileSystem.ZipFileSystem(apkUri, cachedFile));
                vfsIds.add(vfsId);
                zipFileRoot = VirtualFileSystem.getFsRoot(vfsId);
            } catch (Throwable e) {
                e.printStackTrace();
                this.fmItems.postValue(Collections.emptyList());
                return;
            }
        }
        List<AdapterItem> adapterItems = new ArrayList<>();
        try {
            Path path;
            if (uri == null) {
                // Null URI always means root of the zip file
                path = zipFileRoot;
            } else {
                path = new Path(AppManager.getContext(), uri);
            }
            for (Path child : path.listFiles()) {
                adapterItems.add(new AdapterItem(child));
            }
            Collections.sort(adapterItems);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            this.fmItems.postValue(adapterItems);
        }
    });
}
Also used : Path(io.github.muntashirakon.io.Path) ApkFile(io.github.muntashirakon.AppManager.apk.ApkFile) VirtualFileSystem(io.github.muntashirakon.io.VirtualFileSystem) ArrayList(java.util.ArrayList) ApkFile(io.github.muntashirakon.AppManager.apk.ApkFile) File(java.io.File) AnyThread(androidx.annotation.AnyThread)

Example 2 with ApkFile

use of io.github.muntashirakon.AppManager.apk.ApkFile in project AppManager by MuntashirAkon.

the class PackageInstallerCompat method install.

public boolean install(@NonNull ApkFile apkFile) {
    try {
        this.apkFile = apkFile;
        this.packageName = apkFile.getPackageName();
        initBroadcastReceiver();
        new Thread(this::copyObb).start();
        Log.d(TAG, "Install: opening session...");
        if (!openSession())
            return false;
        List<ApkFile.Entry> selectedEntries = apkFile.getSelectedEntries();
        Log.d(TAG, "Install: selected entries: " + selectedEntries.size());
        // Write apk files
        for (ApkFile.Entry entry : selectedEntries) {
            try (InputStream apkInputStream = entry.getSignedInputStream(context);
                OutputStream apkOutputStream = session.openWrite(entry.getFileName(), 0, entry.getFileSize())) {
                IoUtils.copy(apkInputStream, apkOutputStream);
                session.fsync(apkOutputStream);
                Log.d(TAG, "Install: copied entry " + entry.name);
            } catch (IOException e) {
                callFinish(STATUS_FAILURE_SESSION_WRITE);
                Log.e(TAG, "Install: Cannot copy files to session.", e);
                return abandon();
            } catch (SecurityException e) {
                callFinish(STATUS_FAILURE_SECURITY);
                Log.e(TAG, "Install: Cannot access apk files.", e);
                return abandon();
            }
        }
        Log.d(TAG, "Install: Running installation...");
        return commit();
    } finally {
        unregisterReceiver();
    }
}
Also used : ApkFile(io.github.muntashirakon.AppManager.apk.ApkFile) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) IOException(java.io.IOException) WorkerThread(androidx.annotation.WorkerThread)

Example 3 with ApkFile

use of io.github.muntashirakon.AppManager.apk.ApkFile in project AppManager by MuntashirAkon.

the class SplitApkChooser method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    int apkFileKey = requireArguments().getInt(EXTRA_APK_FILE_KEY, -1);
    String actionName = requireArguments().getString(EXTRA_ACTION_NAME);
    ApplicationInfo appInfo = requireArguments().getParcelable(EXTRA_APP_INFO);
    String versionInfo = requireArguments().getString(EXTRA_VERSION_INFO);
    pm = requireActivity().getPackageManager();
    if (apkFileKey == -1 || appInfo == null) {
        throw new IllegalArgumentException("ApkFile cannot be empty.");
    }
    apkFile = ApkFile.getInstance(apkFileKey);
    if (!apkFile.isSplit())
        throw new RuntimeException("Apk file does not contain any split.");
    List<ApkFile.Entry> apkEntries = apkFile.getEntries();
    CharSequence[] entryNames = new CharSequence[apkEntries.size()];
    final boolean[] choices = getChoices(apkEntries);
    for (int i = 0; i < apkEntries.size(); ++i) {
        entryNames[i] = apkEntries.get(i).toLocalizedString(requireActivity());
    }
    if (installInterface == null)
        throw new RuntimeException("No install action has been set.");
    return new MaterialAlertDialogBuilder(requireActivity()).setCancelable(false).setCustomTitle(UIUtils.getDialogTitle(requireActivity(), pm.getApplicationLabel(appInfo), pm.getApplicationIcon(appInfo), versionInfo)).setMultiChoiceItems(entryNames, choices, (dialog, which, isChecked) -> {
        if (isChecked)
            apkFile.select(which);
        else
            apkFile.deselect(which);
    }).setPositiveButton(actionName == null ? getString(R.string.install) : actionName, (dialog, which) -> installInterface.triggerInstall()).setNegativeButton(R.string.cancel, (dialog, which) -> dialog.cancel()).create();
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Dialog(android.app.Dialog) UIUtils(io.github.muntashirakon.AppManager.utils.UIUtils) ArrayList(java.util.ArrayList) Objects(java.util.Objects) ApkFile(io.github.muntashirakon.AppManager.apk.ApkFile) List(java.util.List) SparseBooleanArray(android.util.SparseBooleanArray) Nullable(androidx.annotation.Nullable) ApplicationInfo(android.content.pm.ApplicationInfo) R(io.github.muntashirakon.AppManager.R) DialogInterface(android.content.DialogInterface) DialogFragment(androidx.fragment.app.DialogFragment) ApplicationInfo(android.content.pm.ApplicationInfo) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) NonNull(androidx.annotation.NonNull)

Example 4 with ApkFile

use of io.github.muntashirakon.AppManager.apk.ApkFile in project AppManager by MuntashirAkon.

the class AppInfoFragment method setupTagCloud.

@UiThread
private void setupTagCloud(AppInfoViewModel.TagCloud tagCloud) {
    mTagCloud.removeAllViews();
    if (mainModel == null)
        return;
    // Add tracker chip
    if (!tagCloud.trackerComponents.isEmpty()) {
        CharSequence[] trackerComponentNames = new CharSequence[tagCloud.trackerComponents.size()];
        for (int i = 0; i < trackerComponentNames.length; ++i) {
            ComponentRule rule = tagCloud.trackerComponents.get(i);
            trackerComponentNames[i] = rule.isBlocked() ? getColoredText(rule.name, ContextCompat.getColor(mActivity, R.color.stopped)) : rule.name;
        }
        addChip(getResources().getQuantityString(R.plurals.no_of_trackers, tagCloud.trackerComponents.size(), tagCloud.trackerComponents.size()), tagCloud.areAllTrackersBlocked ? R.color.stopped : R.color.tracker).setOnClickListener(v -> {
            if (!isExternalApk && isRootEnabled) {
                new SearchableMultiChoiceDialogBuilder<>(mActivity, tagCloud.trackerComponents, trackerComponentNames).setTitle(R.string.trackers).setSelections(tagCloud.trackerComponents).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.block, (dialog, which, selectedItems) -> {
                    showProgressIndicator(true);
                    executor.submit(() -> {
                        mainModel.addRules(selectedItems, true);
                        runOnUiThread(() -> {
                            if (isDetached())
                                return;
                            showProgressIndicator(false);
                            displayShortToast(R.string.done);
                        });
                    });
                }).setNeutralButton(R.string.unblock, (dialog, which, selectedItems) -> {
                    showProgressIndicator(true);
                    executor.submit(() -> {
                        mainModel.removeRules(selectedItems, true);
                        runOnUiThread(() -> {
                            if (isDetached())
                                return;
                            showProgressIndicator(false);
                            displayShortToast(R.string.done);
                        });
                    });
                }).show();
            } else {
                new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.trackers).setItems(trackerComponentNames, null).setNegativeButton(R.string.close, null).show();
            }
        });
    }
    if (tagCloud.isSystemApp) {
        if (tagCloud.isSystemlessPath) {
            addChip(R.string.systemless_app);
        } else
            addChip(R.string.system_app);
        if (tagCloud.isUpdatedSystemApp) {
            addChip(R.string.updated_app);
        }
    } else if (!mainModel.getIsExternalApk())
        addChip(R.string.user_app);
    if (tagCloud.splitCount > 0) {
        addChip(getResources().getQuantityString(R.plurals.no_of_splits, tagCloud.splitCount, tagCloud.splitCount)).setOnClickListener(v -> {
            try (ApkFile apkFile = ApkFile.getInstance(mainModel.getApkFileKey())) {
                // Display a list of apks
                List<ApkFile.Entry> apkEntries = apkFile.getEntries();
                CharSequence[] entryNames = new CharSequence[tagCloud.splitCount];
                for (int i = 0; i < tagCloud.splitCount; ++i) {
                    entryNames[i] = apkEntries.get(i + 1).toLocalizedString(mActivity);
                }
                new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.splits).setItems(entryNames, null).setNegativeButton(R.string.close, null).show();
            }
        });
    }
    if (tagCloud.isDebuggable) {
        addChip(R.string.debuggable);
    }
    if (tagCloud.isTestOnly) {
        addChip(R.string.test_only);
    }
    if (!tagCloud.hasCode) {
        addChip(R.string.no_code);
    }
    if (tagCloud.hasRequestedLargeHeap) {
        addChip(R.string.requested_large_heap, R.color.tracker);
    }
    if (tagCloud.runningServices.size() > 0) {
        addChip(R.string.running, R.color.running).setOnClickListener(v -> {
            mProgressIndicator.show();
            executor.submit(() -> {
                CharSequence[] runningServices = new CharSequence[tagCloud.runningServices.size()];
                for (int i = 0; i < runningServices.length; ++i) {
                    runningServices[i] = new SpannableStringBuilder().append(getTitleText(mActivity, tagCloud.runningServices.get(i).service.getShortClassName())).append("\n").append(getSmallerText(new SpannableStringBuilder().append(getStyledKeyValue(mActivity, R.string.process_name, tagCloud.runningServices.get(i).process)).append("\n").append(getStyledKeyValue(mActivity, R.string.pid, String.valueOf(tagCloud.runningServices.get(i).pid)))));
                }
                DialogTitleBuilder titleBuilder = new DialogTitleBuilder(mActivity).setTitle(R.string.running_services);
                if (PermissionUtils.hasDumpPermission() && FeatureController.isLogViewerEnabled()) {
                    titleBuilder.setSubtitle(R.string.running_services_logcat_hint);
                }
                runOnUiThread(() -> {
                    mProgressIndicator.hide();
                    MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(mActivity).setCustomTitle(titleBuilder.build()).setItems(runningServices, (dialog, which) -> {
                        if (!FeatureController.isLogViewerEnabled())
                            return;
                        Intent logViewerIntent = new Intent(mActivity.getApplicationContext(), LogViewerActivity.class).setAction(LogViewerActivity.ACTION_LAUNCH).putExtra(LogViewerActivity.EXTRA_FILTER, SearchCriteria.PID_KEYWORD + tagCloud.runningServices.get(which).pid).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        mActivity.startActivity(logViewerIntent);
                    }).setNeutralButton(R.string.force_stop, (dialog, which) -> executor.submit(() -> {
                        try {
                            PackageManagerCompat.forceStopPackage(mPackageName, mainModel.getUserHandle());
                            runOnUiThread(this::refreshDetails);
                        } catch (RemoteException | SecurityException e) {
                            Log.e(TAG, e);
                            displayLongToast(R.string.failed_to_stop, mPackageLabel);
                        }
                    })).setNegativeButton(R.string.close, null);
                    builder.show();
                });
            });
        });
    }
    if (tagCloud.isForceStopped) {
        addChip(R.string.stopped, R.color.stopped);
    }
    if (!tagCloud.isAppEnabled) {
        addChip(R.string.disabled_app, R.color.disabled_user);
    }
    if (tagCloud.isAppSuspended) {
        addChip(R.string.suspended, R.color.stopped);
    }
    if (tagCloud.isAppHidden) {
        addChip(R.string.hidden, R.color.disabled_user);
    }
    magiskHiddenProcesses = tagCloud.magiskHiddenProcesses;
    if (tagCloud.isMagiskHideEnabled) {
        addChip(R.string.magisk_hide_enabled).setOnClickListener(v -> displayMagiskHideDialog());
    }
    magiskDeniedProcesses = tagCloud.magiskDeniedProcesses;
    if (tagCloud.isMagiskDenyListEnabled) {
        addChip(R.string.magisk_denylist).setOnClickListener(v -> displayMagiskDenyListDialog());
    }
    if (tagCloud.hasKeyStoreItems) {
        Chip chip;
        if (tagCloud.hasMasterKeyInKeyStore) {
            chip = addChip(R.string.keystore, R.color.tracker);
        } else
            chip = addChip(R.string.keystore);
        chip.setOnClickListener(view -> new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.keystore).setItems(KeyStoreUtils.getKeyStoreFiles(mApplicationInfo.uid, mainModel.getUserHandle()).toArray(new String[0]), null).setNegativeButton(R.string.close, null).show());
    }
    if (tagCloud.backups.length > 0) {
        CharSequence[] backupNames = new CharSequence[tagCloud.backups.length];
        for (int i = 0; i < tagCloud.backups.length; ++i) {
            backupNames[i] = tagCloud.backups[i].toLocalizedString(mActivity);
        }
        addChip(R.string.backup).setOnClickListener(v -> new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.backup).setItems(backupNames, null).setNegativeButton(R.string.close, null).show());
    }
    if (!tagCloud.isBatteryOptimized) {
        addChip(R.string.no_battery_optimization, R.color.red_orange).setOnClickListener(v -> new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.battery_optimization).setMessage(R.string.enable_battery_optimization).setNegativeButton(R.string.no, null).setPositiveButton(R.string.yes, (dialog, which) -> {
            Runner.runCommand(new String[] { "dumpsys", "deviceidle", "whitelist", "-" + mPackageName });
            refreshDetails();
        }).show());
    }
    if (tagCloud.netPolicies > 0) {
        String[] readablePolicies = NetworkPolicyManagerCompat.getReadablePolicies(mActivity, tagCloud.netPolicies).values().toArray(new String[0]);
        addChip(R.string.has_net_policy).setOnClickListener(v -> new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.net_policy).setItems(readablePolicies, null).setNegativeButton(R.string.ok, null).show());
    }
    if (tagCloud.ssaid != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        addChip(R.string.ssaid, R.color.red_orange).setOnClickListener(v -> {
            View view = getLayoutInflater().inflate(R.layout.dialog_ssaid_info, null);
            AlertDialog alertDialog = new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.ssaid).setView(view).setPositiveButton(R.string.apply, null).setNegativeButton(R.string.close, null).setNeutralButton(R.string.reset_to_default, null).create();
            TextInputEditText ssaidHolder = view.findViewById(R.id.ssaid);
            TextInputLayout ssaidInputLayout = view.findViewById(android.R.id.text1);
            AtomicReference<Button> applyButton = new AtomicReference<>();
            AtomicReference<Button> resetButton = new AtomicReference<>();
            AtomicReference<String> ssaid = new AtomicReference<>(tagCloud.ssaid);
            alertDialog.setOnShowListener(dialog -> {
                applyButton.set(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
                resetButton.set(alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
                applyButton.get().setVisibility(View.GONE);
                applyButton.get().setOnClickListener(v2 -> executor.submit(() -> {
                    try {
                        SsaidSettings ssaidSettings = new SsaidSettings(mPackageName, mApplicationInfo.uid);
                        if (ssaidSettings.setSsaid(ssaid.get())) {
                            model.loadTagCloud();
                            runOnUiThread(() -> displayLongToast(R.string.restart_to_reflect_changes));
                        } else {
                            runOnUiThread(() -> displayLongToast(R.string.failed_to_change_ssaid));
                        }
                        alertDialog.dismiss();
                    } catch (IOException ignore) {
                    }
                }));
                resetButton.get().setVisibility(View.GONE);
                resetButton.get().setOnClickListener(v2 -> {
                    ssaid.set(tagCloud.ssaid);
                    ssaidHolder.setText(ssaid.get());
                    resetButton.get().setVisibility(View.GONE);
                    applyButton.get().setVisibility(View.GONE);
                });
            });
            ssaidHolder.setText(tagCloud.ssaid);
            ssaidHolder.setTypeface(Typeface.MONOSPACE);
            ssaidHolder.setOnClickListener(v2 -> {
                ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("SSAID", ssaid.get());
                clipboard.setPrimaryClip(clip);
                displayShortToast(R.string.copied_to_clipboard);
            });
            ssaidInputLayout.setEndIconOnClickListener(v2 -> {
                ssaid.set(SsaidSettings.generateSsaid(mPackageName));
                ssaidHolder.setText(ssaid.get());
                if (!tagCloud.ssaid.equals(ssaid.get())) {
                    if (resetButton.get() != null) {
                        resetButton.get().setVisibility(View.VISIBLE);
                    }
                    if (applyButton.get() != null) {
                        applyButton.get().setVisibility(View.VISIBLE);
                    }
                }
            });
            alertDialog.show();
        });
    }
    if (tagCloud.uriGrants != null) {
        addChip(R.string.saf).setOnClickListener(v -> {
            CharSequence[] uriGrants = new CharSequence[tagCloud.uriGrants.size()];
            for (int i = 0; i < tagCloud.uriGrants.size(); ++i) {
                uriGrants[i] = tagCloud.uriGrants.get(i).uri.toString();
            }
            new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.saf).setItems(uriGrants, null).setNegativeButton(R.string.close, null).show();
        });
    }
    if (tagCloud.usesPlayAppSigning) {
        addChip(R.string.uses_play_app_signing, R.color.disabled_user).setOnClickListener(v -> new MaterialAlertDialogBuilder(mActivity).setTitle(R.string.uses_play_app_signing).setMessage(R.string.uses_play_app_signing_description).setNegativeButton(R.string.close, null).show());
    }
}
Also used : Chip(com.google.android.material.chip.Chip) Arrays(java.util.Arrays) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) BackupDialogFragment(io.github.muntashirakon.AppManager.backup.BackupDialogFragment) BuildConfig(io.github.muntashirakon.AppManager.BuildConfig) ComponentRule(io.github.muntashirakon.AppManager.rules.struct.ComponentRule) ProxyFile(io.github.muntashirakon.io.ProxyFile) Uri(android.net.Uri) ImageView(android.widget.ImageView) Drawable(android.graphics.drawable.Drawable) LogViewerActivity(io.github.muntashirakon.AppManager.logcat.LogViewerActivity) Manifest(android.Manifest) UIUtils.getStyledKeyValue(io.github.muntashirakon.AppManager.utils.UIUtils.getStyledKeyValue) NoRootAccessibilityService(io.github.muntashirakon.AppManager.accessibility.NoRootAccessibilityService) UIUtils.displayLongToast(io.github.muntashirakon.AppManager.utils.UIUtils.displayLongToast) UIUtils.displayShortToast(io.github.muntashirakon.AppManager.utils.UIUtils.displayShortToast) Fragment(androidx.fragment.app.Fragment) ClipboardManager(android.content.ClipboardManager) UiThread(androidx.annotation.UiThread) ContextCompat(androidx.core.content.ContextCompat) R(io.github.muntashirakon.AppManager.R) ArrayMap(androidx.collection.ArrayMap) Runner(io.github.muntashirakon.AppManager.runner.Runner) PackageManagerCompat(io.github.muntashirakon.AppManager.servermanager.PackageManagerCompat) LinearProgressIndicator(com.google.android.material.progressindicator.LinearProgressIndicator) NetworkPolicyManager(android.net.NetworkPolicyManager) KeyStoreUtils(io.github.muntashirakon.AppManager.utils.KeyStoreUtils) FileUtils(io.github.muntashirakon.AppManager.utils.FileUtils) UIUtils(io.github.muntashirakon.AppManager.utils.UIUtils) Executors(java.util.concurrent.Executors) StringRes(androidx.annotation.StringRes) Nullable(androidx.annotation.Nullable) SearchableMultiChoiceDialogBuilder(io.github.muntashirakon.AppManager.types.SearchableMultiChoiceDialogBuilder) LangUtils(io.github.muntashirakon.AppManager.utils.LangUtils) UIUtils.getColoredText(io.github.muntashirakon.AppManager.utils.UIUtils.getColoredText) ActivityResultContracts(androidx.activity.result.contract.ActivityResultContracts) MagiskHide(io.github.muntashirakon.AppManager.magisk.MagiskHide) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) UiThreadHandler(io.github.muntashirakon.AppManager.utils.UiThreadHandler) PackageInstallerActivity(io.github.muntashirakon.AppManager.apk.installer.PackageInstallerActivity) RunnerUtils(io.github.muntashirakon.AppManager.runner.RunnerUtils) ServiceHelper(io.github.muntashirakon.AppManager.logcat.helper.ServiceHelper) SsaidSettings(io.github.muntashirakon.AppManager.ssaid.SsaidSettings) TextInputLayout(com.google.android.material.textfield.TextInputLayout) PackageSizeInfo(io.github.muntashirakon.AppManager.types.PackageSizeInfo) HIDDEN_API_ENFORCEMENT_DISABLED(io.github.muntashirakon.AppManager.servermanager.ApplicationInfoCompat.HIDDEN_API_ENFORCEMENT_DISABLED) WorkerThread(androidx.annotation.WorkerThread) RemoteException(android.os.RemoteException) ArrayList(java.util.ArrayList) PermissionUtils(io.github.muntashirakon.AppManager.utils.PermissionUtils) SpannableStringBuilder(android.text.SpannableStringBuilder) Path(io.github.muntashirakon.io.Path) UIUtils.getSecondaryText(io.github.muntashirakon.AppManager.utils.UIUtils.getSecondaryText) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) Settings(android.provider.Settings) SearchCriteria(io.github.muntashirakon.AppManager.logcat.struct.SearchCriteria) DateUtils(io.github.muntashirakon.AppManager.utils.DateUtils) Formatter(android.text.format.Formatter) NetworkPolicyManagerCompat(io.github.muntashirakon.AppManager.servermanager.NetworkPolicyManagerCompat) ViewModelProvider(androidx.lifecycle.ViewModelProvider) ComponentName(android.content.ComponentName) PackageInfoCompat(androidx.core.content.pm.PackageInfoCompat) IOException(java.io.IOException) AnyThread(androidx.annotation.AnyThread) WhatsNewDialogFragment(io.github.muntashirakon.AppManager.apk.whatsnew.WhatsNewDialogFragment) HIDDEN_API_ENFORCEMENT_JUST_WARN(io.github.muntashirakon.AppManager.servermanager.ApplicationInfoCompat.HIDDEN_API_ENFORCEMENT_JUST_WARN) Utils(io.github.muntashirakon.AppManager.utils.Utils) File(java.io.File) AccessibilityMultiplexer(io.github.muntashirakon.AppManager.accessibility.AccessibilityMultiplexer) FastScrollerBuilder(me.zhanghai.android.fastscroll.FastScrollerBuilder) UIUtils.getSmallerText(io.github.muntashirakon.AppManager.utils.UIUtils.getSmallerText) DigestUtils(io.github.muntashirakon.AppManager.utils.DigestUtils) AppDetailsActivity(io.github.muntashirakon.AppManager.details.AppDetailsActivity) IntentUtils(io.github.muntashirakon.AppManager.utils.IntentUtils) ComponentsBlocker(io.github.muntashirakon.AppManager.rules.compontents.ComponentsBlocker) PackageInstallerCompat(io.github.muntashirakon.AppManager.apk.installer.PackageInstallerCompat) PackageUtils(io.github.muntashirakon.AppManager.utils.PackageUtils) FeatureController(io.github.muntashirakon.AppManager.settings.FeatureController) PackageManager(android.content.pm.PackageManager) ProfileManager(io.github.muntashirakon.AppManager.profiles.ProfileManager) Spannable(android.text.Spannable) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) UIUtils.getTitleText(io.github.muntashirakon.AppManager.utils.UIUtils.getTitleText) ManifestViewerActivity(io.github.muntashirakon.AppManager.details.ManifestViewerActivity) Log(io.github.muntashirakon.AppManager.logs.Log) DrawableRes(androidx.annotation.DrawableRes) ScannerActivity(io.github.muntashirakon.AppManager.scanner.ScannerActivity) HIDDEN_API_ENFORCEMENT_DEFAULT(io.github.muntashirakon.AppManager.servermanager.ApplicationInfoCompat.HIDDEN_API_ENFORCEMENT_DEFAULT) AppManager(io.github.muntashirakon.AppManager.AppManager) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HIDDEN_API_ENFORCEMENT_ENABLED(io.github.muntashirakon.AppManager.servermanager.ApplicationInfoCompat.HIDDEN_API_ENFORCEMENT_ENABLED) GuardedBy(androidx.annotation.GuardedBy) Locale(java.util.Locale) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) AppUsageStatsManager(io.github.muntashirakon.AppManager.usage.AppUsageStatsManager) BetterActivityResult(io.github.muntashirakon.AppManager.utils.BetterActivityResult) ApkUtils(io.github.muntashirakon.AppManager.apk.ApkUtils) PermissionUtils.hasDumpPermission(io.github.muntashirakon.AppManager.utils.PermissionUtils.hasDumpPermission) AppDetailsViewModel(io.github.muntashirakon.AppManager.details.AppDetailsViewModel) Utils.openAsFolderInFM(io.github.muntashirakon.AppManager.utils.Utils.openAsFolderInFM) ViewGroup(android.view.ViewGroup) UserPackagePair(io.github.muntashirakon.AppManager.types.UserPackagePair) TERMUX_PERM_RUN_COMMAND(io.github.muntashirakon.AppManager.utils.PermissionUtils.TERMUX_PERM_RUN_COMMAND) List(java.util.List) TextView(android.widget.TextView) TextUtils(com.android.internal.util.TextUtils) SwipeRefreshLayout(io.github.muntashirakon.widget.SwipeRefreshLayout) ProfileMetaManager(io.github.muntashirakon.AppManager.profiles.ProfileMetaManager) ApplicationInfo(android.content.pm.ApplicationInfo) Signature(android.content.pm.Signature) ColorRes(androidx.annotation.ColorRes) AppDetailsItem(io.github.muntashirakon.AppManager.details.struct.AppDetailsItem) Typeface(android.graphics.Typeface) HIDDEN_API_ENFORCEMENT_BLACK(io.github.muntashirakon.AppManager.servermanager.ApplicationInfoCompat.HIDDEN_API_ENFORCEMENT_BLACK) Context(android.content.Context) TextInputEditText(com.google.android.material.textfield.TextInputEditText) AlertDialog(androidx.appcompat.app.AlertDialog) AppDetailsFragment(io.github.muntashirakon.AppManager.details.AppDetailsFragment) Pair(android.util.Pair) Intent(android.content.Intent) MainThread(androidx.annotation.MainThread) HashMap(java.util.HashMap) Ops(io.github.muntashirakon.AppManager.settings.Ops) PackageInfo(android.content.pm.PackageInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference) FmProvider(io.github.muntashirakon.AppManager.fm.FmProvider) MenuItem(android.view.MenuItem) ClipData(android.content.ClipData) ApkFile(io.github.muntashirakon.AppManager.apk.ApkFile) MaterialButton(com.google.android.material.button.MaterialButton) SharedPrefsActivity(io.github.muntashirakon.AppManager.sharedpref.SharedPrefsActivity) ArrayUtils(io.github.muntashirakon.AppManager.utils.ArrayUtils) Build(android.os.Build) ExecutorService(java.util.concurrent.ExecutorService) OutputStream(java.io.OutputStream) LayoutInflater(android.view.LayoutInflater) ActivityCompat(androidx.core.app.ActivityCompat) RulesTypeSelectionDialogFragment(io.github.muntashirakon.AppManager.rules.RulesTypeSelectionDialogFragment) MagiskDenyList(io.github.muntashirakon.AppManager.magisk.MagiskDenyList) ScrollableDialogBuilder(io.github.muntashirakon.dialog.ScrollableDialogBuilder) ResolveInfo(android.content.pm.ResolveInfo) DialogTitleBuilder(io.github.muntashirakon.dialog.DialogTitleBuilder) Bitmap(android.graphics.Bitmap) MagiskProcess(io.github.muntashirakon.AppManager.magisk.MagiskProcess) Collections(java.util.Collections) MimeTypeMap(android.webkit.MimeTypeMap) ActivityResult(androidx.activity.result.ActivityResult) AlertDialog(androidx.appcompat.app.AlertDialog) ApkFile(io.github.muntashirakon.AppManager.apk.ApkFile) Chip(com.google.android.material.chip.Chip) SearchableMultiChoiceDialogBuilder(io.github.muntashirakon.AppManager.types.SearchableMultiChoiceDialogBuilder) Button(android.widget.Button) MaterialButton(com.google.android.material.button.MaterialButton) SsaidSettings(io.github.muntashirakon.AppManager.ssaid.SsaidSettings) TextInputLayout(com.google.android.material.textfield.TextInputLayout) DialogTitleBuilder(io.github.muntashirakon.dialog.DialogTitleBuilder) ClipboardManager(android.content.ClipboardManager) Intent(android.content.Intent) AtomicReference(java.util.concurrent.atomic.AtomicReference) IOException(java.io.IOException) ComponentRule(io.github.muntashirakon.AppManager.rules.struct.ComponentRule) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) LogViewerActivity(io.github.muntashirakon.AppManager.logcat.LogViewerActivity) TextInputEditText(com.google.android.material.textfield.TextInputEditText) RemoteException(android.os.RemoteException) ClipData(android.content.ClipData) SpannableStringBuilder(android.text.SpannableStringBuilder) UiThread(androidx.annotation.UiThread)

Example 5 with ApkFile

use of io.github.muntashirakon.AppManager.apk.ApkFile in project AppManager by MuntashirAkon.

the class AppExplorerViewModel method onCleared.

@Override
protected void onCleared() {
    super.onCleared();
    executor.shutdownNow();
    // Unmount file systems
    for (int vsfId : vfsIds) {
        try {
            VirtualFileSystem.unmount(vsfId);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    FileUtils.closeQuietly(apkFile);
    for (File cachedFile : cachedFiles) {
        FileUtils.deleteSilently(cachedFile);
    }
}
Also used : ApkFile(io.github.muntashirakon.AppManager.apk.ApkFile) File(java.io.File)

Aggregations

ApkFile (io.github.muntashirakon.AppManager.apk.ApkFile)11 File (java.io.File)7 ApplicationInfo (android.content.pm.ApplicationInfo)6 PackageManager (android.content.pm.PackageManager)5 IOException (java.io.IOException)5 WorkerThread (androidx.annotation.WorkerThread)4 ArrayList (java.util.ArrayList)4 PackageInfo (android.content.pm.PackageInfo)3 NonNull (androidx.annotation.NonNull)3 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)3 ProxyFile (io.github.muntashirakon.io.ProxyFile)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 Bundle (android.os.Bundle)2 RemoteException (android.os.RemoteException)2 AnyThread (androidx.annotation.AnyThread)2 Nullable (androidx.annotation.Nullable)2 UiThread (androidx.annotation.UiThread)2 R (io.github.muntashirakon.AppManager.R)2 UIUtils (io.github.muntashirakon.AppManager.utils.UIUtils)2