Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #3] Optimize application list for Dual apps. #1338

Conversation

amaa-99
Copy link

@amaa-99 amaa-99 commented Jul 25, 2023

Fixed the error in the syntax of the 'pm list packages' command executed in the Api.getPackagesForUser() leading to an execution error and consequently to an empty package list getting returned.

@amaa-99 amaa-99 changed the title 3 bug in the implementation of apigetpackagesforuser leading to empty package list [Issue #3] Bug in the implementation of apigetpackagesforuser leading to empty package list Jul 25, 2023
@amaa-99 amaa-99 changed the title [Issue #3] Bug in the implementation of apigetpackagesforuser leading to empty package list [Issue #3] Bug in the implementation of apigetpackagesforuser leading to empty package list. Jul 25, 2023
@amaa-99 amaa-99 changed the title [Issue #3] Bug in the implementation of apigetpackagesforuser leading to empty package list. [Issue #3] Bug in the implementation of Api.getpackagesForUser() leading to empty package list. Jul 25, 2023
@@ -1688,7 +1688,7 @@ private static boolean packagesExistForUserUid(HashMap<Integer,String> pkgs, int
public static HashMap<Integer, String> getPackagesForUser(List<Integer> userProfile) {
HashMap<Integer,String> listApps = new HashMap<>();
for(Integer integer: userProfile) {
Shell.Result result = Shell.cmd("pm list packages -U --user " + integer).exec();
Shell.Result result = Shell.cmd("pm list packages -u --user " + integer).exec();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-U is to list the packages with UID. Not sure why you want to remove it ?

Copy link
Author

@amaa-99 amaa-99 Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting consistently an error message returned by "pm list packages -U --user" xx in one of my devices (something similar to "Error: Unknown option: -U").
I believe I was testing the scenario where root is not available (or not supported).

In any case I'd revert this change... In case the problem is due to root not being available then it probably shouldn't get this code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better look at cmd package list packages as an option for recent implementations/SDK's

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting the application uids is not a problem with the PackageManager APIs, the issue is getting (only) those for a given user: The API for that was only added very recently.

Copy link
Author

@amaa-99 amaa-99 Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look in the two commits currently in the branch: Those don't solve the underlying problem but already help mitigating it.

As a bonus, those also fix the lag noticed when opening the application list or the log views.

If you don't see problems with those I'd suggest having those merged and continue fixing the rest of the problem in a continuation pull request.

@amaa-99 amaa-99 force-pushed the 3-bug-in-the-implementation-of-apigetpackagesforuser-leading-to-empty-package-list branch from 3728571 to 1433e79 Compare July 28, 2023 20:51
Copy link
Owner

@ukanth ukanth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work as it needs UID also as output. Output is used by dual_pattern

@amaa-99
Copy link
Author

amaa-99 commented Aug 9, 2023

I've noticed that, however the -U option seems to be a specific extension in some implementations.
It seems to not be mentioned at all in the official documentation, and is not available in the Samsung Android 5 and 6 firmwares that I've tested, and apparently also not at least on some LineageOS variants.

@amaa-99 amaa-99 force-pushed the 3-bug-in-the-implementation-of-apigetpackagesforuser-leading-to-empty-package-list branch 4 times, most recently from 9897190 to 89f8a83 Compare August 9, 2023 20:04
amaa-99 added 2 commits August 10, 2023 19:24
…ading to empty package list.

Implemented the new Api.getApplicationIcon() method and replaced the calls to Api.getPackagesForUser() in the LogRecyclerViewAdapter with this one.
This both works around the unsupported 'pm list packages -U' issue, and fixes the lag when opening the log view due to the overhead of running 'pm list' in a shell.
…ading to empty package list.

Changed the getApps() implementation to only call getPackagesForUser() in case supportDual is enabled.
This avoids the problems with the unsupported 'pm list packages -U' issue in that location in case the supportDual is not enabled, and reduces the lag when opening the application list view due to the overhead of running 'pm list' in a shell.
@amaa-99 amaa-99 force-pushed the 3-bug-in-the-implementation-of-apigetpackagesforuser-leading-to-empty-package-list branch from 89f8a83 to b3bf307 Compare August 10, 2023 17:30
@ukanth ukanth changed the title [Issue #3] Bug in the implementation of Api.getpackagesForUser() leading to empty package list. [Issue #3] Optimize application list for Dual apps. Aug 14, 2023
@ukanth ukanth merged commit 9612d6f into ukanth:beta Aug 14, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants