Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP asenkyr

asenkyr
22nd January 2014, 07:35 PM   |  #1  
Guest
Thanks Meter: 0
 
n/a posts
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 by asenkyr; 26th January 2014 at 04:13 PM.
23rd January 2014, 02:00 AM   |  #2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 7,330
 
5,910 posts
Join Date:Joined: Aug 2012
Donate to Me
More
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 by GermainZ; 28th January 2014 at 11:13 PM.
The Following User Says Thank You to GermainZ For This Useful Post: [ View ]
asenkyr
23rd January 2014, 07:41 PM   |  #3  
Guest
Thanks Meter: 0
 
n/a posts
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
24th January 2014, 12:09 AM   |  #4  
Junior Member
Thanks Meter: 12
 
25 posts
Join Date:Joined: 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: [ View ]
asenkyr
25th January 2014, 09:54 PM   |  #5  
Guest
Thanks Meter: 0
 
n/a posts
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"
?
25th January 2014, 11:10 PM   |  #6  
Junior Member
Thanks Meter: 12
 
25 posts
Join Date:Joined: 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
25th January 2014, 11:25 PM   |  #7  
Guest
Thanks Meter: 0
 
n/a posts
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
26th January 2014, 11:39 AM   |  #8  
Junior Member
Thanks Meter: 12
 
25 posts
Join Date:Joined: 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: [ View ]
asenkyr
26th January 2014, 04:07 PM   |  #9  
Guest
Thanks Meter: 0
 
n/a posts
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.
26th January 2014, 05:18 PM   |  #10  
Junior Member
Thanks Meter: 12
 
25 posts
Join Date:Joined: 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

Post Reply Subscribe to Thread

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

Advanced Search
Display Modes