-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring Xposed logic
- Loading branch information
MIkhail Aminov
committed
Sep 8, 2023
1 parent
18b608c
commit d71b272
Showing
13 changed files
with
145 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ru.n00byara.motionsenseunlocker.components.xposed.Xposed | ||
ru.n00byara.motionsenseunlocker.components.xposed.XposedEntry |
66 changes: 0 additions & 66 deletions
66
app/src/main/java/ru/n00byara/motionsenseunlocker/components/xposed/Xposed.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
app/src/main/java/ru/n00byara/motionsenseunlocker/components/xposed/XposedEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed; | ||
|
||
import de.robv.android.xposed.IXposedHookLoadPackage; | ||
import de.robv.android.xposed.XposedBridge; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
|
||
public class XposedEntry implements IXposedHookLoadPackage { | ||
private XposedLauncher XposedLauncher = new XposedLauncher(); | ||
|
||
@Override | ||
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { | ||
if (android.os.Build.VERSION.SDK_INT != 33) { | ||
XposedBridge.log("Android 13 supported only!"); | ||
return; | ||
} | ||
|
||
XposedLauncher.handleLoadPackage(lpparam); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/ru/n00byara/motionsenseunlocker/components/xposed/XposedLauncher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed; | ||
|
||
import de.robv.android.xposed.XposedBridge; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.ModPacks; | ||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.XposedModPack; | ||
|
||
public class XposedLauncher { | ||
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { | ||
for (Class<? extends XposedModPack> mod : ModPacks.getMods(lpparam.packageName)) { | ||
try { | ||
XposedModPack instance = mod.getConstructor().newInstance(); | ||
instance.handleLoadPackage(lpparam); | ||
} catch (Throwable T) { | ||
XposedBridge.log("Start Error in " + mod.getName()); | ||
XposedBridge.log(T); | ||
} | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/ru/n00byara/motionsenseunlocker/components/xposed/mods/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed.mods; | ||
|
||
public class Constants { | ||
public static final String SETTINGS_PACKAGE = "com.android.settings"; | ||
public static final String OSLO_PACKAGE = "com.google.oslo"; | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/ru/n00byara/motionsenseunlocker/components/xposed/mods/ModPacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed.mods; | ||
|
||
import java.util.ArrayList; | ||
|
||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.oslo.service.OsloEnableDetector; | ||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.oslo.service.actions.MediaPlayerAction; | ||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.settings.aware.AwareHelper; | ||
|
||
public class ModPacks { | ||
public static ArrayList<Class<? extends XposedModPack>> getMods(String packageName) { | ||
ArrayList<Class<? extends XposedModPack>> modPacks = new ArrayList<>(); | ||
|
||
switch (packageName) { | ||
case Constants.OSLO_PACKAGE: | ||
modPacks.add(MediaPlayerAction.class); | ||
modPacks.add(OsloEnableDetector.class); | ||
break; | ||
case Constants.SETTINGS_PACKAGE: | ||
modPacks.add(AwareHelper.class); | ||
break; | ||
} | ||
|
||
return modPacks; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/ru/n00byara/motionsenseunlocker/components/xposed/mods/XposedModPack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed.mods; | ||
|
||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
|
||
public abstract class XposedModPack { | ||
public abstract void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable; | ||
} |
18 changes: 18 additions & 0 deletions
18
.../n00byara/motionsenseunlocker/components/xposed/mods/oslo/service/OsloEnableDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed.mods.oslo.service; | ||
|
||
import de.robv.android.xposed.XC_MethodReplacement; | ||
import de.robv.android.xposed.XposedHelpers; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.XposedModPack; | ||
|
||
public class OsloEnableDetector extends XposedModPack { | ||
private Class<?> OsloEnableDetector; | ||
@Override | ||
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { | ||
OsloEnableDetector = XposedHelpers.findClass("com.google.oslo.service.OsloEnableDetector", lpparam.classLoader); | ||
|
||
XposedHelpers.findAndHookMethod(OsloEnableDetector, "getAirplaneModeEnabled", XC_MethodReplacement.returnConstant(false)); | ||
XposedHelpers.findAndHookMethod(OsloEnableDetector, "getBatterySaverEnabled", XC_MethodReplacement.returnConstant(false)); | ||
XposedHelpers.findAndHookMethod(OsloEnableDetector, "getCountryOverride", XC_MethodReplacement.returnConstant(true)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ra/motionsenseunlocker/components/xposed/mods/oslo/service/actions/MediaPlayerAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed.mods.oslo.service.actions; | ||
|
||
import de.robv.android.xposed.XC_MethodReplacement; | ||
import de.robv.android.xposed.XposedHelpers; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.XposedModPack; | ||
|
||
public class MediaPlayerAction extends XposedModPack { | ||
private Class<?> MediaPlayerAction; | ||
|
||
@Override | ||
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { | ||
MediaPlayerAction = XposedHelpers.findClass("com.google.oslo.service.actions.MediaPlayerAction", lpparam.classLoader); | ||
|
||
XposedHelpers.findAndHookMethod(MediaPlayerAction, "isSupportedApp", String.class, XC_MethodReplacement.returnConstant(true)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...va/ru/n00byara/motionsenseunlocker/components/xposed/mods/settings/aware/AwareHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ru.n00byara.motionsenseunlocker.components.xposed.mods.settings.aware; | ||
|
||
import de.robv.android.xposed.XC_MethodReplacement; | ||
import de.robv.android.xposed.XposedHelpers; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import ru.n00byara.motionsenseunlocker.components.xposed.mods.XposedModPack; | ||
|
||
public class AwareHelper extends XposedModPack { | ||
private Class<?> AwareHelper; | ||
@Override | ||
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { | ||
AwareHelper = XposedHelpers.findClass("com.google.android.settings.aware.AwareHelper", lpparam.classLoader); | ||
|
||
XposedHelpers.findAndHookMethod(AwareHelper, "isAirplaneModeOn", XC_MethodReplacement.returnConstant(false)); | ||
XposedHelpers.findAndHookMethod(AwareHelper, "isBatterySaverModeOn", XC_MethodReplacement.returnConstant(false)); | ||
} | ||
} |