Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,785,567 Members 42,678 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
asenkyr Old
(Last edited by asenkyr; 26th January 2014 at 03:13 PM.)
#1  
Guest
Thanks Meter 0
Posts: n/a
Camera [Q][SOLVED, partially] modifying environment variable DIRECTORY_DCIM system-wide

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.
 
GermainZ
Old
(Last edited by GermainZ; 28th January 2014 at 10:13 PM.)
#2  
GermainZ's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 6,217
Posts: 5,364
Join Date: Aug 2012
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.
The Following User Says Thank You to GermainZ For This Useful Post: [ Click to Expand ]
asenkyr Old
#3  
Guest
Thanks Meter 0
Posts: n/a
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
Old
#4  
Junior Member
Thanks Meter 12
Posts: 24
Join Date: Sep 2013
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
The Following User Says Thank You to MrCrayon For This Useful Post: [ Click to Expand ]
asenkyr Old
#5  
Guest
Thanks Meter 0
Posts: n/a
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
Old
#6  
Junior Member
Thanks Meter 12
Posts: 24
Join Date: Sep 2013
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
asenkyr Old
#7  
Guest
Thanks Meter 0
Posts: n/a
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
Old
#8  
Junior Member
Thanks Meter 12
Posts: 24
Join Date: Sep 2013
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
The Following User Says Thank You to MrCrayon For This Useful Post: [ Click to Expand ]
asenkyr Old
#9  
Guest
Thanks Meter 0
Posts: n/a
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 )

Thank's for your time.
 
MrCrayon
Old
#10  
Junior Member
Thanks Meter 12
Posts: 24
Join Date: Sep 2013
np I'm a perfectionist too and it's always cool to learn how things work and can be hacked

Sent from my ZP980 using Tapatalk

Tags
dcim, environment variables, meizu mx3
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes