agamemnus / cordova-plugin-xapkreader

Easily access Google Play APK expansion file data.
32 stars 55 forks source link

OBB file on extSD #122

Open BobAchgill opened 6 years ago

BobAchgill commented 6 years ago

Not sure if this is an issue but I don't seem to be able to manually test my OBB file when it is on the external SD. Works OK when on the internal SD. Should it work on the External SD using these or other settings? I would like to target the extSD ... just because there is more space there!

I am using ... Command line :

  cordova platform add android@6.0.0

config.xml :

<preference name="android-maxSdkVersion" value="24" />
<preference name="android-installLocation" value="preferExternal" />
agamemnus commented 6 years ago

Not sure. It should work theoretically. Is that the settings for Cordova 6.5? Try it on that version first...

BobAchgill commented 6 years ago

I am using Cordova 6.5.0

Surely someone has experience using the xapkreader plugin and stores the obb files on the extSD.

I tried looking in stack overflow with this search... Cordova expansion file extsd

... but no hits.

agamemnus commented 6 years ago

Yeah I think someone else wrote about this in the issues pages? It just gets really complex. I completely forgot all the details.

BobAchgill commented 6 years ago

Does xapkreader do anything in the code to support accessing the OBB file if the it is not located on the internal SD but instead located on the extSD? Or does Android OS just handle switching the path so that the app is agnostic as to on which storage the the OBB is stored?

agamemnus commented 6 years ago

There is indeed code there to figure out the path...

BobAchgill commented 6 years ago

... but is there the switch code between internal and extSD?

Who originally wrote the xapkreader plugin? Are they still around?

agamemnus commented 6 years ago

Intel. But then I reworked it.

https://github.com/agamemnus/cordova-plugin-xapkreader/blob/cordova-6.5.0/src/android/XAPKExpansionSupport.java

That file has the code for figuring out the path...

BobAchgill commented 6 years ago

OK thanks! I will try to see if this solves the problem of making the cordova app with OBB file movable to the SD card.... https://ourcodeworld.com/articles/read/171/how-to-enable-the-move-to-sd-card-feature-in-a-cordova-app-for-android

BobAchgill commented 6 years ago

The link above had me add the cordova-custom-config plugin which made sure the android:installLocation="preferExternal" is automatically taken from the Config.xml and "properly" added to the manifest so the app can be movable by the user to and from the External/Internal storage.

So now when i look at the app's storage settings [on my S7] I get the option to move the app to the external storage. It dutifully runs a gas gage showing that the app (and data?) are being moved to the external storage. When complete the app storage location indicator changes from Internal to External.

I looked at the external storage with a file manager and no folder was made for the app data being moved to external. When I run the app it [runs!] but appears to still be using the internal obb file. I know this because when I rename the internal obb app folder the links to the obb file no longer work.

Any ideas why the obb folder/file would not have been copied over?

When I try manually copying the obb folder/file over to the correct location on the external SD the app does not try to read it there.

I thought maybe it is a permissions thing... but the manifest shows this line... <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Is there a forum where would be best to ask for help on this?

agamemnus commented 6 years ago

Android Central, perhaps.

On Thu, Apr 19, 2018, 1:05 AM BobAchgill notifications@github.com wrote:

The link above had me add the cordova-custom-config plugin which made sure the android:installLocation="preferExternal" is automatically taken from the Config.xml and "properly" added to the manifest so the app can be movable by the user to and from the External/Internal storage.

So now when i look at the app's storage settings [on my S7] I get the option to move the app to the external storage. It dutifully runs a gas gage showing that the app (and data?) are being moved to the external storage. When complete the app storage location indicator changes from Internal to External.

I looked at the external storage with a file manager and no folder was made for the app data being moved to external. When I run the app it [runs!] but appears to still be using the internal obb file. I know this because when I rename the internal obb app folder the links to the obb file no longer work.

Any ideas why the obb folder/file would not have been copied over?

When I try manually copying the obb folder/file over to the correct location on the external SD the app does not try to read it there.

I thought maybe it is a permissions thing... but the manifest shows this line...

Is there a forum where would be best to ask for help on this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/issues/122#issuecomment-382611555, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWPiy7jm5VGodUZlPJDVFT5RMOAHmks5tqBsygaJpZM4TXp_3 .

BobAchgill commented 6 years ago

I posted this to Android Central... https://forums.androidcentral.com/android-apps/883693-expansion-file-not-moved-extsd.html#post6226447

Expansion file not moved to extSD

When I try to use the app storage setting menu on my S7 to move my app made with Cordova from internal to external storage the OBB expansion file does not move over though the app storage settings indicator does change from internal to external.

agamemnus commented 6 years ago

I just don't know the appropriate settings here, and it changes all the time to boot...

BobAchgill commented 6 years ago

Also posted the question on the Android Forums... https://androidforums.com/threads/cordova-obb-expansion-file-not-moved-to-external-storage.1264878/

BobAchgill commented 6 years ago

Looks like, from Android5.0 onwards, cordova-plugin-xapkreader plugin would need to be upgraded to support using the serial number of the extSD in the path in order to support moving the app and OBB to the extSD...

From Android 5.0 onwards, the location of the external (removable) SD is no longer a fixed path. Instead, the serial number of the SD card is used in the path. For example, on my Samsung Galaxy S4 which is running Android 7.1.1, the physical external removable SD card path is /storage/4975-1401/.

... or is there a way to hack so that cordova-diagnostic-plugin can be used to make cordova-plugin-xapkreader redirect to the correct place to both move/write and read the externally stored OBB?

BobAchgill commented 6 years ago

I posted this feature request to cordova-diagnostic-plugin for some how it to help cordova-plugin-apkreader in storing app and OBB expansion files on external storage. https://github.com/dpa99c/cordova-diagnostic-plugin/issues/299

BobAchgill commented 6 years ago

Dave Alden with cordova-diagnostic-plugin says:

getExternalSdCardDetails() will provide the filepath(s) to external removable storage locations.

These filepaths can be used along with cordova-plugin-file to read/write files to this location. Or you could enhance cordova-plugin-xapkreader to do this.

getExternalSdCardDetails() is a function in his cordova-diagnostic-plugin.

@agamemnus are you able to add external (removable) storage support to cordova-plugin-xapkreader so that apps (Android 5 and beyond) can have their install moved to extSD ?

agamemnus commented 6 years ago

Maybe you can try updating the code and then submit a PR? I am very busy... if not, maybe the weekend.

BobAchgill commented 6 years ago

I'm not a developer. :(

Most of my users in developing countries will not have enough internal free space to install the free 1.5GB literacy app. Hence, my quest to get the support for ...

<preference name="android-installLocation" value="preferExternal" />

to work.

One other random thought... Can I just compile using something less than android@5 and skirt the issue that way? Or does this issue result because the device's Android level is beyond 5?

agamemnus commented 6 years ago

The latter, I am pretty sure.

BobAchgill commented 6 years ago

Your donor gittip link does not work in your readme.

agamemnus commented 6 years ago

Ha. Yeah they shut the system down. How about I will update that when I also update the file system code?

On Tue, Apr 24, 2018, 9:36 PM BobAchgill notifications@github.com wrote:

Your donor gittip link does not work in your readme.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/issues/122#issuecomment-384133408, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWNuyslTrdPdzqA2CHlGxB_HRb0eyks5tr9MggaJpZM4TXp_3 .

var18k commented 6 years ago

Yeah same problem here. Pls give a solution for how to move obb on SD.

BobAchgill commented 6 years ago

@agamemnus any chance you can implement this fix soon?

agamemnus commented 6 years ago

getExternalSdCardDetails is a function on cordova-diagnostic-plugin... so I would have to copy their code.... not an MIT license..... bit of a headache...... might have to do my own.

Maybe this weekend, sorry.

BobAchgill commented 6 years ago

Any progress over the weekend?

agamemnus commented 6 years ago

I am on a deadline for a thing, so no progress.

BobAchgill commented 6 years ago

Maybe this weekend?

agamemnus commented 6 years ago

Maybe.

On Fri, May 11, 2018 at 1:28 PM, BobAchgill notifications@github.com wrote:

Maybe this weekend?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/issues/122#issuecomment-388431059, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWFLYA7C9kfk60j0wRyitRjL9GEYRks5txcpEgaJpZM4TXp_3 .

BobAchgill commented 5 years ago

Maybe this week?

agamemnus commented 5 years ago

Maybe...

On Tue, May 29, 2018, 2:14 AM BobAchgill notifications@github.com wrote:

Maybe this week?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/issues/122#issuecomment-392663735, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWFBP9Pfa6y-BzEP-SNC-UJzrrzP8ks5t3OdEgaJpZM4TXp_3 .

agamemnus commented 5 years ago

Bob,

Thank you so much for waiting. I hope you still need this. I have earmarked some time this weekend to work on it and help you solve this issue.

BobAchgill commented 5 years ago

Wonderful! Yes, I still need this.

BobAchgill commented 5 years ago

Any progress?!

agamemnus commented 5 years ago

Unfortunately I had an unexpectedly large amount of other work on the weekend. I'm about to go to sleep. Maybe, maybe, tomorrow...

On Tue, Jun 12, 2018, 3:19 AM BobAchgill notifications@github.com wrote:

Any progress?!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/issues/122#issuecomment-396491008, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWEepjAWrFl7w-rP1Oa_2lodn78gCks5t72uPgaJpZM4TXp_3 .

agamemnus commented 5 years ago

Looks like I had a pull request open with some changes to the code that might fix it. Does it work?

BobAchgill commented 5 years ago

Tell me how to use that version as opposed to the normal version and I'll test it!

agamemnus commented 5 years ago

It's the same now (i.e.: 6.5).

BobAchgill commented 5 years ago

There is progress... I tested the pull on an Android 7 device...good news/bad news... 1) The obb dir/file does NOT get moved when app is moved to extSD using move control from the app Storage location button. 2) However, now the app WILL read the OBB file on the extSD if placed there manually! 3) Interesting that the app DOES delete the OBB file on the extSD when the app is deleted.

For some reason the expansion file does not work at all... either internal or extSD when I tested on an Android 4.4.2 device.

agamemnus commented 5 years ago

So then the question is, what actually happens when you press that button? Maybe there is a function that runs that we could implement to copy over the files?

The 4.4.2 issue is troubling, also.... but presumably, only a tiny fraction of users (er, 10.5% as of April...) are still on version 4 of Android, as version 5 was made public 3 years ago....

BobAchgill commented 5 years ago

Correction on my testing... 4.4.2 DOES work but it persists in only using the internal OBB expansion file even when it should be using the external OBB expansion file.

The adding code to move the OBB directory and expansion file to the extSD and back sounds good. So the Android OS doesn't do that??

I say "move " because that frees up the space on the internal memory... the whole reason for moving an app to the extSD. And being able to move back... because the user sees a button that allows that round trip.

agamemnus commented 5 years ago

Maybe not: http://www.tomshardware.com/answers/id-2798563/move-obb-data-files-andriod-card.html

Perhaps one way is to check the obb folder on startup... if it doesn't have the files, check the other location, see if they are there, and then (if they're there) ask the user if they want to move the files. If they aren't, then re-download the files...

But at this point, isn't the primary problem solved?

BobAchgill commented 5 years ago

Original Question... "Not sure if this is an issue but I don't seem to be able to manually test my OBB file when it is on the external SD."

I don't know the stats for Android 4 devices in developing countries. That's my target. It would be nice if "they" were included in the "fix" if it's easy to determine why the code on Android 4 devices is still looking for the OBB expansion file on the internal storage when the app has been moved to extSD. The cheaper phones have less internal storage hence the reason I'm trying to give the user the extSD app/data store option.

If you want me to open a separate issue for the remaining questions ... I can.

Remaining parts... 1) move OBB expansion dir/file to/from extSD when app moved 2) access OBB expansion file on extSD for Android 4.x

Though these two issues seem to be integral to the subject issue.

I see that your idea for moving the data will work but why not use the app move button to trigger the move process? Does the move button force a shutdown of the app as its moved? If so then yes... that solution will be good. Otherwise, wouldn't the user be left wondering why the data did not get moved when the app was moved?

And one more 3) support app install preference to target OBB storage on internal vs extSD.

agamemnus commented 5 years ago

"I see that your idea for moving the data will work but why not use the app move button to trigger the move process?"

Well, that would only work if there was some instant way for the app to know that happened. There might or might not be a way. I couldn't find a way yet. But definitely on startup it would know if the files were missing...

I am still lost on how this process that you want should happen and what happens now... I think you mentioned it before, but I forgot. So the user downloads it from the app store and then you tell them to move it? Or...

BobAchgill commented 5 years ago

This will be added to the config so that the install will default prefer installing the apk and OBB externally if the extSD exists. The plugin will find this install setting in the manifest. If the app developer chooses not to set this I think it defaults to "auto" or "internal".

<manifest xmlns:android="http://schemas.android.com/apk/res/android"     android:installLocation="preferExternal"     ... >

Later the user can opt to move the app/OBB expansion data to internal using the application storage option button.

Reference: https://developer.android.com/guide/topics/data/install-location

agamemnus commented 5 years ago

But does the user even know this option exists though? What % of the time are they trying to do it?

If this is something a lot of users want, maybe it would be better to ask directly in the app (on launch) where the user wants it stored.

BobAchgill commented 5 years ago

It seems to be pretty much a standard that apps that are extSD storage enabled give the control button in the app storage setting window. It was hard for me to find that button but that is where it is... typically.

As far as offering the choice of where to store the expansion file (internal or extSD) at initial launch... What you suggest would be better than just defaulting them to whatever the app developer wants to set as default. Are you able to check how big the expansion file is before download so that you can give them stats on where it might fit the best?

If you can't give the user storage footprint comparison stats then I'm fine with going with using the Storage preferred location setting in the config.

95 percent of my users will never have enough internal room to store the 1.5GB expansion file... so asking them at launch with stats will just be a good reminder that they will soon need larger extSD. :)

agamemnus commented 5 years ago

Normally, the obb download happens immediately after clicking to download the file from Google Play (at the same time as the apk) ...... I'm not sure what's going on anymore. I forgot if you were even getting the file from Google Play... presumably, you are...

BobAchgill commented 5 years ago

Correct. "The obb download happens immediately after clicking to download the file from Google Play (at the same time as the apk)."

What I am recommending is that the plugin support the preferred storage location attribute that the developer sets in the config. Maybe it does already do this??

I don't know because I have been doing manual tests (without Google play).

BobAchgill commented 5 years ago

Remaining issues... 1) support storage location move button 2) Android 4.x 3) *support preferred storage location attribute in manifest on initial download.

agamemnus commented 5 years ago

I'm just saying, if there is no space it I think will tell you and won't download it, I think. Maybe it will ask if you want to install it in the external drive space. Unclear, memory foggy. You should really just publish it in some way (maybe as a beta test) to test it out.

On Thu, Jun 21, 2018, 11:56 AM BobAchgill notifications@github.com wrote:

Remaining issues...

  1. support storage location move button
  2. Android 4.x
  3. *support preferred storage location attribute in manifest on initial download.

    • maybe it already does this

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/issues/122#issuecomment-399153868, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWNaFCZ65HbODm1BU-BeH0U4Ojcq1ks5t-8IrgaJpZM4TXp_3 .