aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt
diff options
context:
space:
mode:
authorYuutaW <17158086+Trumeet@users.noreply.github.com>2019-02-24 17:09:23 -0800
committerYuutaW <17158086+Trumeet@users.noreply.github.com>2019-02-24 17:09:23 -0800
commit6f3bff631d9f5a9189100ee617a15394f4e8ad62 (patch)
tree5581bbd8eaa2071a78c2587296f557e72d790fda /app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt
parent1d1dd33029efb5c2207d78af16d3879bbaf4c9e0 (diff)
downloadWorkMode-6f3bff631d9f5a9189100ee617a15394f4e8ad62.tar
WorkMode-6f3bff631d9f5a9189100ee617a15394f4e8ad62.tar.gz
WorkMode-6f3bff631d9f5a9189100ee617a15394f4e8ad62.tar.bz2
WorkMode-6f3bff631d9f5a9189100ee617a15394f4e8ad62.zip
feat(app): implement piracy checker
Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com>
Diffstat (limited to 'app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt')
-rw-r--r--app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt b/app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt
index c8aae67..5845ff2 100644
--- a/app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt
+++ b/app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt
@@ -4,13 +4,18 @@ import android.content.Context
import android.os.Bundle
import android.os.Parcel
import android.os.PersistableBundle
+import com.crashlytics.android.Crashlytics
+import com.crashlytics.android.answers.Answers
+import com.crashlytics.android.answers.CustomEvent
import com.elvishew.xlog.Logger
import com.elvishew.xlog.XLog
import eu.chainfire.librootjava.RootJava
import eu.chainfire.libsuperuser.Shell
import moe.yuuta.workmode.BuildConfig
+import moe.yuuta.workmode.Setup
import moe.yuuta.workmode.suspend.data.ListMode
import moe.yuuta.workmode.suspend.data.Status
+import moe.yuuta.workmode.suspend.data.SuspendedStorage
import moe.yuuta.workmode.utils.ByteArraySerializer
/**
@@ -154,6 +159,33 @@ open class AccessorStarter(private val mContext: Context, private val mLogPath:
}
throw RuntimeException("Unsuccessful result with unknown stacktrace")
}
+ // If server returns this code, which means the task is successfully executed but
+ // it had detected that the app was cracked.
+ // #Anti-Crack
+ 2.toByte() -> {
+ // The ID is used to prevent from multiple reporting.
+ val id = result.readString()
+ // 0: not written
+ // 1: already reported
+ val writtenValue = SuspendedStorage(mContext).getStorage().getInt("c_$id", 0)
+ if (writtenValue == 0) {
+ val reason = result.readString()
+ Runnable {
+ Runnable {
+ if (Setup.FABRIC_ENABLE)
+ Runnable {
+ Answers.getInstance().logCustom(CustomEvent("St.rf.pa.")
+ .putCustomAttribute("rn", reason))
+ Crashlytics.log("Sf. $reason")
+ }.run()
+ SuspendedStorage(mContext).getStorage().edit()
+ .putInt("c_$id", 1)
+ .apply()
+ }.run()
+ }.run()
+ } else {
+ }
+ }
}
return result
}