Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,811,145 Members 44,364 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][KK][XPOSED] KitKat SD Card Full Access

Tip us?
 
Falseclock
Old
(Last edited by Falseclock; 25th July 2014 at 07:03 AM.)
#1  
Falseclock's Avatar
Senior Member - OP
Thanks Meter 303
Posts: 512
Join Date: Jun 2012
Location: Almaty

 
DONATE TO ME
Default [MOD][KK][XPOSED] KitKat SD Card Full Access

This module fixing external SD card write issue on Android 4.4 KitKat. Module does not have any setting activity. Just enable it in Module tab and restart your phone.
No need to patch platform.xml file.

http://repo.xposed.info/module/kz.vi...roid.sdcardfix

Can be downloaded in Xposed Download tab.

HOW IT WORKS and WHAT FOR?

KitKat No SD card access
If SD card write access not enabled, then no any application without root permission can operate with files on SD Card.


KitKat WITH SD Card access
Once mod is enabled - any application without root access can operate with files on SD, including move, copy, delete.



Source code for other developers
Code:
/*
The MIT License (MIT)

Copyright (c) 2014 by Nurlan Mukhanov aka Falseclock

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

package kz.virtex.android.sdcardfix;

import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;

public class XMain implements IXposedHookZygoteInit
{
	@Override
	public void initZygote(StartupParam startupParam) throws Throwable
	{
		final Class<?> pms = XposedHelpers.findClass("com.android.server.pm.PackageManagerService", null);

		XposedHelpers.findAndHookMethod(pms, "readPermission", "org.xmlpull.v1.XmlPullParser", "java.lang.String", new XC_MethodHook()
		{
			protected void afterHookedMethod(MethodHookParam param) throws Throwable
			{
				String permission = (String) param.args[1];

				if (permission.equals("android.permission.WRITE_EXTERNAL_STORAGE")) {
					Class<?> process = XposedHelpers.findClass("android.os.Process", null);
					int gid = (Integer) XposedHelpers.callStaticMethod(process, "getGidForName", "media_rw");
					Object mSettings = XposedHelpers.getObjectField(param.thisObject, "mSettings");
					Object mPermissions = XposedHelpers.getObjectField(mSettings, "mPermissions");
					Object bp = XposedHelpers.callMethod(mPermissions, "get", permission);
					int[] bp_gids = (int[]) XposedHelpers.getObjectField(bp, "gids");
					XposedHelpers.setObjectField(bp, "gids", appendInt(bp_gids, gid));
				}
			}
		});
	}

	private static int[] appendInt(int[] cur, int val)
	{
		if (cur == null) {
			return new int[]
			{ val };
		}
		final int N = cur.length;
		for (int i = 0; i < N; i++) {
			if (cur[i] == val) {
				return cur;
			}
		}
		int[] ret = new int[N + 1];
		System.arraycopy(cur, 0, ret, 0, N);
		ret[N] = val;
		return ret;
	}
}
The Following 20 Users Say Thank You to Falseclock For This Useful Post: [ Click to Expand ]
 
defim
Old
#2  
Senior Member
Thanks Meter 809
Posts: 1,563
Join Date: Feb 2012
Advantage against HandleExternalStorage: http://forum.xda-developers.com/xpos...orage-t2693521 ?
Motorola Defy+ aka MB526 Android 4.4.4 Cyanogen Mod
Samsung S4a aka GT-i9295 Android 4.2.2 Google Edition
My Android apps / Xposed modules: show Threads
 
HyperCriSiS
Old
#3  
Senior Member
Thanks Meter 29
Posts: 210
Join Date: Nov 2010

 
DONATE TO ME
Did not know that there was already such a fix available. Just found this one and since it is activated I have much less lags. Seems there were many apps trying to access Sdcard causing lags. Awesome!

Sent from my GT-I9300 using XDA Premium 4 mobile app
 
pyler
Old
#4  
Senior Member
Thanks Meter 442
Posts: 358
Join Date: Jan 2013
Can you share source code?
 
Falseclock
Old
(Last edited by Falseclock; 24th July 2014 at 04:42 PM.)
#5  
Falseclock's Avatar
Senior Member - OP
Thanks Meter 303
Posts: 512
Join Date: Jun 2012
Location: Almaty

 
DONATE TO ME
Quote:
Originally Posted by pyler View Post
Can you share source code?
yep!

see first post
The Following User Says Thank You to Falseclock For This Useful Post: [ Click to Expand ]
 
Falseclock
Old
#6  
Falseclock's Avatar
Senior Member - OP
Thanks Meter 303
Posts: 512
Join Date: Jun 2012
Location: Almaty

 
DONATE TO ME
Quote:
Originally Posted by defim View Post
Advantage against HandleExternalStorage: http://forum.xda-developers.com/xpos...orage-t2693521 ?
oops. tried to search something with "SD" word in repository and didn't find anything.
thought nobody still implemented such mod.

Just downloaded module, decompiled and compared with my version.

I think my method works much more correct and less battery power consumptive. I only hooking internal android packages at startup, while module above doing this with every application.
 
pyler
Old
#7  
Senior Member
Thanks Meter 442
Posts: 358
Join Date: Jan 2013
Quote:
Originally Posted by Falseclock View Post
oops. tried to search something with "SD" word in repository and didn't find anything.
thought nobody still implemented such mod.

Just downloaded module, decompiled and compared with my version.

I think my method works much more correct and less battery power consumptive. I only hooking internal android packages at startup, while module above doing this with every application.

Awesome! Thanks for source!
 
defim
Old
#8  
Senior Member
Thanks Meter 809
Posts: 1,563
Join Date: Feb 2012
Quote:
Originally Posted by Falseclock View Post
I think my method works much more correct and less battery power consumptive. I only hooking internal android packages at startup, while module above doing this with every application.
No. Mine gives extra battery power
The funny thing is that both are 99% the same, the only difference is appendInt()
Motorola Defy+ aka MB526 Android 4.4.4 Cyanogen Mod
Samsung S4a aka GT-i9295 Android 4.2.2 Google Edition
My Android apps / Xposed modules: show Threads
 
Falseclock
Old
#9  
Falseclock's Avatar
Senior Member - OP
Thanks Meter 303
Posts: 512
Join Date: Jun 2012
Location: Almaty

 
DONATE TO ME
Quote:
Originally Posted by defim View Post
No. Mine gives extra battery power
The funny thing is that both are 99% the same, the only difference is appendInt()
That's good if so!
 
pyler
Old
#10  
Senior Member
Thanks Meter 442
Posts: 358
Join Date: Jan 2013
do you know alternative to com.android.internal.util.ArrayUtils? Not to use internal API...

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes