diff --git a/app/build.gradle b/app/build.gradle index 530ba43..a96a555 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,7 +19,7 @@ android { //noinspection ExpiredTargetSdkVersion targetSdkVersion 28 versionCode(Common.getversionCode()) - versionName "4.7" + (Common.getGitHeadRefsSuffix(rootProject)) + versionName "4.9" + (Common.getGitHeadRefsSuffix(rootProject)) } buildTypes { release { diff --git a/app/src/main/assets/kr-script/Install_Command.sh b/app/src/main/assets/kr-script/Install_Command.sh deleted file mode 100644 index 8faeb47..0000000 --- a/app/src/main/assets/kr-script/Install_Command.sh +++ /dev/null @@ -1,41 +0,0 @@ -abort() { - echo "$@" 1>&2 - sleep 3 - exec exit 1 -} - - -Script_Dir=$TMPDIR/Script_Dir -jian=`cat ~/downloader/path/* 2>/dev/null` -jian2=$Script_Dir/META-INF/com/google/android/update-binary - -[[ ! -f "$jian" ]] && abort "!未下载文件" -echo "文件路径:$jian" - -if [[ $1 = -apk ]]; then - echo "- 开始安装搞机助手-CMD版.apk,如果未能重启搞机助手请手动重启" - sleep 3 - pm uninstall $Package_name - cp -f "$jian" "$TMP/$Package_name.apk" - pm install -r "$TMP/$Package_name.apk" - rm -f "$TMP/$Package_name.apk" - $Have_ROOT && am start -S $Package_name/gjzs.online.SplashActivity - exit 0 -fi - - -echo "- 开始安装curl" -rm -rf $Script_Dir -mkdir -p $Script_Dir -unzip -oq "$jian" 'META-INF/com/google/android/update-binary' -d $Script_Dir - -if [[ -f "$jian2" ]]; then - sh "$jian2" $1 1 "$jian" - if $Have_ROOT; then - echo "- 已安装完成开始重启搞机助手" - sleep 3 - am start -S $Package_name/gjzs.online.SplashActivity - fi -else - abort "!解压文件失败" -fi \ No newline at end of file diff --git a/app/src/main/assets/kr-script/Start.sh b/app/src/main/assets/kr-script/Start.sh index 1fe6cfd..59247b3 100644 --- a/app/src/main/assets/kr-script/Start.sh +++ b/app/src/main/assets/kr-script/Start.sh @@ -5,25 +5,9 @@ abort() { } Inject() { - [[ ! -x "`curl -where`" ]] && Install_Curl curl -L -s -o "$2" "$CODING/$1" } -Install_Curl() { - echo "- $curl_not_found" - Curl_URL='http://159.27.81.21/curl' - wget -O $ELF1_Path/curl3 "$Curl_URL/`getprop ro.product.cpu.abi`" - wget -O $ELF1_Path/curl3 "$Curl_URL/armeabi-v7a" - wget -O ~/cacert.pem "$Curl_URL/cacert.pem" - if $Have_ROOT; then - . $Core - [[ ! -f "$ELF1_Path/curl3" ]] && downloader "$ELF1_Path/curl3" "$Curl_URL/`getprop ro.product.cpu.abi`" - [[ ! -f "$ELF1_Path/curl3" ]] && downloader "$ELF1_Path/curl3" "$Curl_URL/armeabi-v7a" - [[ ! -f ~/cacert.pem ]] && downloader ~/cacert.pem "$Curl_URL/cacert.pem" - fi - chmod +x $ELF1_Path/curl3 -} - SCRIPT() { if [[ ! -f $2 ]]; then Inject $1 $2 diff --git a/app/src/main/assets/usr/xbin/arm64-v8a/curl b/app/src/main/assets/usr/xbin/arm64-v8a/curl new file mode 100644 index 0000000..ac20f5d Binary files /dev/null and b/app/src/main/assets/usr/xbin/arm64-v8a/curl differ diff --git a/app/src/main/assets/usr/xbin/armeabi-v7a/curl b/app/src/main/assets/usr/xbin/armeabi-v7a/curl new file mode 100644 index 0000000..e3c79dc Binary files /dev/null and b/app/src/main/assets/usr/xbin/armeabi-v7a/curl differ diff --git a/app/src/main/assets/usr/xbin/curl b/app/src/main/assets/usr/xbin/curl index d45c80f..99e5bd5 100644 --- a/app/src/main/assets/usr/xbin/curl +++ b/app/src/main/assets/usr/xbin/curl @@ -6,33 +6,8 @@ CURL() { fi } -CURL2() { - if [[ "$1" = -where ]]; then - exec echo "$C" - elif [[ "$1" = -V ]]; then - exec "$C" "$@" - elif [[ "$1" = --version ]]; then - exec "$C" "$@" - elif [[ "$1" = --help ]]; then - exec "$C" "$@" - elif [[ "$1" = -h ]]; then - exec "$C" "$@" - else - ping -w 1 223.5.5.5 > /dev/null && DoH_Ser='223.5.5.5' - [[ ! -n $DoH_Ser ]] && ping -w 1 223.6.6.6 > /dev/null && DoH_Ser='223.6.6.6' - [[ ! -n $DoH_Ser ]] && ping -w 1 120.53.80.136 > /dev/null && DoH_Ser='120.53.80.136' - [[ ! -n $DoH_Ser ]] && ping -w 1 175.24.219.66 > /dev/null && DoH_Ser='175.24.219.66' - [[ ! -n $DoH_Ser ]] && ping -w 1 8.8.8.8 > /dev/null && DoH_Ser='8.8.8.8' - [[ ! -n $DoH_Ser ]] && ping -w 1 9.9.9.9 > /dev/null && DoH_Ser='9.9.9.9' - [[ ! -n $DoH_Ser ]] && DoH_Ser='223.5.5.5' - "$C" --doh-url "https://$DoH_Ser/dns-query" --doh-insecure --cacert ~/cacert.pem "$@" - fi -} - -C="$ELF1_Path/curl3" -[[ -x "$C" ]] && CURL2 "$@" - -C="$ELF1_Path/curl2" +Arch=$(getprop ro.product.cpu.abi) +C="$ELF3_Path/$Arch/curl" [[ -x "$C" ]] && CURL "$@" C="$DATA_DIR/com.termux/files/usr/bin/curl" diff --git a/app/src/main/assets/usr/xbin/x86/curl b/app/src/main/assets/usr/xbin/x86/curl new file mode 100644 index 0000000..c4bb757 Binary files /dev/null and b/app/src/main/assets/usr/xbin/x86/curl differ diff --git a/app/src/main/assets/usr/xbin/x86_64/curl b/app/src/main/assets/usr/xbin/x86_64/curl new file mode 100644 index 0000000..951fecd Binary files /dev/null and b/app/src/main/assets/usr/xbin/x86_64/curl differ diff --git a/app/src/main/java/gjzs/online/AboutActivity.kt b/app/src/main/java/gjzs/online/AboutActivity.kt index 5faae98..5783e83 100644 --- a/app/src/main/java/gjzs/online/AboutActivity.kt +++ b/app/src/main/java/gjzs/online/AboutActivity.kt @@ -40,36 +40,57 @@ class AboutActivity : AbsAboutActivity() { items.add(License("appcenter-sdk-android", "microsoft", License.MIT, "https://github.com/microsoft/appcenter-sdk-android")) items.add(License("AndroidHiddenApiBypass", "LSPosed", License.APACHE_2, "https://github.com/LSPosed/AndroidHiddenApiBypass")) items.add(License("StringFog", "MegatronKing", License.APACHE_2, "https://github.com/MegatronKing/StringFog")) + items.add(License("curl-android", "vvb2060", "No License", "https://github.com/vvb2060/curl-android")) } override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_about, menu) + // TransparentUI val transparent = menu.findItem(R.id.transparent_ui) val themeConfig = ThemeConfig(this) transparent.isChecked = themeConfig.getAllowTransparentUI() + // App Center Status + val appcenter = menu.findItem(R.id.appcenter_switch) + val appcenterStatus = AppCenterStatus(this) + appcenter.isChecked = appcenterStatus.getAppCenterStatus() return super.onCreateOptionsMenu(menu) } override fun onOptionsItemSelected(menuItem: MenuItem): Boolean { - val themeConfig = ThemeConfig(this) - if (menuItem.isChecked) { - themeConfig.setAllowTransparentUI(false) - val intent = Intent() - intent.setClass(this,MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK - startActivity(intent) - } else { - fun checkPermission(permission: String): Boolean = PermissionChecker.checkSelfPermission(this, permission) == PermissionChecker.PERMISSION_GRANTED - if (menuItem.isChecked && !checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) { - themeConfig.setAllowTransparentUI(false) - Toast.makeText(this@AboutActivity, R.string.kr_write_external_storage, Toast.LENGTH_SHORT).show() - } else { - themeConfig.setAllowTransparentUI(true) - val intent = Intent() - intent.setClass(this,MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK - startActivity(intent) + return when (menuItem.itemId) { + R.id.transparent_ui -> { + val themeConfig = ThemeConfig(this) + if (menuItem.isChecked) { + themeConfig.setAllowTransparentUI(false) + val intent = Intent() + intent.setClass(this, MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK + startActivity(intent) + } else { + fun checkPermission(permission: String): Boolean = PermissionChecker.checkSelfPermission(this, permission) == PermissionChecker.PERMISSION_GRANTED + if (menuItem.isChecked && !checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) { + themeConfig.setAllowTransparentUI(false) + Toast.makeText(this@AboutActivity, R.string.kr_write_external_storage, Toast.LENGTH_SHORT).show() + } else { + themeConfig.setAllowTransparentUI(true) + val intent = Intent() + intent.setClass(this, MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK + startActivity(intent) + } + } + return true + } + R.id.appcenter_switch -> { + val appcenterStatus = AppCenterStatus(this) + if (menuItem.isChecked) { + appcenterStatus.setAppCenterStatus(false) + invalidateOptionsMenu() + } else { + appcenterStatus.setAppCenterStatus(true) + invalidateOptionsMenu() + } + return true } + else -> super.onOptionsItemSelected(menuItem) } - return true } - } \ No newline at end of file diff --git a/app/src/main/java/gjzs/online/AppCenterStatus.kt b/app/src/main/java/gjzs/online/AppCenterStatus.kt new file mode 100644 index 0000000..6dcef23 --- /dev/null +++ b/app/src/main/java/gjzs/online/AppCenterStatus.kt @@ -0,0 +1,16 @@ +package gjzs.online + +import android.app.Activity +import android.content.Context + +class AppCenterStatus (private val activity: Activity) { + private val config = activity.getSharedPreferences("AppCenter_status", Context.MODE_PRIVATE) + + fun getAppCenterStatus(): Boolean { + return config.getBoolean("Status", true) + } + + fun setAppCenterStatus(allow: Boolean) { + config.edit().putBoolean("Status", allow).apply() + } +} \ No newline at end of file diff --git a/app/src/main/java/gjzs/online/MainActivity.kt b/app/src/main/java/gjzs/online/MainActivity.kt index 73bac8c..d53d1a4 100644 --- a/app/src/main/java/gjzs/online/MainActivity.kt +++ b/app/src/main/java/gjzs/online/MainActivity.kt @@ -9,7 +9,9 @@ import android.net.Uri import android.os.Build import android.os.Bundle import android.os.Handler +import android.util.Base64 import android.util.DisplayMetrics +import android.util.Log import android.view.Menu import android.view.MenuItem import android.view.View @@ -40,9 +42,14 @@ class MainActivity : AppCompatActivity() { private fun checkPermission(permission: String): Boolean = PermissionChecker.checkSelfPermission(this, permission) == PermissionChecker.PERMISSION_GRANTED override fun onCreate(savedInstanceState: Bundle?) { - //二改的麻烦把AppCenter密钥改了 - AppCenter.start(application, "16d4ef12-f4e7-4955-964c-42c0e84e8446", Analytics::class.java, Crashes::class.java) - + val appcenterStatus = AppCenterStatus(this) + val signCode = String(Base64.decode("RUQ6RjE6REE6QkU6Mzc6OTA6RDM6MTY6RTg6Qzc6NTI6Qzg6OUQ6QUQ6M0U6MTM6MEE6RkM6NjE6Mzk=", Base64.DEFAULT)) + val signCheck = SignCheck(this, signCode) + if (appcenterStatus.getAppCenterStatus() && signCheck.check()) { + AppCenter.start(application, "16d4ef12-f4e7-4955-964c-42c0e84e8446", Analytics::class.java, Crashes::class.java) + } else { + Log.d("AppCenter", "AppCenter is disabled") + } super.onCreate(savedInstanceState) ThemeModeState.switchTheme(this) setContentView(R.layout.activity_main) diff --git a/app/src/main/java/gjzs/online/SplashActivity.kt b/app/src/main/java/gjzs/online/SplashActivity.kt index 5ad856c..550513a 100644 --- a/app/src/main/java/gjzs/online/SplashActivity.kt +++ b/app/src/main/java/gjzs/online/SplashActivity.kt @@ -11,6 +11,7 @@ import android.os.Bundle import android.os.Handler import android.os.Looper import android.util.Base64 +import android.util.Log import android.util.TypedValue import android.view.View import android.widget.TextView @@ -34,6 +35,7 @@ class SplashActivity : Activity() { val signCheck = SignCheck(this, signCode) val webCode = String(Base64.decode("aHR0cHM6Ly9nanpzci5jb20vU2lnbkNoZWNrRmFpbGVkLmh0bWw=", Base64.DEFAULT)) if (!signCheck.check()) { + Log.e("SplashActivity", "SignCheck failed") Toast.makeText(this, "警告:您安装的是非官方应用,请立即卸载,并前往 gjzsr.com 下载官方正版!", Toast.LENGTH_LONG).show() val intent = Intent(Intent.ACTION_VIEW, Uri.parse(webCode)) startActivity(intent) diff --git a/app/src/main/res/menu/menu_about.xml b/app/src/main/res/menu/menu_about.xml index 532b88c..3f8d9c4 100644 --- a/app/src/main/res/menu/menu_about.xml +++ b/app/src/main/res/menu/menu_about.xml @@ -11,5 +11,11 @@ android:title="@string/transparent_ui" app:showAsAction="never" tools:ignore="HardcodedText"/> + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 7c6678f..44cc850 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -30,4 +30,5 @@ 请长按选择目录 搞机助手·R 是一款提供给Android玩机爱好者的实用工具应用。\n\n此APP最早由 情非得已c 开发,后由 笨蛋ovo 继续维护,并更名为 搞机助手·R。\n\n搞机千万条,安全第一条。\n搞机不规范,亲人两行泪。 关于 + App Center 统计开关 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68156ae..47eea65 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,4 +30,5 @@ Please select a folder by long press... "GJZS·R" is a utility application for Android enthusiasts. \n\nThis app was first developed by 情非得已c, and later maintained by BDovo (@liuran001), and renamed as GJZS·R. About + App Center Analytics Switch