diff options
author | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-02-28 20:32:26 -0800 |
---|---|---|
committer | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-02-28 20:32:26 -0800 |
commit | 373bda9f0219ecd3f1069bf5fe0637c61dc87787 (patch) | |
tree | 9586d23d13cf1297c3b96cf846a36852f8568839 /app/src/main/java/moe/yuuta/workmode/gpl/GPL.kt | |
parent | 39de35e09424c573670d4c56742c17a3bdbe8108 (diff) | |
download | WorkMode-373bda9f0219ecd3f1069bf5fe0637c61dc87787.tar WorkMode-373bda9f0219ecd3f1069bf5fe0637c61dc87787.tar.gz WorkMode-373bda9f0219ecd3f1069bf5fe0637c61dc87787.tar.bz2 WorkMode-373bda9f0219ecd3f1069bf5fe0637c61dc87787.zip |
feat(app): hide and obfuscate license checking codes as much as we can
Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com>
Diffstat (limited to 'app/src/main/java/moe/yuuta/workmode/gpl/GPL.kt')
-rw-r--r-- | app/src/main/java/moe/yuuta/workmode/gpl/GPL.kt | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/app/src/main/java/moe/yuuta/workmode/gpl/GPL.kt b/app/src/main/java/moe/yuuta/workmode/gpl/GPL.kt new file mode 100644 index 0000000..3824f19 --- /dev/null +++ b/app/src/main/java/moe/yuuta/workmode/gpl/GPL.kt @@ -0,0 +1,47 @@ +package moe.yuuta.workmode.gpl + +import android.annotation.SuppressLint +import android.content.Context +import android.provider.Settings +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleObserver +import androidx.lifecycle.OnLifecycleEvent +import moe.yuuta.gplicense.AESObfuscator +import moe.yuuta.gplicense.LicenseChecker +import moe.yuuta.gplicense.LicenseCheckerCallback +import moe.yuuta.gplicense.ServerManagedPolicy +import moe.yuuta.workmode.BuildConfig + +// #Anti-Crack +// Google Play Licenser +class GPL( + private val context: Context, + private val lifecycle: Lifecycle, + private val callback: LicenseCheckerCallback +) : LifecycleObserver { + private val SALT = byteArrayOf( + -90, 83, 80, -91, -37, -57, 74, -69, 52, 89, + -9, -5, -77, -71, -36, -79, -11, 37, -69, 88 + ) + + private lateinit var instance: LicenseChecker + + @OnLifecycleEvent(Lifecycle.Event.ON_CREATE) + fun start() { + @SuppressLint("HardwareIds") val android_id = Settings.Secure.getString(context.contentResolver, + Settings.Secure.ANDROID_ID) + instance = LicenseChecker( + context, + ServerManagedPolicy(context, AESObfuscator(SALT, BuildConfig.APPLICATION_ID, android_id)), + BuildConfig.GOOGLE_PLAY_LICENSING_KEY + ) + instance.checkAccess(callback) + } + + @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) + fun destroy() { + if (::instance.isInitialized) { + instance.onDestroy() + } + } +}
\ No newline at end of file |