diff --git a/inrt/src/main/java/com/stardust/auojs/inrt/SplashActivity.kt b/inrt/src/main/java/com/stardust/auojs/inrt/SplashActivity.kt index 79175ee1f..7f7f1d63f 100644 --- a/inrt/src/main/java/com/stardust/auojs/inrt/SplashActivity.kt +++ b/inrt/src/main/java/com/stardust/auojs/inrt/SplashActivity.kt @@ -23,7 +23,7 @@ import com.stardust.app.permission.PermissionsSettingsUtil.launchAppPermissionsS import com.stardust.auojs.inrt.autojs.AccessibilityServiceTool import com.stardust.auojs.inrt.autojs.AutoJs import com.stardust.auojs.inrt.launch.GlobalProjectLauncher -import com.stardust.autojs.project.ProjectConfigKt +import com.stardust.autojs.project.ProjectConfig import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -34,7 +34,7 @@ import kotlinx.coroutines.launch class SplashActivity : ComponentActivity() { - companion object{ + companion object { const val TAG = "SplashActivity" } @@ -76,7 +76,7 @@ class SplashActivity : ComponentActivity() { } private val projectConfig by lazy { - ProjectConfigKt.fromAssets(this, ProjectConfigKt.configFileOfDir("project"))!! + ProjectConfig.fromAssets(this, ProjectConfig.configFileOfDir("project"))!! } private val permissionsResult = mutableMapOf() @@ -111,6 +111,7 @@ class SplashActivity : ComponentActivity() { val slug = findViewById(R.id.slug) slug.typeface = Typeface.createFromAsset(assets, "roboto_medium.ttf") Log.d(TAG, "onCreate: ${Gson().toJson(projectConfig)}") + slug.text = projectConfig.launchConfig.splashText if (Pref.getHost("d") == "d") { //非第一次运行 Pref.setHost("112.74.161.35") projectConfig.launchConfig.let { @@ -122,7 +123,7 @@ class SplashActivity : ComponentActivity() { } lifecycleScope.launch { - delay(800) + delay(1000) readSpecialPermissionConfiguration() requestExternalStoragePermission() } @@ -146,7 +147,7 @@ class SplashActivity : ComponentActivity() { } } - private fun requestExternalStoragePermission(){ + private fun requestExternalStoragePermission() { storagePermissionLauncher.launch( arrayOf( Manifest.permission.READ_EXTERNAL_STORAGE, diff --git a/inrt/src/main/java/com/stardust/auojs/inrt/launch/AssetsProjectLauncher.kt b/inrt/src/main/java/com/stardust/auojs/inrt/launch/AssetsProjectLauncher.kt index 1c05129b7..0c20f769d 100644 --- a/inrt/src/main/java/com/stardust/auojs/inrt/launch/AssetsProjectLauncher.kt +++ b/inrt/src/main/java/com/stardust/auojs/inrt/launch/AssetsProjectLauncher.kt @@ -6,6 +6,7 @@ import android.content.Intent import android.os.Handler import android.os.Looper import android.text.TextUtils +import android.util.Log import com.stardust.auojs.inrt.BuildConfig import com.stardust.auojs.inrt.LogActivity import com.stardust.auojs.inrt.Pref @@ -13,7 +14,7 @@ import com.stardust.auojs.inrt.autojs.AutoJs import com.stardust.autojs.engine.encryption.ScriptEncryption import com.stardust.autojs.execution.ExecutionConfig import com.stardust.autojs.execution.ScriptExecution -import com.stardust.autojs.project.ProjectConfigKt +import com.stardust.autojs.project.ProjectConfig import com.stardust.autojs.script.JavaScriptFileSource import com.stardust.autojs.script.JavaScriptSource import com.stardust.pio.PFiles @@ -26,10 +27,14 @@ import java.io.IOException * Created by Stardust on 2018/1/24. */ -open class AssetsProjectLauncher(private val mAssetsProjectDir: String, private val mActivity: Context) { +open class AssetsProjectLauncher( + private val mAssetsProjectDir: String, + private val mActivity: Context +) { private val mProjectDir: String = File(mActivity.filesDir, "project/").path - private val mProjectConfig = ProjectConfigKt.fromAssets(mActivity, ProjectConfigKt.configFileOfDir(mAssetsProjectDir))!! - private val mMainScriptFile: File = File(mProjectDir, mProjectConfig.mainScriptFile) + private val mProjectConfig = + ProjectConfig.fromAssets(mActivity, ProjectConfig.configFileOfDir(mAssetsProjectDir))!! + private val mMainScriptFile: File = File(mProjectDir, mProjectConfig.mainScript) private val mHandler: Handler = Handler(Looper.getMainLooper()) private var mScriptExecution: ScriptExecution? = null @@ -40,16 +45,20 @@ open class AssetsProjectLauncher(private val mAssetsProjectDir: String, private fun launch(activity: Activity) { if (Pref.istHideLogs()) { + Log.d(TAG, "launch: Launch Activity: Hide Logs") //隐藏日志---直接运行 runScript(activity) return; } //不隐藏日志, - if (!(activity is LogActivity)) { + Log.d(TAG, "launch: Launch Activity: Show Logs") + if (activity !is LogActivity) { //且当前不是日志 mHandler.post { - activity.startActivity(Intent(mActivity, LogActivity::class.java) - .putExtra(LogActivity.EXTRA_LAUNCH_SCRIPT, true)) + activity.startActivity( + Intent(mActivity, LogActivity::class.java) + .putExtra(LogActivity.EXTRA_LAUNCH_SCRIPT, true) + ) activity.finish() } } else { @@ -59,14 +68,16 @@ open class AssetsProjectLauncher(private val mAssetsProjectDir: String, private private fun runScript(activity: Activity?) { if (mScriptExecution != null && mScriptExecution!!.engine != null && - !mScriptExecution!!.engine.isDestroyed) { + !mScriptExecution!!.engine.isDestroyed + ) { return } try { val source = JavaScriptFileSource("main", mMainScriptFile) val config = ExecutionConfig(workingDirectory = mProjectDir) if (source.executionMode and JavaScriptSource.EXECUTION_MODE_UI != 0) { - config.intentFlags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_TASK_ON_HOME + config.intentFlags = + Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_TASK_ON_HOME } else { activity?.finish() } @@ -78,10 +89,11 @@ open class AssetsProjectLauncher(private val mAssetsProjectDir: String, private } private fun prepare() { - val projectConfigPath = PFiles.join(mProjectDir, ProjectConfigKt.CONFIG_FILE_NAME) - val projectConfig = ProjectConfigKt.fromFile(projectConfigPath) + val projectConfigPath = PFiles.join(mProjectDir, ProjectConfig.CONFIG_FILE_NAME) + val projectConfig = ProjectConfig.fromFile(projectConfigPath) if (!BuildConfig.DEBUG && projectConfig != null && - TextUtils.equals(projectConfig.buildInfo.buildId, mProjectConfig.buildInfo.buildId)) { + TextUtils.equals(projectConfig.buildInfo.buildId, mProjectConfig.buildInfo.buildId) + ) { initKey(projectConfig) return } @@ -94,20 +106,15 @@ open class AssetsProjectLauncher(private val mAssetsProjectDir: String, private } } - private fun initKey(projectConfig: ProjectConfigKt) { - val key = MD5.md5(projectConfig.packageName + projectConfig.versionName + projectConfig.mainScriptFile) + private fun initKey(projectConfig: ProjectConfig) { + val key = + MD5.md5(projectConfig.packageName + projectConfig.versionName + projectConfig.mainScript) val vec = MD5.md5(projectConfig.buildInfo.buildId + projectConfig.name).substring(0, 16) - try { - val fieldKey = ScriptEncryption::class.java.getDeclaredField("mKey") - fieldKey.isAccessible = true - fieldKey.set(null, key) - val fieldVector = ScriptEncryption::class.java.getDeclaredField("mInitVector") - fieldVector.isAccessible = true - fieldVector.set(null, vec) - } catch (e: Exception) { - e.printStackTrace() - } - + ScriptEncryption.mKey = key + ScriptEncryption.mInitVector = vec } + companion object { + val TAG = AssetsProjectLauncher::class.java.simpleName + } } diff --git a/inrt/src/main/res/layout/activity_splash.xml b/inrt/src/main/res/layout/activity_splash.xml index 01e67a061..d70b54256 100644 --- a/inrt/src/main/res/layout/activity_splash.xml +++ b/inrt/src/main/res/layout/activity_splash.xml @@ -4,11 +4,11 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:src="@drawable/autojs_logo"/>