Post Reply

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

OP Falseclock

22nd June 2014, 09:36 AM   |  #1  
Falseclock's Avatar
OP Senior Member
Flag Almaty
Thanks Meter: 315
 
517 posts
Join Date:Joined: Jun 2012
Donate to Me
More
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;
	}
}
Last edited by Falseclock; 25th July 2014 at 07:03 AM.
The Following 23 Users Say Thank You to Falseclock For This Useful Post: [ View ]
22nd June 2014, 10:18 AM   |  #2  
defim's Avatar
Senior Member
Thanks Meter: 874
 
1,667 posts
Join Date:Joined: Feb 2012
Advantage against HandleExternalStorage: http://forum.xda-developers.com/xpos...orage-t2693521 ?
23rd June 2014, 12:40 PM   |  #3  
Senior Member
Thanks Meter: 32
 
220 posts
Join Date:Joined: 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
23rd June 2014, 12:54 PM   |  #4  
Senior Member
Thanks Meter: 481
 
394 posts
Join Date:Joined: Jan 2013
More
Can you share source code?
23rd June 2014, 02:35 PM   |  #5  
Falseclock's Avatar
OP Senior Member
Flag Almaty
Thanks Meter: 315
 
517 posts
Join Date:Joined: Jun 2012
Donate to Me
More
Quote:
Originally Posted by pyler

Can you share source code?

yep!

see first post
Last edited by Falseclock; 24th July 2014 at 04:42 PM.
The Following User Says Thank You to Falseclock For This Useful Post: [ View ]
23rd June 2014, 02:48 PM   |  #6  
Falseclock's Avatar
OP Senior Member
Flag Almaty
Thanks Meter: 315
 
517 posts
Join Date:Joined: Jun 2012
Donate to Me
More
Quote:
Originally Posted by defim

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.
23rd June 2014, 04:42 PM   |  #7  
Senior Member
Thanks Meter: 481
 
394 posts
Join Date:Joined: Jan 2013
More
Quote:
Originally Posted by Falseclock

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!
24th June 2014, 12:24 AM   |  #8  
defim's Avatar
Senior Member
Thanks Meter: 874
 
1,667 posts
Join Date:Joined: Feb 2012
Quote:
Originally Posted by Falseclock

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()
24th June 2014, 05:28 AM   |  #9  
Falseclock's Avatar
OP Senior Member
Flag Almaty
Thanks Meter: 315
 
517 posts
Join Date:Joined: Jun 2012
Donate to Me
More
Quote:
Originally Posted by defim

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!
25th June 2014, 02:13 PM   |  #10  
Senior Member
Thanks Meter: 481
 
394 posts
Join Date:Joined: Jan 2013
More
do you know alternative to com.android.internal.util.ArrayUtils? Not to use internal API...

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Xposed Framework Modules by ThreadRank