FWGS / xash3d

DEPRECATED in favor of https://github.com/FWGS/xash3d-fwgs. Only bugfixes are accepted.
https://xash.su
GNU General Public License v3.0
551 stars 107 forks source link

[Android] SD Card permissions. #332

Closed Lion4K closed 6 years ago

Lion4K commented 6 years ago

Hi, as I believe you devs already know, theres a issue with the SD Storage access on Kit Kat or later android versions. However I'm here to present a possible solution.

I've seen some apps bypassing this, by using android's internal file picker, and some others have implemented something that makes the app asks the system for SD Card privileges, which in its turn asks the user about it.

This may provide some help. https://source.android.com/devices/storage/

Again, I'm not a developer, I have little to no knowledge on android developing, the most I know is to use ADB / Fastboot to custom rom procedures, and logcats. I'm just trying to be helpful.

Happy new year!!

mittorn commented 6 years ago

It does not work for native code and it is very slow. Yes, we may wrap filesystem to java, but it is hard task, it will not be compatible with mods, it will be slow and increase memory usage. 0.5s hanging on save,download,changelevel,graph write, reducing connection time 2-3 times because of demoheader. And it may crash/hang because of buggy implementations. Use "rodir" feature in test versions, it is fast enough and compatible with half-life game code (but not with aghl, xdm, etc...).

mittorn commented 6 years ago

P.S you yell about file picker method which does not work, but android 6.0 method with /mnt/runtime may work. I do not have android 6.0+ devices to check if it useful.

Lion4K commented 6 years ago

I can test that for you if you want. I can also point to some apps that uses that method that you may be able to take a look at and idk, make sense out of something there, idk jack about that.

a1batross commented 6 years ago

It does not depends, request you SD card privileges or not, it will not available from native code.

Rodir is seems to be best solution here.

Lion4K commented 6 years ago

Solid Explorer is one of the apps that Uses that. I made a video showing how that happens. heres the link to it: EDIT wrong video uploaded. please stand by

Lion4K commented 6 years ago

BTW whats Rodir? And how to get it?

Lion4K commented 6 years ago

Also, how ironic is that, Solid Explorer, a file explorer that relies on android's own file explorer to work. lol;

mittorn commented 6 years ago

Does Solid Explorer performing file operations in native code? If it uses documents api, this method unuseful for xash3d.

Lion4K commented 6 years ago

Here's the correct Link: https://www.youtube.com/watch?v=EP20YbnZBc4

Lion4K commented 6 years ago

No I belive it's not native, at least if I understood what native is.

Lion4K commented 6 years ago

I mean, I have no idea.

mittorn commented 6 years ago

Use /sdcard/xash as game folder, but leave it empty and place game data to /storage/sdcard1/xash and add -rodir /storage/sdcard1/xash to command-line arguments.

mittorn commented 6 years ago

Documents API is only availiable in java code. It is different from classic filesystem. It is similar to downloafing files from network Instead of reading.

mittorn commented 6 years ago

File managers "uploads" files to sdcard, and does nlt write it directly.

Lion4K commented 6 years ago

So "Path to game resources" I set what?

mittorn commented 6 years ago

To /sdcard/xash which should be empty. Xash3D will write all changed files there. It will be used as overlay to read-only /storage/sdcard1/xash

Lion4K commented 6 years ago

could not found directory valve.

Lion4K commented 6 years ago

like, my sdcard path is /storage/F2ED-255F/

Lion4K commented 6 years ago

so my Advanced Tab should be:

Command line ar(...) -dev 3 -log -rodir /storage/F2ED-255F/xash

Path to game resources: /storage/emulated/0/xash

Pixel format (...) 32Bit

Keyboard does not resizes

Check updates Tick

Update to unstable Untick

enable immersive mode (...) Tick

a1batross commented 6 years ago

Forgot to say, it works only on test versions.

Lion4K commented 6 years ago

Oh. Where do I get this version?

mittorn commented 6 years ago

https://github.com/FWGS/xash3d-deploy

Lion4K commented 6 years ago

Sorry, its probably like, "bitting me at the ankle" but I can't find it. can you please point the link to the apk file?

a1batross commented 6 years ago

Read READMR.md file. Use "travis-latest" branch.

Lion4K commented 6 years ago

This? https://github.com/FWGS/xash3d-deploy/blob/travis-0.19.x/xash3d-generic.apk?raw=true

a1batross commented 6 years ago

Yes.

2 янв. 2018 г. 9:50 ПП пользователь "Lion de Oliveira Lorena" < notifications@github.com> написал:

This? https://github.com/FWGS/xash3d-deploy/blob/travis-0. 19.x/xash3d-generic.apk?raw=true

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/FWGS/xash3d/issues/332#issuecomment-354845340, or mute the thread https://github.com/notifications/unsubscribe-auth/ADEJgadbkrY6SDS3iyBXEB_kD2jeICLUks5tGnpwgaJpZM4RP714 .

Lion4K commented 6 years ago

thanks, gonna copy the files one more time, as google play music keeps playing the media files on the game folder.

Lion4K commented 6 years ago

works nicely. thanks.

Lion4K commented 6 years ago

except not for any other mod rather than original HL.

mittorn commented 6 years ago

Try add dot (.) to folder name begin. It will hide it from file managers and media scanner. And do not forget to update paths

Lion4K commented 6 years ago

hmm, gonna try that. thanks.

Lion4K commented 6 years ago

Oh, nvm, I went to do that, but I just remembered I tried something else and It worked like a charm.

I made a new text file on windows, and with the help of cmd I renamed it to ".nomedia" and then copied it to xash folder and then each subfolder like valve, cstrike, etc.

I went to verify if it worked and it did. But perhaps your method is easyier, i'm gonna use it next time.

mittorn commented 6 years ago

android may remove media files from folders with .nomedia, so i not recommend using this method

a1batross commented 6 years ago

@mittorn you need to have a very-very special luck for this. :)

a1batross commented 6 years ago

@Lion4K for mods you should add the same command argument in the mod's launcher.

mittorn commented 6 years ago

@a1batross No, just add .nomedia after mediascanner adds files to database

a1batross commented 6 years ago

Nope. It's a bug. I don't even think it exist on modern Android. (Yes, I think 4.x branch isn't a modern).

3 янв. 2018 г. 3:27 ПП пользователь "mittorn" notifications@github.com написал:

@a1batross https://github.com/a1batross No, just add .nomedia after mediascanner adds files to database

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FWGS/xash3d/issues/332#issuecomment-355000571, or mute the thread https://github.com/notifications/unsubscribe-auth/ADEJgS7QlzIDC8E72lkajI_DAkyj3i3Xks5tG3JKgaJpZM4RP714 .

mittorn commented 6 years ago

I do not know if ti is bug or feature, but i do not recommend to use it as Samsung devices may have it enabled.

Lion4K commented 6 years ago

im using androis 7.1.1, waiting motorola release oreo.

Lion4K commented 6 years ago

but yeah the .nomedia file worked like a charm. not only stopped music but also pictures.

Lion4K commented 6 years ago

for the mods. lets say i wanna use Crack-Life. What should I use? folder name is cracklife.

r/n i'm using:

advanced:

cmd args -dev 3 -log -rodir /storage/F2ED-255F/xash -game cracklife

Path: /storage/emulated/0/xash

should I add cracklife to both lines?

nekonomicon commented 6 years ago

You must place cracklife folder to xash folder.

Lion4K commented 6 years ago

yeah, it is.

all my mods are there

cracklife clcampaign cstrike czero czeror valve ricochet dmc etc etc etc

Lion4K commented 6 years ago

Would be this one the native thing you were talking about? It sure does look different from the one I showed on the video.

Teste https://imgur.com/gallery/FZGTF

Lion4K commented 6 years ago

It asks directly to the folder and not the whole card.

mittorn commented 6 years ago

rewrite xash3d to java and it will work

Lion4K commented 6 years ago

When you mean rewrite, isn't it already in Java? I mean I thought everything in Android was Java, actually Dalvik something idk. I saw something on college but didn't pay attention.

nekonomicon commented 6 years ago

Xash3d was written on pure C(menu and game libraries on C++). Only launchers(black windows) was written on Java. You can write apps for android on any programming language in combination with Java. Dalvik - just Google's JVM implementation for android.

Lion4K commented 6 years ago

I see, I guess I should had payed more attention to college lol

Lion4K commented 6 years ago

Well, about the other mods, I still can't get them to work, how should I fill both lines, like, for example for CrackLife.

cmd args -dev 3 -log -rodir /storage/F2ED-255F/xash

Path: /storage/emulated/0/xash

Should I use "-game cracklife" on both of them?