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] Work Profile apps are not shown in Android 12 even enabling in Preferences #1280

Closed
pixincreate opened this issue Apr 28, 2022 · 9 comments
Labels

Comments

@pixincreate
Copy link

Describe the bug
Work profile apps are not shown even after enabling allowance of those apps in Android 12

Firewall Logs
IPv4rules.log

Smartphone (please complete the following information):

  • Device: Nokia 6.1 Plus [DRG]
  • Android OS: LineageOS 19.1 (Android 12L)

Additional context
When work profile exist, Afwall+ restrict internet access to them but doesn't allow apps to show there

@szymonj99
Copy link

szymonj99 commented May 4, 2022

The main cause of this issue is https://developer.android.com/training/package-visibility

I am playing around with that on my end, and I wonder if we could either:

Use the <queries><intent><action ...></intent></queries> syntax in AndroidManifest.xml

<queries>
    <intent>
        <action android:name="android.intent.action.ALL_APPS"/> <!-- I am unsure of what to actually use here. I'm not even 100% sure if this something that would help us here -->
    </intent>
</queries>

along with

Intent intent = new Intent(Intent.ACTION_ALL_APPS);

to get all the installed applications, or (instert another way here... 😆 ).

Worst-case scenario is doing something like

<queries>
    <package android:name="com.google.android.gm" />
    <package android:name="com.facebook.katana" />
    <package android:name="com.abc.xyz" />
    <package android:name="com.def.ghi" />
    ...
    ad infinitum
    ...
</queries>

which is very clearly not ideal.

I think however that a possible (not spiked this yet) approach is to use as suggested in the code already, //use pm list packages -f -U --user 10 however this would have to run the command for all the users on the device, and get rid of duplicates. 🤔 https://developer.android.com/reference/android/app/UiAutomation#executeShellCommand%28java.lang.String%29 sounds like something we could use here.
Or, we could also hand-roll our own piece of code like this:

try {
    Process su = Runtime.getRuntime().exec("su -c pm list packages --user 0");
    installed_packages = new BufferedReader(new InputStreamReader(su.getInputStream()));
}
etc...

@pixincreate
Copy link
Author

pixincreate commented May 5, 2022

I've another idea but that requires user to install AfWall+ to the other profile (which I believe is not a job that makes the life harder but easy). I believe this would be efficient in every way possible.

After installing AfWall+ to the other profile (workProfile), apps in tht profile will then become visible. Now, your only job is that you should find and link AfWall+ from workProfile with the mainProfile in order for them to work together. The same has to be applied to multiple users as well. You've root access, you can do it.

@szymonj99
Copy link

Correct me if I'm wrong, but you're describing inter-process communications here?
That seems convoluted, and wouldn't work from my limited knowledge.
Sure, we could get a list of package/application names from the work profile back to the main profile, but we couldn't really do anything with just strings (look below).
One way to get package information is pkgmanager.getApplicationInfo(package_name, pkgManagerFlags);. This errors out, and I can't get around this even with root as of right now.

java.lang.SecurityException: getPackagesForUid: UID 10194 requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS or android.permission.INTERACT_ACROSS_PROFILES to access user .

Using the steps you've described wouldn't help here as we need to get the package/application info so that we can check if an application has networking permissions. This can only be done using the function I described above.
Correct me if I misunderstood you or made a mistake here. 👍

@pixincreate
Copy link
Author

I've very little idea about Android Apps, learning to develop apps BTW.

But what I meant to say was AfWall+ if installed on a workProfile, it can see the workProfile installed apps.

@benne-dee
Copy link

benne-dee commented May 31, 2022

@pixincreate I think you are looking for this. #1249 (comment)
It's a custom script that I believe purports to allow the main (primary user) AFWall+ apply rules ticked in secondary users' AFWall+

This works by reading the saved configuration from the secondary (or work profile) user's AFWall+ data directory and applying those rules directly.

@pixincreate
Copy link
Author

@pixincreate I think you are looking for this. #1249 (comment) It's a custom script that I believe purports to allow the main (primary user) AFWall+ apply rules ticked in secondary users' AFWall+

This works by reading the saved configuration from the secondary (or work profile) user's AFWall+ data directory and applying those rules directly.

This actually never worked for me. All that I got was an elf indicating that the rules cannot be applied.

@benne-dee
Copy link

This actually never worked for me. All that I got was an elf indicating that the rules cannot be applied.

I was able to replicate this error. Made some edits to the script to resolve the errors seen while applying rules. Perhaps it would work for you too. [Link]

p.s: If it still doesn't work, looking at the logs with a logcat app, like Logcat Reader might help figure out the problem. You'd need to filter by Tag 'AFWall' so as not to get overwhelmed.

@ukanth
Copy link
Owner

ukanth commented Jun 19, 2022

@ukanth
Copy link
Owner

ukanth commented Jun 19, 2022

Duplicate of #1249

@ukanth ukanth marked this as a duplicate of #1249 Jun 19, 2022
@ukanth ukanth closed this as completed Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants