[Q][SOLVED, partially] modifying environment variable DIRECTORY_DCIM system-wide

Search This thread
A

asenkyr

Guest
Hello,

Problem:
My Meizu MX3 (runs Flyme os 3 based on android 4.2.2) has preset "Camera" in the DIRECTORY_DCIM environment variable. Most of the camera apps respect this setting and they are saving photos in the Camera instead of the DCIM. This causes problems with automatic syncing, because photos are obviously expected to be in the DCIM.

Partial solutions:
I tried symlinking the two dirs, but as far as i know it is not possible in the FUSE used since the 4.2.2.
mount -o bind led to the duplicity in the gallery app and i don't consider it too "clean" solution.

I ended up with modifying source of Focal open source camera not to read DIRECTORY_DCIM env var, but rather just to save the picture into the DCIM directly.


Is there a way to change this variable on boot? I don't want to use any 3rd party apps for simple things like this. Editing init.rc led to nothing, because it is always replaced by the default one from the ramdisk.

Thanks in advance.
 
Last edited:

GermainZ

Inactive Recognized Developer / Retired Forum Mod
Aug 3, 2012
6,170
8,805
Have you tried making an init.d script to export the value you want? I haven't looked at the source code so I don't know if that'll make a difference, but that's the only thing I can think of, short of modifying the API call using e.g. Xposed (somewhat similar to what this mod does.)

You may want to link the SO question you also created, in case you get a working answer there, so anyone stumbling on this page will find the way to that.
 
Last edited:
A

asenkyr

Guest
The init.d dir was not on my phone, so i tried creating it. Scripts from there do not get run on the startup, which brings me back to the problem with editing init.rc.

I will probbly just keep using modified camera until they release Ubuntu mobile for mx3 - which according to rumors could be soon :)

Thank you for your time

Sent from my M353 using XDA Premium 4 mobile app
 

MrCrayon

Senior Member
Sep 6, 2013
205
64
Xiaomi Redmi Note 4
Lenovo P11
Check if in your init.rc there is something like
Code:
 service flash_recovery /system/etc/install-recovery.sh
Then you can edit/create that script and enable running init.d scripts with:
Code:
busybox run-parts /system/etc/init.d
search on this forum for more info ;)

Sent from my ZP980 using Tapatalk
 
A

asenkyr

Guest
Thank you, your guide worked and my scripts in init.d now get executed :)
Sadly, exporting the variable in script residing in init.d does nothing (the script itself gets executed, i tried echoing "test" in file). There must be something, which keeps reseting the DIRECTORY_DCIM to its original value, or else i'm out of ideas :)

Or am i assuming incorrectly, that Java code
Code:
Environment.DIRECTORY_DCIM
should read env variable settable by
Code:
export DIRECTORY_DCIM="DCIM"
?
 

MrCrayon

Senior Member
Sep 6, 2013
205
64
Xiaomi Redmi Note 4
Lenovo P11
Actually now that you say that I checked my init.rc and I don't have that. Plus if I try
Code:
echo DIRECTORY_DCIM
I have nothing, so at least for me it's not set there.

Sent from my ZP980 using Tapatalk
 
A

asenkyr

Guest
For me echoing the varible also returns nothing, but reading it by Java returns "Camera".
Since it was my only clue, i hoped it could be reset by exporting DIRECTORY_DCIM (since android docs states that
android.os.Environment provides acces to environment vars) I guess i was wrong.
Is there any other kind of emvironment variables, i am not aware of?

Sent from my M353 using Tapatalk
 

MrCrayon

Senior Member
Sep 6, 2013
205
64
Xiaomi Redmi Note 4
Lenovo P11
I checked that variable is hardcoded in the android.os.Environment class.

I can think of three methods to test to change that but I didn't test any:

  1. Use exposed framework to change the call that gets DIRECTORY_DCIM, if that's possible it's probably the best choice.
  2. Edit and compile again android.os.Environment (I have no idea how to do that or if it's even possible)
  3. Make a script that monitors your X folder to move pictures to DCIM folder
I can help you with the last one ;)
 
A

asenkyr

Guest
The xposed is great idea, but unfortunately it doesn't work. It says "unknown option -- c" which as far as i know has something to do with bad (probably outdated?) version of SU. Meizu's firmware is probably more customized android than i previously thought.

Now i'm using the solution you also advised - i am automatically moving media from Camera to DCIM - i was hoping for more clean solution, but i guess this is as close as i'll ever get :) (don't get me wrong, it works as it is supposed to. I'm just a perfectionist :D)

Thank's for your time.