Skip to content

Commit

Permalink
Initial Code Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrerm124 committed Feb 22, 2018
1 parent 108a27f commit 6b62f59
Show file tree
Hide file tree
Showing 69 changed files with 2,550 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

\.idea/
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
41 changes: 41 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.ljmu.andre.artdeoptimiser"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'

// Xposed
provided 'de.robv.android.xposed:api:82'
provided 'de.robv.android.xposed:api:82:sources'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.ljmu.andre.artdeoptimiser;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.ljmu.andre.artdeoptimiser", appContext.getPackageName());
}
}
43 changes: 43 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.ljmu.andre.artdeoptimiser">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar"
tools:replace="android:icon">
<meta-data
android:name="xposedmodule"
android:value="true"/>
<meta-data
android:name="xposeddescription"
android:value="Easy example which makes the status bar clock red and adds a smiley"/>
<meta-data
android:name="xposedminversion"
android:value="80"/>

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity
android:name=".LegalActivity"
android:label="@string/title_activity_legal"
android:parentActivityName=".MainActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">
</activity>
</application>

</manifest>
1 change: 1 addition & 0 deletions app/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.ljmu.andre.artdeoptimiser.HookManager
81 changes: 81 additions & 0 deletions app/src/main/java/com/ljmu/andre/artdeoptimiser/HookManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.ljmu.andre.artdeoptimiser;

import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.util.Log;

import com.ljmu.andre.artdeoptimiser.Utils.PackageUtils;

import java.io.File;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

import static com.ljmu.andre.artdeoptimiser.MainActivity.TAG;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.getObjectField;

/**
* This class was created by Andre R M (SID: 701439)
* It and its contents are free to use by all
*/

public class HookManager implements IXposedHookLoadPackage {
private static final Object DEOP_FOLDER_LOCK = new Object();
private File deopFolder;

@Override public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if (lpparam.packageName.equals("android")) {
try {
ClassLoader classLoader = lpparam.classLoader;
Class packageParserClass = findClass("android.content.pm.PackageParser", classLoader);
Class packageClass = findClass("android.content.pm.PackageParser$Package", classLoader);

findAndHookMethod(
packageParserClass,
"parseBaseApplication", packageClass, Resources.class, XmlResourceParser.class, int.class, String[].class,
new XC_MethodHook() {
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Log.d(TAG, "Parsing Base Application");

// Lock required as this function is highly multi-threaded ===================
synchronized (DEOP_FOLDER_LOCK) {
if (deopFolder == null) {
deopFolder = PackageUtils.getDeoptimisationFolder();
}
}

ApplicationInfo appInfo = (ApplicationInfo) getObjectField(param.args[0], "applicationInfo");

if (appInfo == null) {
return;
}

String packageName = appInfo.packageName;

XposedBridge.log("Adjusting package flags for: " + packageName);

Log.d(TAG, "Starting Flag Manipulation");
Log.d(TAG, "Start Flags: " + appInfo.flags);

if (new File(deopFolder, packageName + PackageUtils.DEOP_EXT).exists())
appInfo.flags |= ApplicationInfo.FLAG_VM_SAFE_MODE;

if (new File(deopFolder, packageName + PackageUtils.DEBUG_EXT).exists())
appInfo.flags |= ApplicationInfo.FLAG_DEBUGGABLE;

Log.d(TAG, "End Flags: " + appInfo.flags);
}
}
);
} catch (Throwable t) {
Log.e(TAG, "Error with main xposed hooking", t);
XposedBridge.log(t);
}
}
}
}
35 changes: 35 additions & 0 deletions app/src/main/java/com/ljmu/andre/artdeoptimiser/LegalActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.ljmu.andre.artdeoptimiser;

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class LegalActivity extends AppCompatActivity {

@BindView(R.id.toolbar) Toolbar toolbar;
Unbinder unbinder;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_legal);
unbinder = ButterKnife.bind(this);

setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();

if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}

@Override protected void onDestroy() {
super.onDestroy();
unbinder.unbind();
}
}
Loading

0 comments on commit 6b62f59

Please sign in to comment.