Enhance installation and cleanup processes(#29)
This pull request includes several changes to improve the functionality and stability of the LSPatch application. The most important changes include modifications to the AndroidManifest.xml file, updates to the LSPApplication and Patcher classes, and enhancements to the NewPatchScreen and AppManagePage user interfaces.
Permissions and Providers:
- Added the
REQUEST_INSTALL_PACKAGESpermission to theAndroidManifest.xmlfile. - Added a
FileProviderto theAndroidManifest.xmlto support file sharing.
Application and Patching Logic:
- Introduced a new
targetApkFileproperty inLSPApplicationto handle APK files. - Updated the
Patcherclass to copy the APK to the external cache directory and assign it totargetApkFile.
User Interface Enhancements:
- Modified
NewPatchScreento include a newInstallDialog2for handling APK installations with additional uninstall logic. - Added functions to
Utils.ktto check if an APK is fixed by LSP, install APKs, and uninstall APKs by package name.
Clean-Up and Utility Functions:
- Added a method to clean the external temporary APK directory in
LSPPackageManager. - Created a new XML file
file_paths.xmlto define paths for file sharing.
I will begin reviewing when I finish my PhD thesis (soon), please feel free to improve current PR.
For the local mode, i.e., when useManager = False, you choose to embed the loader.
I am not sure whether this is a good design, I may thus choose to skip the third commit.
Do you find any advantage of doing so?
This can be convenient to a certain extent. If there are no changes for a long time, the user experience will be better. However, many users are now reporting that this causes the program to crash.
According to the log, the crash is caused by the core not being loaded.
I see, I'd prefer to see the user bug reports. We can keep it as another possible pull-request in the future. You may keep it in another branch of your repo.
Let us focus on the native installation. Currently, most installed application from play store are using split APK delivery.
However, the simple Intent method is no longer sufficient to handle multiple APKs.
It is recommended to use PackageInstaller for split APKs. Could you please improve / check this point?
To test it out, you can try patching Spotify installed from Google Play as an example.
use PackageInstaller for split APKs?
I meant, currently, only PackageInstaller can handle split APKs installation. You need to create a PackageInstaller session and so on.
I don't understand
Okay, here is what I mean.
Problem in you code
You code cannot handle split APK installation, which thus fails to patch most applications installed from Google Play store, such as Spotify. Note that in this case, LSPatch modfies each split APK, and these modified APKs need to be installed at the same time.
My suggestion to solve this
I suggest you to read the official doc of the PackageInstaller API, since this is the official way to handle monolithic APK and split APKs. After reading its doc or maybe some other resources, you should be able to finally solve this problem.
Futher details of this API
This API has a concept of session, by handling all split APKs during a created session, you will manage to correctly install them into the device.
OK, now I understand. I will take a look at it when I have time.
Is the code written by AI, and you were talking with it in Chinese?
Is the code written by AI, and you were talking with it in Chinese?
The annotations were written by the AI, while the overall logic was completed by myself.
AI generated code are really low, you should double check. At least, please log in English, and use the TAG properly. No stupid comments from AI.
Recently, I have been in the habit of using AI to generate comments to organize the logic after writing the code. However, when submitting, I forgot to delete them.
Please rebase on the master branch, remove the two commits, https://github.com/JingMatrix/LSPatch/pull/33/commits/8dba96296b62747c92c61ad68bc9d168b4d476e5 and https://github.com/JingMatrix/LSPatch/pull/33/commits/feea434ccba46dff037b71a54d8bb20ac0afb963.
You can keep them in another branch of your repo.