jerdog · Apr 12, 2012 at 06:30 pm

Android 3.2+ Code (Inadvertently?) Preventing Write Access to External Storage

It would seem that Google has a bug in their AOSP code that was introduced around Android 3.2, which affects how the OS handles USB Storage and can prevent write access to SD cards and USB sticks. XDA Elite Recognized Developer, Senior Moderator, and News Writer Chainfire sums up the issue in his blog post:

In the past, an app would request the “WRITE_EXTERNAL_STORAGE” permission, which would grant write access to all external storages (user/group “sdcard_rw“). This has apparently been changed to only grant write access to the primary external storage. A second permission has been introduced called “WRITE_MEDIA_STORAGE“, which would grant access to the other external storages (user/group “media_rw“).

The problem is, a third party will not actually be granted this permission, only system apps and apps provided by the device manufacturer will normally be granted this permission. There are exceptions, apparently on some devices third party apps will be granted this permission, but according to the AOSP sources, they’re certainly not supposed to.

As Chainfire investigated the issue he came across code in the /system/vold/Volume.cpp that explicitly states:

 if (primaryStorage) {
     // Special case the primary SD card.
     // For this we grant write access to the SDCARD_RW group.
     gid = AID_SDCARD_RW;
} else {
     // For secondary external storage we keep things locked up.
     gid = AID_MEDIA_RW;
}

On many devices, the internal flash is considered the “primary SD card.” The real SD card then becomes the secondary external storage, and is locked down—protected by the unattainable “WRITE_MEDIA_STORAGE” permission.

Chainfire submitted his question to the Android Developers Office Hours team, and they ended up discussing it in their live hangout on April 11. Unfortunately, the Google engineers present in the hangout were not able to provide any real answers, as this is a complicated issue and the question was only raised an hour before the show went live. They have however promised to get to the bottom of this issue, and get back to Chainfire (and us) at a later time.

Also according to Chainfire, the problem is actually present on ICS builds for the SGS2 as well, though Samsung “worked around it using a very ugly permission hack“:

<permission name=”android.permission.WRITE_EXTERNAL_STORAGE” >
     <group gid=”sdcard_rw” />
     <group gid=”media_rw” />
 </permission>

What you see here is Samsung piggybacking the WRITE_MEDIA_STORAGE permission to the WRITE_EXTERNAL_STORAGE permission, so apps do not experience the described problem.

Whether or not Google intended for connected SD Cards and USB sticks to be limited to be read-only for third-party apps remains to be seen. It does however give birth to a disturbing thought: What if the code and accompanying notes are Google’s first stages of implementing some sort of write protection for external storage, and thus further limiting our mobile freedom? We can only hope this is a genuine bug, as freedom is one of the very reasons we all avoid the Dark Side.

[Huge thanks to Chainfire for the heads up and help!]
_________
Want something on the XDA Portal? Send us a tip!
Emil Kako · Mar 2, 2015 at 01:03 pm · 1 comment

How Do You Usually Access the XDA Forums?

There are a number of different apps on the Play Store that make browsing the XDA portal and forums a fun experience on mobile, but we want to know: What's your favorite way to access the XDA forums? Do you prefer browsing on the desktop, mobile app, or mobile browser? If you use a mobile app, which one? Let us know how you connect with our community in the comment section below.

DISCUSS
Faiz Malkani · Mar 2, 2015 at 12:39 pm · 1 comment

Google Announces Plans for Projects Titan, Loon and Link

Once a year, top players in the mobile sphere gather for MWC, to show off what they've been working on and collectively set the standard for the year to come. Yesterday was a big day with the launch of HTC and Samsung's flagships, alongside numerous other announcements, and today it was Google's turn to take the stage. SVP Sundar Pichai took the stage in Barcelona to speak about Google's network initiatives, Project Link and Project Loon, as well as to...

XDA NEWS
Mario Tomás Serrafero · Mar 2, 2015 at 11:36 am · 1 comment

Intel at MWC 2015: New Chip Branding and Details

Intel showed its face at MWC 2015 to give the world a yearly update on their upcoming line of chipsets for mobile. While last year the company focused on gathering partnerships and strengthening up their services, architectures and production, now they are revamping their Atom line of SoCs for mobile with a new brand name and a distinctive category format much like that of their i3/i5/i7 line of personal computing processors. The new scheme will be naming the chips x3, x5...

XDA NEWS
Share This