From 1ae04c3850eb876c7f4d1956089741e747691b3a Mon Sep 17 00:00:00 2001 From: YuutaW <17158086+trumeet@users.noreply.github.com> Date: Thu, 16 May 2019 16:03:24 -0700 Subject: refactor: remove #Anti-Crack Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com> --- .../moe/yuuta/workmode/access/AccessorStarter.kt | 56 +++------------------- 1 file changed, 7 insertions(+), 49 deletions(-) (limited to 'app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt') 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 a7056c4..b5ffb83 100644 --- a/app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt +++ b/app/src/main/java/moe/yuuta/workmode/access/AccessorStarter.kt @@ -6,6 +6,11 @@ import android.os.Bundle import android.os.PersistableBundle import android.service.quicksettings.TileService import androidx.annotation.WorkerThread +import com.elvishew.xlog.Logger +import com.elvishew.xlog.XLog +import eu.chainfire.librootjava.RootIPCReceiver +import eu.chainfire.librootjava.RootJava +import eu.chainfire.libsuperuser.Shell import moe.yuuta.workmode.BuildConfig import moe.yuuta.workmode.IAccessor import moe.yuuta.workmode.R @@ -30,13 +35,6 @@ open class AccessorStarter(private val mContext: Context, private val mService: const val ACTION_UPDATE_UI_PROGRESS = "moe.yuuta.workmode.access.ACTION_UPDATE_UI_PROGRESS" const val EXTRA_SHOW_PROGRESS = "moe.yuuta.workmode.access.EXTRA_SHOW_PROGRESS" - // #Anti-Crack - internal const val EXTRA_ERROR_CODE = "moe.yuuta.workmode.access.EXTRA_ERROR_CODE" - internal const val EXTRA_ERROR_MSG = "moe.yuuta.workmode.access.EXTRA_ERROR_MSG" - internal const val EXTRA_ERROR_STATUS = "moe.yuuta.workmode.access.EXTRA_ERROR_STATUS" - internal const val EXTRA_DATA = "moe.yuuta.workmode.access.EXTRA_DATA" - internal const val EXTRA_DAT = "moe.yuuta.workmode.access.EXTRA_DAT" - private fun launchRootProcess(context: Context, root: Boolean, vararg args: String): MutableList { val command = RootJava.getLaunchScript(context, WorkModeAccessor::class.java, @@ -104,50 +102,11 @@ open class AccessorStarter(private val mContext: Context, private val mService: fun setPackagesSuspended(packages: List, suspended: Boolean, appExtras: PersistableBundle, launcherExtras: PersistableBundle, dialogMessage: String): Array { - val result = mService.setPackagesSuspended(packages, suspended, appExtras, launcherExtras, dialogMessage) - processError(result) - return result.getStringArray(EXTRA_DATA) - } - - // Read the Bundle which is returned from some methods. - // It contains the crack information and the normal information. - // If it has crack information, log it. - // #Anti-Crack - private fun processError(bundle: Bundle) { - when (bundle.getInt(EXTRA_ERROR_CODE)) { - 1 -> { - } - // If server returns this code, which means the task is successfully executed but - // it had detected that the app was cracked. - // #Anti-Crack - 2 -> { - // The ID is used to prevent from multiple reporting. - val id = bundle.getString(EXTRA_ERROR_STATUS) - val reason = bundle.getString(EXTRA_ERROR_MSG) - SuspendedStorage.get(mContext).reportCrack(id ?: "nd", reason ?: "nr") - } - } + return mService.setPackagesSuspended(packages, suspended, appExtras, launcherExtras, dialogMessage) } fun apply(suspendList: Array, listMode: ListMode, status: Status) { - // Tell the trigger times and times to the server, it will disable the app automatically - // #Anti-Crack - val sp = SuspendedStorage.get(mContext).getStorage() - val keys = sp.all.keys.stream() - .filter { - return@filter it.startsWith("c_") - } - .collect(Collectors.toList()) - val map = hashMapOf() - for (key in keys) { - try { - val times = sp.getInt(key, -1) - map[key] = times - } catch (e: Throwable) {} - } - val dat = Bundle() - dat.putSerializable(EXTRA_DAT, map) - val result = mService.apply(dat, suspendList, + mService.apply(suspendList, when (listMode) { ListMode.BLACKLIST -> 1 ListMode.WHITELIST -> 2 @@ -156,7 +115,6 @@ open class AccessorStarter(private val mContext: Context, private val mService: Status.ON -> 1 Status.OFF -> 2 }) - processError(result) } fun getInstalledApplicationsAcrossUser(flags: Int): List = -- cgit v1.2.3