Skip to content

Commit

Permalink
Bump to 1.6.1; sort AppOps based on label
Browse files Browse the repository at this point in the history
  • Loading branch information
jclehner committed Dec 20, 2013
1 parent f3539de commit 2c24b71
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.jclehner.appopsxposed"
android:versionCode="10"
android:versionName="1.6" >
android:versionCode="10601"
android:versionName="1.6.1" >

<uses-sdk
android:minSdkVersion="18"
Expand Down
32 changes: 31 additions & 1 deletion src/at/jclehner/appopsxposed/AppOpsXposed.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import android.content.res.XModuleResources;
import android.os.Build;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodHook;
Expand Down Expand Up @@ -91,6 +94,8 @@ public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable
log(t);
}
}

hookLoaderLoadInBackground(lpparam);
}

private static void hookIsValidFragment(LoadPackageParam lpparam)
Expand Down Expand Up @@ -124,4 +129,29 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable
throw e;
}
}

// We can do this crude comparison since AppOpsEntry.toString() returns the app's
// label, which is exactly what we need. No reflection necessary here!

private static final Comparator<Object> TO_STRING_COMPARATOR = new Comparator<Object>() {
@Override
public int compare(Object lhs, Object rhs)
{
return lhs.toString().compareToIgnoreCase(rhs.toString());
}
};

private static void hookLoaderLoadInBackground(LoadPackageParam lpparam)
{
findAndHookMethod("com.android.settings.applications.AppOpsCategory$AppListLoader", lpparam.classLoader,
"loadInBackground", new XC_MethodHook() {

@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable
{
List<?> entries = (List<?>) param.getResult();
Collections.sort(entries, TO_STRING_COMPARATOR);
}
});
}
}

0 comments on commit 2c24b71

Please sign in to comment.