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

Player checking in Android via pm list packages #1416

Open
Rem01Gaming opened this issue Sep 8, 2024 · 14 comments
Open

Player checking in Android via pm list packages #1416

Rem01Gaming opened this issue Sep 8, 2024 · 14 comments
Assignees
Labels
priority 4: wishlist Default for feature requests type: feature request feature request

Comments

@Rem01Gaming
Copy link

Rem01Gaming commented Sep 8, 2024

Is your feature request related to a problem? Please describe.
There is a way to check players in Android, we can retrieve package list from command pm list packages and then check if MPV or VLC is installed.

Describe the solution you'd like
Example of checking installed player in Android:

if pm list packages | grep is.xyz.mpv >/dev/null; then
	echo "MPV Android installed"
fi

if pm list packages | grep org.videolan.vlc >/dev/null; then
	echo "VLC Android installed"
fi

Additional context
Instead of completely disabling the player checking on Android, this is much more better solution.

@Rem01Gaming Rem01Gaming added priority 4: wishlist Default for feature requests type: feature request feature request labels Sep 8, 2024
@CoolnsX
Copy link
Collaborator

CoolnsX commented Sep 8, 2024

You think I haven't tried that? I know that it won't work.
Screenshot_20240908-190403

@Rem01Gaming
Copy link
Author

Hmm try /system/bin/pm list packages

@CoolnsX
Copy link
Collaborator

CoolnsX commented Sep 8, 2024

Interesting, it works now, earlier it used to not work. The same binary path u mentioned.

@CoolnsX
Copy link
Collaborator

CoolnsX commented Sep 8, 2024

I have Android 14 btw

@Rem01Gaming
Copy link
Author

Rem01Gaming commented Sep 8, 2024

I have Android 14 btw

Android 14 is a bit weird on some case like this
In case it still failing, we can disables the player checking only if the pm command returns an error.

@CoolnsX
Copy link
Collaborator

CoolnsX commented Sep 8, 2024

Ye, the first pm is from termux. And this one is from system.

@Rem01Gaming
Copy link
Author

Ye, the first pm is from termux. And this one is from system.

Screenshot_20240908-204926_Termux_Monet~2
It's actually the same pm from system, just how to call it that diff

@CoolnsX
Copy link
Collaborator

CoolnsX commented Sep 8, 2024

That calling via termux's pm is not working properly.

@Rem01Gaming
Copy link
Author

Ye

@port19x
Copy link
Collaborator

port19x commented Oct 17, 2024

@CoolnsX wanna do sth with this or should we omit this?

@CoolnsX
Copy link
Collaborator

CoolnsX commented Oct 17, 2024

We need more devices to confirm this, we can implement it but it should not be blocking

@Nannk
Copy link
Contributor

Nannk commented Oct 17, 2024

LineageOS 21 with microG, Android 14 (AP2A.240905.003)
Screenshot_20241017-110808_Termux_1

@Rem01Gaming
Copy link
Author

You think I haven't tried that? I know that it won't work. Screenshot_20240908-190403

@CoolnsX I think you're right, after some research Google have been restrict QUERY_ALL_PACKAGES permission access since Android 11.
I'm also found this discussion on termux packages repo which talking about the same thing, however somehow pm list packages working some ROMs (yes it's not device dependent). About why it was working on some ROMs is either device maintainer or ROM developer have been bypassed or skipped this particular security changes.

Since this was working on some ROMs, I recommend to disables the player checking only if the pm command returns an error.

androidPlayerCheck() {
	package_list="$(/system/bin/pm list packages)"

	if echo "$package_list" | grep -q Failure; then
		echo "Checking of players is disabled due to selinux restriction"
		return 1
	fi

	if echo "$package_list" | grep -q is.xyz.mpv; then
		echo "MPV Android installed"
		return 0
	fi

	if echo "$package_list" | grep -q org.videolan.vlc; then
		echo "VLC Android installed"
		return 0
	fi
}
androidPlayerCheck

But yeah we probably need to think twice to implement this, it's up to you.

@searinminecraft
Copy link

searinminecraft commented Dec 3, 2024

I think the reason why /system/bin/pm list packages doesnt work is because of SELinux related stuff. It depends on kernel or SELinux status and rules

It really only works if there is a workaround to get around the SELinux restriction, or by setting the SELinux to Permissive (which is a security flaw that is not recommended to do, and requires root)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority 4: wishlist Default for feature requests type: feature request feature request
Projects
None yet
Development

No branches or pull requests

5 participants