M66B/XPrivacy

File manager not detected

Closed this issue · 23 comments

  • can you name the created file with a HH-DD/MM/YY name
  • can you not overwrite the previously exported files config ? so we can have an exported files history.
  • can we choose the file we would like to import
M66B commented

Could you please test if this is okay for you: http://d-h.st/Eyb
I tested with OI File Manager: https://play.google.com/store/apps/details?id=org.openintents.filemanager
Not all file manager let XPrivacy specify the folder and file type.

I just used Export, now the file name is YY-MM-DD-HH

EZ file Explorer didn't show straight the .Xprivacy folder
AndroXplorer didn't show straight the .Xprivacy folder
Total commander didn't show straight the .Xprivacy folder
The stock browser seems to be not an option
Have no problem to browse backup

M66B commented

Try OI File Manager

I just got PRO version from you.

But this feature is not working. I am using latest nightly of LegacyXperia CM10.2 Android 4.3.

When I click export, it directly writes in /sdcard/.xprivacy/XPrivacy.xml

It overwrites it everytime without asking for confirmation.(If you accidentally happen to touch "Export" the old exported setting is overwritten)

I installed OI File manager but it seems its not calling OI File manager. (However it shows popup to save to google drive or so)

If you import, again it automatically imports without asking for filename/directory. (I hope clicking on import twice will not cause duplicate entries or something internally)

Also a suggestion, filename should not be hour dependent. It should be XPrivacy-YYYYMMDDHHMMss.xml

This way I can test things easily making sure I have backup of latest "stable" settings. Or I can revert back easily one by one in reverse order.

M66B commented

In the next release seconds will be added to the file name, so there will be no more overwrites.

If there is no suitable file manager, the file name will be /sdcard/.xprivacy/XPrivacy.xml
If there is a suitable file manager, the file name will be /sdcard/.xprivacy/XPrivacy_yyyyMMdd_HHmmss.xml
OI File manager is a suitable file manager.

But I have installed OI File Manager. I even rebooted after installing OI File Manager.

Still its not asking me for file name.

Do I have to do some settings? I searched in XPrivacy as well as OI File manager but could not find anything.

Oh wait sorry. The files are there!!!

I was under impression that it will ask me for filename. But I didnt realize that it will NOT ask for name but its still storing as per above naming convention.

Sorry for causing confusion. Its working as expected.

Ok I was going through code (I have not fully understood it) but I failed to understand why do u need OI File Manager for exporting?

But I think you can eliminate requiring OI File Manager.

In line 74 of src/biz/bokhorst/xprivacy/ActivityShare.java
exportTask.executeOnExecutor(mExecutor, new File(fileName));

If you change it to,
exportTask.executeOnExecutor(mExecutor, new File(getFileName(true)));

It should eliminate need for OI File Manager for exporting.

Line 63:
String fileName = (extras.containsKey(cFileName) ? extras.getString(cFileName) : getFileName(false));

can be moved inside //Import if() statement.

Again I have not fully understood the code but to me it appears right way which will not require OI File Manager for exporting.

For importing, I think android File Manager works.

If you want I can create pull request.

M66B commented

Support for (OI) File managers was explicitly request, so this will not be removed, sorry.

No no I am not asking you to remove support for OI File manager. OI File manager comes in to picture only for importing.

What I am saying is that, if you dont have OI File Manager, and then u try to export, then File name does not have XPrivacy_yyyyMMdd_HHmmss.xml format.

If you change the code as I mentioned above (assuming I understood it right) then filename will be exported in XPrivacy_yyyyMMdd_HHmmss.xml format even if OI FIle Manager is not installed which I think is right way,

M66B commented

The idea is that if there is no suitable file manager installed the file name for importing/exporting is the same (without time component in the file name). If the exported file name is XPrivacy_yyyyMMdd_HHmmss.xml when there is no suitable file manager installed, importing would be hard.

What is exactly your problem?
Do you have a suitable file manager installed?
Is is correctly detected by XPrivacy?
Does the file manager pop up when importing/exporting?

Ok this is lengthy but let me explain.

First of all forget my above code changes which I suggested. I realized that related code is in ActivityMain.java and not ActivityShare.java

This is original request (from 1st post of this ticket).

  1. can you name the created file with a HH-DD/MM/YY name (- you solved this)
  2. can you not overwrite the previously exported files config ? so we can have an exported files history. (1 automatically solves this as well)
  3. can we choose the file we would like to import (this needs file manager, CM File Manager, OI File manager, Google Drive, File Manager by rhmsoft etc. work)

Nowhere he has asked for OI File manager.

I have Google drive, CM File manager and File manager by rhmsoft. Assume that currently I have not installed OI File manager.

The problem is here: line 811 file ActivityMain.java (function optionsExport())
boolean multiple = Util.isIntentAvailable(ActivityMain.this, Intent.ACTION_GET_CONTENT);

Now even if CM File Manager, Google Drive, File Manager by rhmsoft support "choosing a file" for import, somehow above line returns false. So your code stores exports in file Xprivacy.xml.

Now I install OI File manager

OI File manager turns that line to true and code exports file as XPrivacy_yyyyMMdd_HHmmss.xml

Now I want to import the file.

Now lets see line 818 in function optionImport()
if (Util.isIntentAvailable(ActivityMain.this, Intent.ACTION_GET_CONTENT)) {
Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT);

Since this function is true due to existence of OI File Manager, you will realize that the "popup" shows you not just OI File manager, but also CM file manager, Google drive, and rhmsoft file manager.

See images, all three are allowing me to "pick / choose a file". (that is when I click Import)

screenshot_2013-08-31-16-45-48
screenshot_2013-08-31-16-46-23
screenshot_2013-08-31-16-46-55
screenshot_2013-08-31-16-47-17

1st pic: XPrivacy first asks me which importer to choose (Drive, CM File manager, etc.)

2nd pic: CM File manager asking me to pick a file for importing

3rd pic: Google drive asking me to pick a file for importing

4th pic: Rhmsoft file manager asking me to pick a file for importing

Clearly those file managers also allow you to choose file for importing. But isIntentAvailable() returns false somehow.

Also it is safe to assume that person who installs Xposed framework / Xprivacy definitely has good file manager installed.

So I think its safe to assume that File can always be exported safely in XPrivacy_yyyyMMdd_HHmmss.xml without checking for isIntenetAvailable().

It will be very rare that person installing Xposed framework and Xprivacy does not have above or equivalent file manager which does not allowing choosing a file.

M66B commented

"Clearly those file managers also allow you to choose file for importing. But isIntentAvailable() returns false somehow." So, this is the real problem.

"Also it is safe to assume that person who installs Xposed framework / Xprivacy definitely has good file manager installed." No, we cannot assume that, there are also a lot of novice users that care about privacy.

Can you try to figure out why isIntentAvailable returns false?
Is the function erroneous or is being checked for the wrong intent?

M66B commented

Can you check if the above commit fixes your problem?

I am sorry to tell you that I have not setup anything on my PC related to android development. So I can not check if it has fixed it because I can not generate APK.

I read the code on github and try to debug by imagination! :)

If you can generate APK and give me link then i would gladly test it.

M66B commented

Test version 1.9.10: http://d-h.st/bqy

Nope. Not working with 1.9.10 its saving file as XPrivacy.xml i.e. date strings.

Still needs OI File manager.

In your latest FIX you may have to use GET_INTENT_FILTERS instead of flag 0
http://developer.android.com/reference/android/content/pm/PackageManager.html#GET_INTENT_FILTERS

OR

See this it suggests use of PackageManager.GET_ACTIVITIES whereas in your earlier code you had used PackageManager.MATCH_DEFAULT_ONLY.

http://stackoverflow.com/questions/11679996/pick-a-file-using-intent-action-get-content

M66B commented

This is a version with the original code restored, but using PackageManager.GET_ACTIVITIES: http://d-h.st/I6u

Nope not working as well.

You have not used one line from that example.
intent.setType("file/*");

Dont know if its really needed.

M66B commented

Test version: http://d-h.st/w5l

Finally it worked!!

Great work. No more dependent only on OI File manager.

It appears that setType was the one missing.

And whatever is default for setType (when not used) was defined by OI File manager as available intenet and hence it was working not the rest.

But now with file/* all of them work!

Thanks.

M66B commented

Thanks for testing!