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

Rebuild APKs #6

Closed
Atrate opened this issue Jun 5, 2020 · 12 comments
Closed

Rebuild APKs #6

Atrate opened this issue Jun 5, 2020 · 12 comments
Labels
Feature New feature or request Priority: 5 Lowest priority

Comments

@Atrate
Copy link
Contributor

Atrate commented Jun 5, 2020

While I believe that #2, #3 and #4 are in line with this project's direction, this issue might not be.

An interesting (and hard and time consuming to implement) feature I couldn't find in any FOSS app so far is APK rebuilding.

By that I mean disassembling the application, modifying the manifest file and some classes, then recompiling and signing with a new key, similar to what apps like Lucky Patcher or Jasi Patcher do.

This would allow for a very deeply-rooted removal of advertising receivers and services or unneeded permissions, instead of simply disabling them.

This would also allow for the removal of permissions that can't be disabled, e.g. android.permission.INTERNET.

Curiously, this does not require root access at all.

@MuntashirAkon
Copy link
Owner

I would love that myself. But I'll probably have decompile Lucky Patcher to figure it out. I know how to find classes inside classes.dex and modify them but that's all I know as of today. I've no idea how odex works and I have yet to figure out how to convert odex to dex without root.

@MuntashirAkon
Copy link
Owner

On second thought, dalvik.system.DexFile is deprecated now, which is probably used by these app to modify apps without root. Even classyshark3xodus utilizes this to find trackers inside a dex file.

@MuntashirAkon
Copy link
Owner

This would also allow for the removal of permissions that can't be disabled, e.g. android.permission.INTERNET.

Are you sure permissions like android.permission.INTERNET can't be disabled? AppOpsX can disable such permissions but the source code has no documentation whatsoever. I'll probably merge this app if I can figure out what it's been doing to disable these permissions. Currently I can't even make it work due to API issues: it uses API 28 as the target API but I only have API 29 (can't download API 28 due to bandwidth issues) and while it does compile on API 29, the app doesn't work at all.

@Atrate
Copy link
Contributor Author

Atrate commented Jun 12, 2020

AppOpsX can disable such permissions but the source code has no documentation whatsoever. I

Always thought it was impossible, but if AppOpsX does it and it works then that's great

@MuntashirAkon
Copy link
Owner

MuntashirAkon commented Jun 15, 2020

It seems most methods that are used to modify permissions are restricted in the latest APIs. There are some methods to bypass this restriction but I'm not sure if it worth it. My three days of effort ends here, I think. Regarding #2, I will only add a switch next to permissions that can be revoked using the pm command (only dangerous permissions can be revoked by pm by the way).

Modifying/rebuilding apk on the fly seem to be the only viable solution for newer versions of Android. But I've no idea how to get started yet.

EDIT: Accessing certain methods now requires android.permission.UPDATE_APP_OPS_STATS permission which is only granted to the system apps. So, unless my app is a system app, there's no way to achieve this. So, it's a lost cause now.

@MuntashirAkon
Copy link
Owner

Related wiki article: How to control application components without root

@MuntashirAkon
Copy link
Owner

AppOps-related discussion is moved to #17.

@MuntashirAkon
Copy link
Owner

MuntashirAkon commented Jul 2, 2020

I've finally decided to add support for app manifest editing, hopefully in v2.6. But I'm not sure how the F-Droid repo owners will react to that.

@MuntashirAkon MuntashirAkon changed the title [Feature] Rebuild APKs Rebuild APKs Jul 2, 2020
@MuntashirAkon MuntashirAkon added the Feature New feature or request label Jul 2, 2020
@Atrate
Copy link
Contributor Author

Atrate commented Jul 16, 2020

So, unless my app is a system app, there's no way to achieve this. So, it's a lost cause now.

Might be outdated now, but a Magisk module could be used to make AppManager a privileged system app. I could quickly spin such a module up and AM would just DL and install the zip if the user needed such functionality.

@MuntashirAkon
Copy link
Owner

Might be outdated now, but a Magisk module could be used to make AppManager a privileged system app. I could quickly spin such a module up and AM would just DL and install the zip if the user needed such functionality.

Current method of setting app ops is a bit slow but works. So, I won't be working on this any time soon.

@Atrate
Copy link
Contributor Author

Atrate commented Aug 14, 2020

@MuntashirAkon
Copy link
Owner

Closing in favour of #138 (this thread contains too many off-topic comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request Priority: 5 Lowest priority
Projects
None yet
Development

No branches or pull requests

2 participants