Skip to content

Commit

Permalink
Add initial modern Xposed API module code .
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravssnl committed Jan 22, 2024
0 parents commit 059fb88
Show file tree
Hide file tree
Showing 47 changed files with 970 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Gaurav <[email protected]>

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.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SimpleRadioAdAway

SimpleRadio AdAway Xposed module for the Android app available in the Google PlayStore. This Xposed module hass been developed using the `Modern Xposed API` provided by LSPosed (https://github.com/LSPosed/LSPosed/wiki/Develop-Xposed-Modules-Using-Modern-Xposed-API).

Install this Xposed module to block the advertisements and enjoy Ad free radio experience :)

# Requirements

Lsposed must be installed on your Android device to use this Module. You can search on Google for more info about them.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
47 changes: 47 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}

android {
namespace = "com.gauravssnl.simpleradioadaway"
compileSdk = 34

defaultConfig {
applicationId = "com.gauravssnl.simpleradioadaway"
minSdk = 29
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
compileOnly(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar"))))
implementation("org.apache.commons:commons-lang3:3.14.0")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
Binary file added app/libs/libxposed-api-100.aar
Binary file not shown.
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
16 changes: 16 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SimpleRadioAdAway"
tools:targetApi="31" />

</manifest>
148 changes: 148 additions & 0 deletions app/src/main/java/com/gauravssnl/simpleradioadaway/MainModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package com.gauravssnl.simpleradioadaway

import android.os.Bundle
import io.github.libxposed.api.XposedInterface
import io.github.libxposed.api.XposedInterface.AfterHookCallback
import io.github.libxposed.api.XposedInterface.BeforeHookCallback
import io.github.libxposed.api.XposedModule
import io.github.libxposed.api.XposedModuleInterface
import io.github.libxposed.api.XposedModuleInterface.ModuleLoadedParam
import io.github.libxposed.api.annotations.AfterInvocation
import io.github.libxposed.api.annotations.BeforeInvocation
import io.github.libxposed.api.annotations.XposedHooker
import org.apache.commons.lang3.ClassUtils

private const val DEBUG = false //adding this flag to avoid flooding logs; but use for DEBUG
private lateinit var module: MainModule

class MainModule(base: XposedInterface, param: ModuleLoadedParam) : XposedModule(base, param) {
init {
log("MainModule at :: " + param.processName)
module = this
}

override fun onPackageLoaded(param: XposedModuleInterface.PackageLoadedParam) {
super.onPackageLoaded(param)
log("onPackageLoaded :: ${param.packageName}")
log("param classloader is :: ${param.classLoader}")
log("module apk path is :: ${this.applicationInfo.sourceDir}")
log("----------------------------")
if (param.isFirstPackage) {
log("First package loaded")
log("Try finding classes & hooking methods")
val className1 = "${param.packageName}.SimpleRadioBaseActivity"
log("Trying to find className :: $className1")
val clazz1 = ClassUtils.getClass(param.classLoader, className1, false)
val method1 = clazz1.getDeclaredMethod("initAds")
hook(method1, MyHooker::class.java)
val method2 = clazz1.getDeclaredMethod("preloadActivityAds")
hook(method2, MyHooker::class.java)
val method3 = clazz1.getDeclaredMethod("isPremium")
hook(method3, MyHooker::class.java)
val method4 = clazz1.getDeclaredMethod("getAdRequest")
hook(method4, MyHooker::class.java)
val method5 = clazz1.getDeclaredMethod("getAdManagerAdRequest")
hook(method5, MyHooker::class.java)
val method6 = clazz1.getDeclaredMethod("startCMPDeniedActivity")
hook(method6, MyHooker::class.java)
val method7 = clazz1.getDeclaredMethod("openIABScreen", String::class.java)
hook(method7, MyHooker::class.java)
val method8 = clazz1.getDeclaredMethod(
"showInterstitial", String::class.java, String::class.java
)
hook(method8, MyHooker::class.java)
val method9 = clazz1.getDeclaredMethod(
"initInterstitialAd",
String::class.java,
Boolean::class.javaPrimitiveType,
Boolean::class.javaPrimitiveType
)
hook(method9, MyHooker::class.java)

val className2 = "${param.packageName}.MainActivity"
log("Trying to find className :: $className2")
val clazz2 = ClassUtils.getClass(param.classLoader, className2, false)
val method10 = clazz2.getDeclaredMethod("createAdView")
hook(method10, MyHooker::class.java)
val method11 = clazz2.getDeclaredMethod("getInterstitialExperimentAdUnit")
hook(method11, MyHooker::class.java)

val method12 = clazz1.getDeclaredMethod("getInterstitialAdUnit")
hook(method12, MyHooker::class.java)
val method13 = clazz1.getDeclaredMethod("openIABScreen", String::class.java)
hook(method13, MyHooker::class.java)
val method14 = clazz1.getDeclaredMethod("startCMPDeniedActivity")
hook(method14, MyHooker::class.java)
val method15 =
clazz1.getDeclaredMethod("showInterstitial", String::class.java, String::class.java)
hook(method15, MyHooker::class.java)
val method16 =
clazz1.getDeclaredMethod("hideBannerAd", Boolean::class.javaPrimitiveType)
hook(method16, MyHooker::class.java)

val className3 = "${param.packageName}.experiment.AdsExperiment"
log("Trying to find className :: $className2")
val clazz3 = ClassUtils.getClass(param.classLoader, className3, false)
val method17 = clazz3.getDeclaredMethod("b0")
hook(method17, MyHooker::class.java)
val method18 = clazz3.getDeclaredMethod("S")
hook(method18, MyHooker::class.java)
val method19 = clazz3.getDeclaredMethod("Q")
hook(method19, MyHooker::class.java)
val method20 = clazz3.getDeclaredMethod("A0")
hook(method20, MyHooker::class.java)
val method21 = clazz3.getDeclaredMethod("N1")
hook(method21, MyHooker::class.java)

val method24 = clazz1.getDeclaredMethod("onPostCreate", Bundle::class.java)
hook(method24, MyHooker::class.java)

log("All hooking completed. Enjoy Ad-free experience")
}
}

@XposedHooker
class MyHooker : XposedInterface.Hooker {
companion object {
@JvmStatic
@BeforeInvocation
fun beforeInvocation(callback: BeforeHookCallback): MyHooker {
if (DEBUG) module.log("beforeInvocation callback params :: ${callback.args.contentToString()}")
if (DEBUG) module.log("callback member :: ${callback.member}")
if ("hideBannerAd".contentEquals(callback.member.name)) callback.args[0] = true
return MyHooker()
}

@JvmStatic
@AfterInvocation
fun afterInvocation(callback: AfterHookCallback, context: MyHooker) {
if (DEBUG) module.log("afterInvocation callback params :: ${callback.args.contentToString()}")
if (DEBUG) module.log("callback member name :: ${callback.member.name}")
callback.result = when (callback.member.name) {
"isPremium", "b0" -> true
"S", "A0", "Q" -> false
"getAdRequest", "getInterstitialExperimentAdUnit", "getInterstitialAdUnit" -> null
"onPostCreate" -> {
val activityClazzObj = callback.thisObject
val mHideAdField =
activityClazzObj!!::class.java.superclass.getDeclaredField("mHideAd")
mHideAdField.isAccessible = true
mHideAdField.setBoolean(activityClazzObj, true)

val mHideAdFmAdAdapterField =
activityClazzObj::class.java.superclass.getDeclaredField("mAdAdapter")
mHideAdFmAdAdapterField.isAccessible = true
mHideAdFmAdAdapterField.set(activityClazzObj, null)

val mAdsManagerField =
activityClazzObj::class.java.superclass.getDeclaredField("mMediaLabAdViewContainer")
mAdsManagerField.isAccessible = true
mAdsManagerField.set(activityClazzObj, null)
}

else -> return
}
}
}
}
}
Loading

0 comments on commit 059fb88

Please sign in to comment.