From 9b5171ac5416e1108409bdae3b0271e9a4452fa2 Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 6 Aug 2025 18:45:49 +0800 Subject: [PATCH] tag120 --- app/build.gradle.kts | 16 ++- .../java/com/android/grape/util/FileUtils.kt | 113 +----------------- .../java/com/android/grape/util/TaskUtils.kt | 6 +- 3 files changed, 20 insertions(+), 115 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fe99d78..1ba7031 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -30,6 +30,20 @@ android { buildTypes { release { + buildConfigField("int", "TAG", "119") + signingConfig = signingConfigs.getByName("release") + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + debug { + buildConfigField("int", "TAG", "120") + isMinifyEnabled = false + } + create("home") { + buildConfigField("int", "TAG", "120") signingConfig = signingConfigs.getByName("release") isMinifyEnabled = false proguardFiles( @@ -56,7 +70,7 @@ android { variant.outputs.all { val versionName = variant.versionName val versionCode = variant.versionCode - val outputFileName = "app-${variant.applicationId}-v${versionName}-${versionCode}.apk" + val outputFileName = "Grape-${variant.name}-v${versionName}-${versionCode}.apk" if (this is ApkVariantOutputImpl) { this.outputFileName = outputFileName diff --git a/app/src/main/java/com/android/grape/util/FileUtils.kt b/app/src/main/java/com/android/grape/util/FileUtils.kt index ce49c23..6102ee2 100644 --- a/app/src/main/java/com/android/grape/util/FileUtils.kt +++ b/app/src/main/java/com/android/grape/util/FileUtils.kt @@ -319,55 +319,6 @@ object FileUtils { } - /** - * 向文件中添加内容 - * - * @param strcontent 内容 - * @param filePath 地址 - * @param fileName 文件名 - */ - fun writeToFile(strcontent: String, filePath: String, fileName: String) { - //生成文件夹之后,再生成文件,不然会出错 - val strFilePath = filePath + fileName - - // 每次写入时,都换行写 - val subfile = File(strFilePath) - - - var raf: RandomAccessFile? = null - try { - /** 构造函数 第二个是读写方式 */ - raf = RandomAccessFile(subfile, "rw") - /** 将记录指针移动到该文件的最后 */ - raf.seek(subfile.length()) - /** 向文件末尾追加内容 */ - raf.write(strcontent.toByteArray()) - - raf.close() - } catch (e: IOException) { - e.printStackTrace() - } - } - - - /** - * 修改文件内容(覆盖或者添加) - * - * @param path 文件地址 - * @param content 覆盖内容 - * @param append 指定了写入的方式,是覆盖写还是追加写(true=追加)(false=覆盖) - */ - fun modifyFile(path: String?, content: String?, append: Boolean) { - try { - val fileWriter = FileWriter(path, append) - val writer = BufferedWriter(fileWriter) - writer.append(content) - writer.flush() - writer.close() - } catch (e: IOException) { - e.printStackTrace() - } - } /** * 读取文件内容 @@ -380,19 +331,6 @@ object FileUtils { return File(filePath, filename).takeIf { it.exists() }?.readText() ?: "" } - /** - * 重命名文件 - * - * @param oldPath 原来的文件地址 - * @param newPath 新的文件地址 - */ - fun renameFile(oldPath: String, newPath: String) { - val oleFile = File(oldPath) - val newFile = File(newPath) - //执行重命名 - oleFile.renameTo(newFile) - } - /** * 复制文件 @@ -472,54 +410,6 @@ object FileUtils { } - /** - * 解压缩一个文件 - * - * @param zipFile 压缩文件 - * @param folderPath 解压缩的目标目录 - * @return - * @throws IOException 当解压缩过程出错时抛出 - */ - @Throws(IOException::class) - fun upZipFile(zipFile: File?, folderPath: String): ArrayList { - val fileList = ArrayList() - val desDir = File(folderPath) - if (!desDir.exists()) { - desDir.mkdirs() - } - val zf = ZipFile(zipFile) - val entries: Enumeration<*> = zf.entries() - while (entries.hasMoreElements()) { - val entry = entries.nextElement() as ZipEntry - if (entry.isDirectory) { - continue - } - val `is` = zf.getInputStream(entry) - var str = folderPath + File.separator + entry.name - str = String(str.toByteArray(charset("8859_1")), charset("UTF-8")) - val desFile = File(str) - if (!desFile.exists()) { - val fileParentDir = desFile.parentFile - if (!fileParentDir!!.exists()) { - fileParentDir.mkdirs() - } - desFile.createNewFile() - } - val os: OutputStream = FileOutputStream(desFile) - val buffer = ByteArray(BUFFER_SIZE) - var length: Int - while ((`is`.read(buffer).also { length = it }) > 0) { - os.write(buffer, 0, length) - } - os.flush() - os.close() - `is`.close() - fileList.add(desFile) - } - return fileList - } - - //复制文件 @Throws(IOException::class) fun copyFile(sourceFile: File?, targetFile: File?) { @@ -574,6 +464,7 @@ object FileUtils { } fun writeAfLog() { + LogUtils.d("FileUtils", "writeAfLog: ") val filePath = "/data/data/${recordPackageName}/log.txt" ShellUtil.execRootCmdAndGetResult("chmod 777 $filePath") val afLog = ShellUtil.execRootCmdAndGetResult("cat $filePath") @@ -589,7 +480,7 @@ object FileUtils { return } } - LogUtils.d("FileUtils", "afLog: $afLog", null) + LogUtils.d("FileUtils", "afLog: $afLog") try { BufferedOutputStream( FileOutputStream(file) diff --git a/app/src/main/java/com/android/grape/util/TaskUtils.kt b/app/src/main/java/com/android/grape/util/TaskUtils.kt index 531dc31..7ee9372 100644 --- a/app/src/main/java/com/android/grape/util/TaskUtils.kt +++ b/app/src/main/java/com/android/grape/util/TaskUtils.kt @@ -7,6 +7,7 @@ import android.os.Handler import android.os.Looper import android.provider.Settings import android.util.Log +import com.android.grape.BuildConfig import com.android.grape.MainApplication import com.android.grape.data.AppState import com.android.grape.data.AppState.afLog @@ -177,7 +178,7 @@ object TaskUtils { // String params = "platform=Android&"TaskUtils"="+get"TaskUtils"(context)+"&uuid="+PrefUtil.getUUID(context); val ANDROID_ID = Settings.System.getString(context.contentResolver, Settings.Secure.ANDROID_ID) - val params = "platform=Android&tag=119&uuid=$ANDROID_ID" + val params = "platform=Android&tag=${BuildConfig.TAG}&uuid=$ANDROID_ID" val valid = false println("IOSTQ:execReloginTask->url:$url?$params") try { @@ -220,8 +221,7 @@ object TaskUtils { val url = "http://39.103.73.250/tt/ddj/preRequest!requestInstall.do" val ANDROID_ID = Settings.System.getString(context.contentResolver, Settings.System.ANDROID_ID) - - val params = "platform=Android&tag=119&uuid=$ANDROID_ID" + val params = "platform=Android&tag=${BuildConfig.TAG}&uuid=$ANDROID_ID" printStr("IOSTQ:request result : $url?$params") try { val result: String? = postData(