-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SayantanRC
committed
Dec 1, 2021
0 parents
commit a17b495
Showing
38 changed files
with
943 additions
and
0 deletions.
There are no files selected for viewing
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,105 @@ | ||
*.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 | ||
### Android template | ||
# Built application files | ||
*.apk | ||
*.aar | ||
*.ap_ | ||
*.aab | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
# Uncomment the following line in case you need and you don't have the release build type files in your app | ||
# release/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/assetWizardSettings.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
# Android Studio 3 in .gitignore file. | ||
.idea/caches | ||
.idea/modules.xml | ||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you | ||
.idea/navEditor.xml | ||
|
||
# Keystore files | ||
# Uncomment the following lines if you do not want to check your keystore files in. | ||
#*.jks | ||
#*.keystore | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
.cxx/ | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
# google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json | ||
|
||
# fastlane | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output | ||
fastlane/readme.md | ||
|
||
# Version control | ||
vcs.xml | ||
|
||
# lint | ||
lint/intermediates/ | ||
lint/generated/ | ||
lint/outputs/ | ||
lint/tmp/ | ||
# lint/reports/ | ||
|
||
# Android Profiling | ||
*.hprof | ||
|
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.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,41 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
applicationId "balti.xposed.pixelifygooglephotos" | ||
minSdk 21 | ||
targetSdk 31 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled 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 { | ||
|
||
implementation 'androidx.core:core-ktx:1.7.0' | ||
implementation 'androidx.appcompat:appcompat:1.3.1' | ||
implementation 'com.google.android.material:material:1.4.0' | ||
|
||
// Xposed API | ||
compileOnly 'de.robv.android.xposed:api:82' | ||
compileOnly 'de.robv.android.xposed:api:82:sources' | ||
} |
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,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 |
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,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="balti.xposed.pixelifygooglephotos"> | ||
|
||
<application | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.PixelifyGooglePhotos" > | ||
|
||
<meta-data | ||
android:name="xposedmodule" | ||
android:value="true" /> | ||
<meta-data | ||
android:name="xposeddescription" | ||
android:value="Module Google Pixel features in Google Photos on any device." /> | ||
<meta-data | ||
android:name="xposedminversion" | ||
android:value="90" /> | ||
<meta-data | ||
android:name="xposedscope" | ||
android:resource="@array/module_scope" /> | ||
</application> | ||
|
||
</manifest> |
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 @@ | ||
balti.xposed.pixelifygooglephotos.FeatureSpoofer |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/balti/xposed/pixelifygooglephotos/Constants.kt
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,5 @@ | ||
package balti.xposed.pixelifygooglephotos | ||
|
||
object Constants { | ||
val PREF_USE_PIXEL_2016 = "PREF_USE_PIXEL_2016" | ||
} |
133 changes: 133 additions & 0 deletions
133
app/src/main/java/balti/xposed/pixelifygooglephotos/FeatureSpoofer.kt
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,133 @@ | ||
package balti.xposed.pixelifygooglephotos | ||
|
||
import android.util.Log | ||
import balti.xposed.pixelifygooglephotos.Constants.PREF_USE_PIXEL_2016 | ||
import de.robv.android.xposed.* | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage | ||
|
||
class FeatureSpoofer: IXposedHookLoadPackage { | ||
|
||
/** | ||
* For Pixel 2016 only features. | ||
* Use at your own risk. | ||
* By default [featuresToSpoof] will be used. | ||
* https://github.com/DotOS/android_vendor_dot/blob/55f1c26bb6dbb1175d96cf538ae113618caf7d06/prebuilt/common/etc/pixel_2016_exclusive.xml | ||
*/ | ||
private val featuresToSpoofPixel2016: List<String> = listOf( | ||
"com.google.android.apps.photos.NEXUS_PRELOAD", | ||
"com.google.android.apps.photos.nexus_preload", | ||
) | ||
|
||
/** | ||
* Features from PixelFeatureDrops magisk module. | ||
* https://github.com/ayush5harma/PixelFeatureDrops/tree/master/system/etc/sysconfig | ||
*/ | ||
private val featuresToSpoof: List<String> = featuresToSpoofPixel2016 + listOf( | ||
"com.google.android.feature.PIXEL_2017_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2018_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2019_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2019_MIDYEAR_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2020_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2020_MIDYEAR_EXPERIENCE", | ||
) | ||
|
||
/** | ||
* Actual class is not android.content.pm.PackageManager. | ||
* It is an abstract class which cannot be hooked. | ||
* Actual class found from stackoverflow: | ||
* https://stackoverflow.com/questions/66523720/xposed-cant-hook-getinstalledapplications | ||
*/ | ||
private val CLASS_APPLICATION_MANAGER = "android.app.ApplicationPackageManager" | ||
|
||
/** | ||
* Method hasSystemFeature(). Two signatures exist. We need to hook both. | ||
* https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String) | ||
* https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String,%20int) | ||
*/ | ||
private val METHOD_HAS_SYSTEM_FEATURE = "hasSystemFeature" | ||
|
||
/** | ||
* Simple message to log messages in xposed log as well as android log. | ||
*/ | ||
private fun log(message: String){ | ||
XposedBridge.log("PixelifyGooglePhotos: $message") | ||
Log.d("PixelifyGooglePhotos", message) | ||
} | ||
|
||
/** | ||
* To read preference of user. | ||
*/ | ||
private val pref by lazy { | ||
XSharedPreferences("balti.xposed.pixelifygooglephotos") | ||
} | ||
|
||
/** | ||
* This is the final list of features to spoof. | ||
* If user has selected to use Pixel 2016 features, use [featuresToSpoofPixel2016], | ||
* else use [featuresToSpoof] (default selection). | ||
*/ | ||
private val finalFeaturesToSpoof by lazy { | ||
if (pref.getBoolean(PREF_USE_PIXEL_2016, false)) featuresToSpoofPixel2016 | ||
else featuresToSpoof | ||
} | ||
|
||
/** | ||
* If a feature needed for google photos is needed, i.e. features in [finalFeaturesToSpoof], | ||
* then set result of hooked method [METHOD_HAS_SYSTEM_FEATURE] as `true`. | ||
* Else don't set anything. | ||
* | ||
* The [METHOD_HAS_SYSTEM_FEATURE] will be hooked anyway, but if the arguments passed, | ||
* is in [finalFeaturesToSpoof], then set result as true. | ||
*/ | ||
private fun returnTrueForSpoofedFeature(param: XC_MethodHook.MethodHookParam?){ | ||
val arguments = param?.args?.toList() | ||
|
||
var isFeatureToBeSpoofed = false | ||
arguments?.forEach { | ||
if (it.toString() in finalFeaturesToSpoof) isFeatureToBeSpoofed = true | ||
} | ||
|
||
if (isFeatureToBeSpoofed) param?.setResult(true) | ||
} | ||
|
||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) { | ||
log("Loaded ${lpparam?.packageName}") | ||
|
||
/** | ||
* Hook hasSystemFeature(String). | ||
*/ | ||
XposedHelpers.findAndHookMethod( | ||
CLASS_APPLICATION_MANAGER, | ||
lpparam?.classLoader, | ||
METHOD_HAS_SYSTEM_FEATURE, String::class.java, | ||
object: XC_MethodHook() { | ||
|
||
override fun beforeHookedMethod(param: MethodHookParam?) { | ||
super.beforeHookedMethod(param) | ||
log("$METHOD_HAS_SYSTEM_FEATURE String") | ||
returnTrueForSpoofedFeature(param) | ||
} | ||
|
||
} | ||
) | ||
|
||
/** | ||
* Hook hasSystemFeature(String, int). | ||
*/ | ||
XposedHelpers.findAndHookMethod( | ||
CLASS_APPLICATION_MANAGER, | ||
lpparam?.classLoader, | ||
METHOD_HAS_SYSTEM_FEATURE, String::class.java, Int::class.java, | ||
object: XC_MethodHook() { | ||
|
||
override fun beforeHookedMethod(param: MethodHookParam?) { | ||
super.beforeHookedMethod(param) | ||
log("$METHOD_HAS_SYSTEM_FEATURE (String, Int)") | ||
returnTrueForSpoofedFeature(param) | ||
} | ||
|
||
} | ||
) | ||
|
||
} | ||
} |
Oops, something went wrong.