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

OBB file on extSD #122

Open
BobAchgill opened this issue Apr 17, 2018 · 69 comments
Open

OBB file on extSD #122

BobAchgill opened this issue Apr 17, 2018 · 69 comments

Comments

@BobAchgill
Copy link

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 [email protected]

config.xml :

<preference name="android-maxSdkVersion" value="24" />
<preference name="android-installLocation" value="preferExternal" />
@agamemnus
Copy link
Owner

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

@BobAchgill
Copy link
Author

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
Copy link
Owner

agamemnus commented Apr 17, 2018

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

@BobAchgill
Copy link
Author

BobAchgill commented Apr 17, 2018

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
Copy link
Owner

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

@BobAchgill
Copy link
Author

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

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

@agamemnus
Copy link
Owner

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
Copy link
Author

BobAchgill commented Apr 18, 2018

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
Copy link
Author

BobAchgill commented Apr 19, 2018

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
Copy link
Owner

agamemnus commented Apr 19, 2018 via email

@BobAchgill
Copy link
Author

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
Copy link
Owner

agamemnus commented Apr 20, 2018 via email

@BobAchgill
Copy link
Author

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

@BobAchgill
Copy link
Author

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
Copy link
Author

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.
dpa99c/cordova-diagnostic-plugin#299

@BobAchgill
Copy link
Author

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
Copy link
Owner

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

@BobAchgill
Copy link
Author

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
Copy link
Owner

The latter, I am pretty sure.

@BobAchgill
Copy link
Author

Your donor gittip link does not work in your readme.

@agamemnus
Copy link
Owner

agamemnus commented Apr 25, 2018 via email

@var18k
Copy link

var18k commented Apr 30, 2018

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

@BobAchgill
Copy link
Author

@agamemnus any chance you can implement this fix soon?

@agamemnus
Copy link
Owner

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
Copy link
Author

Any progress over the weekend?

@agamemnus
Copy link
Owner

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

@BobAchgill
Copy link
Author

Maybe this weekend?

@agamemnus
Copy link
Owner

agamemnus commented May 11, 2018 via email

@BobAchgill
Copy link
Author

Maybe this week?

@BobAchgill
Copy link
Author

BobAchgill commented Jun 20, 2018

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
Copy link
Owner

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
Copy link
Author

BobAchgill commented Jun 20, 2018

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
Copy link
Owner

"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
Copy link
Author

BobAchgill commented Jun 20, 2018

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
Copy link
Owner

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
Copy link
Author

BobAchgill commented Jun 21, 2018

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
Copy link
Owner

agamemnus commented Jun 21, 2018

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
Copy link
Author

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
Copy link
Author

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

@agamemnus
Copy link
Owner

agamemnus commented Jun 21, 2018 via email

@BobAchgill
Copy link
Author

Ok!
How about 1 an 2?

@agamemnus
Copy link
Owner

Ok, can try but it just doesn't seem too important if the users will use Google Play as they probably won't be able to download it without sufficient space anyway...

So it wasn't working on 4.x before? Or was? (Are you only testing with 4.x?)

@agamemnus
Copy link
Owner

agamemnus commented Jun 21, 2018

(Although you can change settings on Google Play to set preferred install location... and it just might go to the area with the available space, so seems like a non-issue except for the 4.x problem...)

@BobAchgill
Copy link
Author

I did not test with 4.x before.

@BobAchgill
Copy link
Author

Looks like the method for setting Google Play to download to ExtSD is a hack. It takes over the ExtSD and wipes all other data. Does not appear to be a Google recommended method. And may not work on all devices.

http://www.tomsguide.com/forum/id-3439437/set-downloading-location-play-store-apps-directly-card-samsung-galaxy-grand-prime.html

@BobAchgill
Copy link
Author

BobAchgill commented Jun 22, 2018

I'll do a full system test with downloading from Google play. My guess is that the plugin code handles the download of the OBB file and writes to storage. .... if so then you would make the same changes you made to get Android 5+ to work for reads of ExtSD data.... to the downloader for writes to the extsd.

@BobAchgill
Copy link
Author

BobAchgill commented Jun 26, 2018

So far I have tested download from Google play using a Android 4.2.2... here is what happened...
I compiled using the default storage location being set to prefer extSD.
The download apparently put the app on the extSD but the OBB was written to the internal storage.
I say that the app was written to the extSD because when I look at the app storage settings it shows that the app is stored on the extSD.
When I try to run the freshly downloaded app it immediatly shows a dark screen with the message...
"Downloading assets..." but then shows "Unfortuanatley, Test has stopped."

Next,
I moved the OBB/file over to the extSD using file manager and tried running the app again to see if putting the data in the "expected" location on the extSD would prevent the app from bombing trying to download ... it still failed with the same error message.

Next,
I pressed the move button in the app settings storage to move the app over to the internal storage. The move occurs. At least the gas gage counts down the move and concludes with showing that the app is now located on internal storage. But when I look with file manager the OBB/file is not moved over to internal storage.

So Next, I move the OBB/file over with file manager to the expected location in internal storage... And when I try to run the app again it still fails trying to download assets.

It appears that either way the app can not read the obb/file on either internal or extSD storage so it trys to download the file??

I will try the Android 7.0 test tomorrow.

@BobAchgill
Copy link
Author

Test on Android 7 fails same way...
"Downloading assets..." but then shows "Unfortuanatley, Test has stopped."

@agamemnus
Copy link
Owner

Something isn't right .... should be working since the latest patch came from a user for whom it works. Can you make a link to the file?

@BobAchgill
Copy link
Author

https://play.google.com/apps/internaltest/4699174589605622933

I may need to approve your email address? Give it a try.

@agamemnus
Copy link
Owner

agamemnus commented Jun 30, 2018 via email

@BobAchgill
Copy link
Author

Added

@agamemnus
Copy link
Owner

agamemnus commented Jun 30, 2018 via email

@agamemnus
Copy link
Owner

I have seen people mention this kind of thing before... any way you could send me the uncompiled file to look at so I could check the settings?

@BobAchgill
Copy link
Author

BobAchgill commented Jul 1, 2018

It appears to work with Android 7 now.
With one caveat...
When I move the app to external storage ... the app moves and the obb copy (i.e. does not free up internal storage space) over to ext storage but it still looks for the OBB on the internal storage... and if I delete the OBB from ext storage it starts downloading the expansion file again from Google play.

The download of the app does not appear to honor the storage location pointer to have the app prefer to install on external storage.

This makes it very difficult if not impossible for the user who does not have enough internal storage to download the app.

@agamemnus
Copy link
Owner

agamemnus commented Jul 1, 2018 via email

@BobAchgill
Copy link
Author

BobAchgill commented Jul 2, 2018

Testing with Android 7.x...

It will not install the app to the external storage using this...
<preference name="android-manifest/@android:installLocation" value="preferExternal" />

Once it is installed it is possible to move the app to external storage but not the obb.

So there is no scenario where the obb can be stored/accessed on the ext storage.

My guess is that it did not initially install the app to the preffered ext storage because it knew that it could not also write to the obb file to ext storage??

@agamemnus
Copy link
Owner

agamemnus commented Jul 2, 2018 via email

@BobAchgill
Copy link
Author

BobAchgill commented Jul 2, 2018

With preferred install storage location set to extSD...
<preference name="android-manifest/@android:installLocation" value="preferExternal" />

Test case 1: Android 7.x
App installed to internal And OBB to internal.
Can move app to extSD but not OBB

Test case 2: Android 4.4.2
App installed to extSD but OBB to internal.

What is hoped for is that some how the OBB can be stored and accessed on the extSD on initial install to save space on the User's internal storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants