ungoogled-software / ungoogled-chromium-android

Android build for ungoogled-chromium
GNU General Public License v3.0
495 stars 42 forks source link

Install extension via File Manager #49

Closed ungubajue90k closed 3 years ago

ungubajue90k commented 3 years ago

Please explain why your feature request fall into the scope of ungoogled-chromium? Hello,

I have no way to install extension on ungoogled-chromium android via file manager.

Please describe the feature you would like to have It would be good if ungoogled-chromium android could install extensions that the user has on his android device as a file (.crx) or as a folder (subfolder with many files locally).

Describe the solution you'd like The solution is, for example, when installing folders, navigate to the extension area as on the Desktoo version and select the folder. Here is a Chromium extension where the user has to select the folder. Please unzip the file https://github.com/gorhill/uBlock/releases/download/1.32.4/uBlock0_1.32.4.chromium.zip

For .crx file, the user can simply open the .crx file in default file manager on Android and select ungoogled-chromium Android. Then an installation window appears and the user can add it. It is also possible to select multiple .crx files and install them all with one click.

Describe alternatives you've considered There is no alternative.

Additional context I think it's possible to do it on current Android devices.

I use a Samsung Galaxy Note 20 (Android 11, OneUI 3) and Huawei Mate 40 (Android 10, EMUI 11).

ghost commented 3 years ago

Please explain why your feature request fall into the scope of ungoogled-chromium? Hello,

I have no way to install extension on ungoogled-chromium android via file manager.

Please describe the feature you would like to have It would be good if ungoogled-chromium android could install extensions that the user has on his android device as a file (.crx) or as a folder (subfolder with many files locally).

Describe the solution you'd like The solution is, for example, when installing folders, navigate to the extension area as on the Desktoo version and select the folder. Here is a Chromium extension where the user has to select the folder. Please unzip the file https://github.com/gorhill/uBlock/releases/download/1.32.4/uBlock0_1.32.4.chromium.zip

For .crx file, the user can simply open the .crx file in default file manager on Android and select ungoogled-chromium Android. Then an installation window appears and the user can add it. It is also possible to select multiple .crx files and install them all with one click.

Describe alternatives you've considered There is no alternative.

Additional context I think it's possible to do it on current Android devices.

I use a Samsung Galaxy Note 20 (Android 11, OneUI 3) and Huawei Mate 40 (Android 10, EMUI 11).

Make sure you using pre release version that has extensions support Open Chrome://extensions Enable dev mode Choose unpack Extension and choose crx file

Done

ungubajue90k commented 3 years ago

Make sure you using pre release version that has extensions support Open Chrome://extensions Enable dev mode Choose unpack Extension and choose crx file

Done

I have tried it with this uBlock Origin .crx file loaded from this page. https://www.crx4chrome.com/crx/31931/

But ungoogled-chromium android crashes all the time. I use this version. https://github.com/ungoogled-software/ungoogled-chromium-android/releases/tag/87.0.4280.141-1-extensions

Does it work on your site when you select this ublock Origin .crx file?

ungubajue90k commented 3 years ago

Here the error message when I install an extension by folder inside in ungoogled-chromium android under chrome://extensions/ and Developer mode is enabled.

Failed to load extension File ///storage/emulated/0/Download/uBlock0.chromium Error Manifest is not valid JSON. Can't read file. Could not load manifest.

wchen342 commented 3 years ago

Most likely because Android 10+ changed the file permission system. Did you try enabling "Allow from unknown source"?

wchen342 commented 3 years ago

Also chromium cannot read crx file directly. You need to unpack it first and select the folder (not the json file).

ungubajue90k commented 3 years ago

Most likely because Android 10+ changed the file permission system. Did you try enabling "Allow from unknown source"?

I also have "Allow from unknown source" enabled and the app still crashes. I cannot install the extension (.crx).

wchen342 commented 3 years ago

Did you unpack it? Also post the full log please.

ungubajue90k commented 3 years ago

Also chromium cannot read crx file directly. You need to unpack it first and select the folder (not the json file).

As I said before this is just the error message, I posted in the report the original uBlock Origin github page.

There I have loaded the .zip file and unzip it. The folder is called this, uBlock0.chromium /storage/emulated/0/Download/uBlock0.chromium

Then I selected it with AOSP Files and it shows the error message. Failed to load extension File ///storage/emulated/0/Download/uBlock0.chromium Error Manifest is not valid JSON. Can't read file. Could not load manifest.

I only allowed the folder and did not select a file.


Same problem also when I unzip your new idea with .crx file and select this folder, this time another error message appears:

Failed to load extension File /// Error Manifest file is missing or unreadable Could not load manifest.

ungubajue90k commented 3 years ago

Did you unpack it? Also post the full log please.

Works on your site with Android 10 or Android 11 devices? I have posted in the report the original uBlock Origin github page.

What do you mean Full Log? Do I need a computer? If so, is that a problem because I know exactly how to do it.

wchen342 commented 3 years ago

I have investigated this before and it is very likely unfixable. The problem is caused by scoped storage and is a "feature" (as Google put it) in Android system itslef, which I cannot change.

What do you mean Full Log?

See the XDA tutorial on how to get log.

Also this has nothing to do with uBlock Origin. Do not post to their issue trackers.

wchen342 commented 3 years ago

@csagan5 I think there is a bug in Add-bookmark-import-export-actions.patch. In SelectFileDialog.java, there is

private static final String HTML_TYPE = "text/html";

and

return countAcceptTypesFor(HTML_TYPE) > 0;

, but countAcceptTypesFor has

assert superType.indexOf('/') == -1;

in its first line.

Did you run into problem with the patch?

ungubajue90k commented 3 years ago

@wchen342 Here is the Full log, is this sufficient?

I do not know if it is full log, just clicked logcat and launched the ungoogled chromium app and tried to install the extension (folder selection).

log.txt

wchen342 commented 3 years ago

As I suspected chromium cannot see the file. Which way did you use to select the path? Also did you give chromium Storage permission?

wchen342 commented 3 years ago

I can reproduce it locally now. I think the logic I previously used to get the media storage Uri from absolute path no longer works.

I will try to search around to see whether there is an updated method. If there is not then probably this cannot be fixed.

ungubajue90k commented 3 years ago

As I suspected chromium cannot see the file. Which way did you use to select the path? Also did you give chromium Storage permission?

Yes I have allowed the "Storage" access manually before. By default it is denied.

ungubajue90k commented 3 years ago

I selected the path with Files. I need to take the left Files for folder. The right Files is for file. IMG_20210123_160947

csagan5 commented 3 years ago

Did you run into problem with the patch?

Asserts are not enforced in release builds? Thanks for spotting that, it needs to be fixed.

wchen342 commented 3 years ago

@csagan5 It doesn't lead to a crash but it prevented me from opening file selection dialog.

~@ungubajue90k Did it work with folder selection then?~ Nevermind, I see you are answering my question.

ghost commented 3 years ago

Most likely because Android 10+ changed the file permission system

Heh that's why i do not update my android 10 with latest security patches mweheheheh :3

wchen342 commented 3 years ago

I have included a potential fix in the new version. Let me know whether it works.

ungubajue90k commented 3 years ago

I have included a potential fix in the new version. Let me know whether it works.

Thanks good work. ❤

My first tests with Android 10 devices works. I have loaded original uBlock Origin (folder) and it was installed. But there is an error when I open the same website in incognito mode the ads are not blocked, without incognito mode it works.

Other question, how can I see which tracker is blocked by uBlock Origin? There is no quick overview for the extension, how can I enable it, similar to ungoogled chromium (desktop version)?

On Android 11 devices I will test later, will give a feedback.

Edit Now no longer works, I have test on Android 10 and 11 deleted the app and completely reinstalled and allowed the permission storage. When I select it the folder happens the same error, again. as I have already written.

ghost commented 3 years ago

But there is an error when I open the same website in incognito mode the ads are not blocked, without incognito mode it works.

Open chrome://extension click detail on ublock Turn on allow in incognito mode 🤦🤦🤦🤦🤦

ungubajue90k commented 3 years ago

But there is an error when I open the same website in incognito mode the ads are not blocked, without incognito mode it works.

Open chrome://extension click detail on ublock Turn on allow in incognito mode 🤦🤦🤦🤦🤦

I also did that with incognito allow, but it still did not block.

Current status, as already written, the installation in general no longer works. Edited the previous post before your reply came.

wchen342 commented 3 years ago

Now no longer works

Can you again post the log?

in incognito mode the ads are not blocked

It is expected. I fixed extensions only in non-incognito mode at this time, since it is a huge change and I have to break it down to smaller steps.

Other question, how can I see which tracker is blocked by uBlock Origin

This is #21. It will need an Android GUI which I will discover how later.

ungubajue90k commented 3 years ago

Can you again post the log?

Ok no problem here the log. log 2.txt

wchen342 commented 3 years ago

Did you enable "Allow from unknown source"? The java part seems to be working correctly.

ungubajue90k commented 3 years ago

Did you enable "Allow from unknown source"? The java part seems to be working correctly.

No forget. Sorry.

It works now the Permission "Storage" and "Allow from unknown source" must be enabled, then I can install it this folder.

It would be good if you can integrate a message when users install extension for the first time, that then a message appears that e.g Permission "Storage" and "Allow from unknown source" must be enabled.

There should also be a button integrated in the message to go directly to these settings, something like a setup. This setup always appears again when user has disabled the "Storage" and "Allow from unkown source" and tries to install an extension.


Others problem: When I select a .crx file to install it does not work. The App crashes immediately.

wchen342 commented 3 years ago

The developer mode does not have a way to install crx file directly. This is the same as on desktop.

ungubajue90k commented 3 years ago

The developer mode does not have a way to install crx file directly. This is the same as on desktop.

I understand I have found a way, the .crx file must be unpacked, after unpacking there is a folder and I can select and install in ungoogled-chromium android.

I have MiXplorer and the addons MiX Archive loaded from the developer directly. https://drive.google.com/drive/folders/1bXUO38CsuN3J8Iykjp44IkAZ5idgwUMg

Can you add this tutorial for .crx file method in this github page?

wchen342 commented 3 years ago

Sorry but what do you mean? I have already included the instructions to unpack and copy the folder in README.

ungubajue90k commented 3 years ago

Sorry but what do you mean? I have already included the instructions to unpack and copy the folder in README.

I read your tutorial but you didn't mention an app and with standard file manager I couldn't unzip the .crx file and searched and found this file manager app and it worked.

Maybe you know an open source app that can unzip .crx file.

wchen342 commented 3 years ago

unzip and 7z are pretty standard tools on Linux, and 7-zip has a windows version too. If you meant to extract crx file on an Android device then I am not aware of a good open sourced app that can do so. There is an app named Ghost Commander on F-Droid but I didn't test it.

ungubajue90k commented 3 years ago

unzip and 7z are pretty standard tools on Linux, and 7-zip has a windows version too.

I very rarely use computer because I am often on the road. Only use mobile devices like Android and maybe in the future real Linux smartphone e.g. PinePhone.

If you meant to extract crx file on an Android device then I am not aware of a good open sourced app that can do so. There is an app named Ghost Commander on F-Droid but I didn't test it.

Tested with Ghost Commander and it does not work, also tried to change the file extension to .zip to extract but always error message. Do you have any other open source app suggestion?

wchen342 commented 3 years ago

I searched around for a while and found this: https://www.reddit.com/r/opensource/comments/gy1pt0/7zip_on_android/

The first app is a wrapper of p7zip and it is on Google Play. Or you can get Termux which is a terminal simulator from F-Droid, and install p7zip directly from inside the terminal.

ungubajue90k commented 3 years ago

Or you can get Termux which is a terminal simulator from F-Droid, and install p7zip directly from inside the terminal.

Here is a guide on how it worked. You can add it if you want.

  1. Download Termux and Material Files and install the .apk file on your Android device.

  2. Create a new folder in Material Files e.g with the name uBlock Origin 1.32.4 and copy the path. Just hold on this folder and tap on Copy path. You will see a short message: '/storage/emulated/0/Download/uBlock Origin...' copied to clipboard

  3. Open Termux and type this command to get "Storage" permission termux-setup-storage -> y -> Allow. Alternatively, simply press and hold the Termux app on the Home screen and click on "App info" and allow "Storage" under Permissions.

  4. Install p7zip type this command: pkg install p7zip.

  5. When p7zip is installed. Go to the target directory where you want to extract the file onto. Paste the path you copied from Material Files. cd "[paste path]". For example this looks like cd "/storage/emulated/0/Download/uBlock Origin 1.32.4".

  6. Reopen Material Files and copy the path with Copy path the .crx file for example will look like this /storage/emulated/0/Download/uBlock Origin 1.32.4.crx

  7. Reopen Termux again enter this command: 7z x "[paste path]" For example this looks like 7z x "/storage/emulated/0/Download/uBlock Origin 1.32.4.crx".

  8. Done. The .crx file is extracted. Have fun. ❤