From fb3ee3d76db0e83ba6dfd3bf22b57224c3f77e6b Mon Sep 17 00:00:00 2001 From: Syuugo Date: Wed, 28 Feb 2024 15:10:40 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B5=B1=E5=90=88=E6=BA=96=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 1 + .github/workflows/build.yml | 27 +-- .gitignore | 6 +- CT3/build.gradle | 41 +++++ CT3/src/main/AndroidManifest.xml | 39 ++++ .../touch/support/DchaStateChanger.java | 28 +++ .../touch/support/DevelopmentOptions.java | 38 ++++ .../ic_settings_development_alpha.png | Bin 0 -> 425 bytes CTX/build.gradle | 42 +++++ CTX/src/main/AndroidManifest.xml | 35 ++++ .../touch/support/DchaStateChanger.java | 18 ++ .../touch/support/DevelopmentOptions.java | 28 +++ .../ic_settings_development_alpha.png | Bin app/build.gradle | 14 +- app/proguard-rules.pro | 3 +- app/src/main/AndroidManifest.xml | 170 +----------------- app/src/main/assets/ALL.apk | 0 app/src/main/assets/CT3.apk | 0 app/src/main/assets/CTX.apk | 0 app/src/main/assets/base.apk | Bin 5163 -> 0 bytes .../setuplogin/BootCompletedReceiver.java | 21 --- .../touch/setuplogin/BypassActivity.java | 93 ---------- .../touch/setuplogin/BypassService.java | 24 --- .../touch/setuplogin/DchaCopyFile.java | 75 -------- .../touch/setuplogin/DchaInstallApp.java | 78 -------- .../touch/setuplogin/DchaStateChanger.java | 18 -- .../touch/setuplogin/DchaStateChanger3.java | 26 --- .../touch/setuplogin/DchaStateReceiver.java | 22 --- .../touch/setuplogin/DevelopmentOptions.java | 26 --- .../touch/setuplogin/DevelopmentOptions3.java | 44 ----- .../touch/setuplogin/DeviceAdminReceiver.java | 4 - .../touch/setuplogin/DynamicReceiver.java | 26 --- .../setuplogin/LoginSettingActivity.java | 144 ++++++--------- .../touch/setuplogin/PackageReceiver.java | 44 ----- .../touch/setuplogin/PlayUpgradeActivity.java | 84 --------- .../touch/setuplogin/RebootActivity.java | 4 - app/src/main/res/layout/copyfile.xml | 48 ----- app/src/main/res/layout/installapp.xml | 49 ----- app/src/main/res/xml/device_admin.xml | 1 - docs/HowTo.md | 70 +++----- docs/README.md | 19 +- docs/test_environment_info.xml | 4 +- gradle.properties | 3 + settings.gradle | 2 +- 44 files changed, 373 insertions(+), 1046 deletions(-) create mode 100644 CT3/build.gradle create mode 100644 CT3/src/main/AndroidManifest.xml create mode 100644 CT3/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java create mode 100644 CT3/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java create mode 100644 CT3/src/main/res/drawable-mdpi-v4/ic_settings_development_alpha.png create mode 100644 CTX/build.gradle create mode 100644 CTX/src/main/AndroidManifest.xml create mode 100644 CTX/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java create mode 100644 CTX/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java rename {app/src/main/res/drawable-hdpi => CTX/src/main/res/drawable-hdpi-v4}/ic_settings_development_alpha.png (100%) create mode 100644 app/src/main/assets/ALL.apk create mode 100644 app/src/main/assets/CT3.apk create mode 100644 app/src/main/assets/CTX.apk delete mode 100644 app/src/main/assets/base.apk delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/BootCompletedReceiver.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/BypassActivity.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/BypassService.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DchaCopyFile.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DchaInstallApp.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger3.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateReceiver.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions3.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DeviceAdminReceiver.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/DynamicReceiver.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/PackageReceiver.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/PlayUpgradeActivity.java delete mode 100644 app/src/main/java/jp/co/benesse/touch/setuplogin/RebootActivity.java delete mode 100644 app/src/main/res/layout/copyfile.xml delete mode 100644 app/src/main/res/layout/installapp.xml delete mode 100644 app/src/main/res/xml/device_admin.xml create mode 100644 gradle.properties diff --git a/.gitattributes b/.gitattributes index 7a87507..c7706b3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,4 @@ *.apk binary *.jar binary *.png binary +*.jks \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33f20df..e30ce56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,12 +8,6 @@ on: - 'gradle/**' - '*.gradle' workflow_dispatch: - inputs: - release: - description: 'Release' - type: boolean - required: true - default: false jobs: build: @@ -42,7 +36,11 @@ jobs: - name: Build with Gradle run: | - ./gradlew aR --no-daemon + ./gradlew :CT3:asD + ./gradlew :CTX:asD + cp -f CT3/build/outputs/apk/debug/app-debug.apk app/src/main/assets/CT3.apk + cp -f CTX/build/outputs/apk/debug/app-debug.apk app/src/main/assets/CTX.apk + ./gradlew :app:asD { echo "repo=$(echo ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/})" echo "version=v$(grep versionName app/build.gradle | awk '{print $2}' | tr -d \")" @@ -53,17 +51,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ env.repo }}(${{ env.version }}@${{ env.commit }}) - path: app/build/outputs/apk/release/app-release.apk - - - name: Release - uses: softprops/action-gh-release@v1 - if: github.event.inputs.release == 'true' - with: - tag_name: ${{ env.version }} - draft: true - prerelease: false - files: app/build/outputs/apk/release/app-release.apk - - - name: Push APK - if: github.event.inputs.release == 'true' - run: curl -sT app/build/outputs/apk/release/app-release.apk -u ${{ secrets.FTP_USER }}:${{ secrets.FTP_PASSWORD }} ftp://${{ secrets.FTP_HOST }}${{ secrets.FTP_PATH }} + path: app/build/outputs/apk/debug/app-debug.apk \ No newline at end of file diff --git a/.gitignore b/.gitignore index f55202b..45747bd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,9 @@ # IntelliJ /.idea/ # Gradle Build +/build/ /app/build/ +/CT?/build/ # Android Studio Signing APK -/app/debug/ /app/release/ -# jadx -/app/libs/*.jar.cache/ \ No newline at end of file +/CT?/release/ \ No newline at end of file diff --git a/CT3/build.gradle b/CT3/build.gradle new file mode 100644 index 0000000..a07d09f --- /dev/null +++ b/CT3/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'me.s1204.benesse.touch.support' + compileSdk 34 + + defaultConfig { + minSdk 24 + //noinspection ExpiredTargetSdkVersion + targetSdk 22 + versionCode 1 + versionName "1.0.0" + proguardFiles += '../app/proguard-rules.pro' + } + + signingConfigs { + android { + storeFile file('../app/android.jks') + storePassword 'android' + keyAlias 'android' + keyPassword 'android' + } + } + + buildTypes { + debug { + signingConfig signingConfigs.android + minifyEnabled false + } + release { + minifyEnabled true + shrinkResources true + } + } +} + +dependencies { + compileOnly files('../app/libs/BenesseExtension.jar') +} \ No newline at end of file diff --git a/CT3/src/main/AndroidManifest.xml b/CT3/src/main/AndroidManifest.xml new file mode 100644 index 0000000..693d35d --- /dev/null +++ b/CT3/src/main/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CT3/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java b/CT3/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java new file mode 100644 index 0000000..7423e99 --- /dev/null +++ b/CT3/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java @@ -0,0 +1,28 @@ +package me.s1204.benesse.touch.support; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.BenesseExtension; +import android.os.Bundle; +import android.provider.Settings; + +public class DchaStateChanger extends Activity { + private void setDchaState(int value) { + Settings.System.putInt(getContentResolver(), "dcha_state", value); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + finishAndRemoveTask(); + if (Settings.System.canWrite(this)) { + if (BenesseExtension.getDchaState() == 3) { + setDchaState(0); + } else { + setDchaState(3); + } + } else { + startActivity(new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, Uri.parse("package:" + getPackageName())).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); + } + } +} diff --git a/CT3/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java b/CT3/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java new file mode 100644 index 0000000..2286bbb --- /dev/null +++ b/CT3/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java @@ -0,0 +1,38 @@ +package me.s1204.benesse.touch.support; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.provider.Settings; + +public class DevelopmentOptions extends Activity { + private boolean getEnabled(String variable) throws Settings.SettingNotFoundException { + return Settings.Global.getInt(getContentResolver(), variable) == 1; + } + private void setDchaState(int value) { + Settings.System.putInt(getContentResolver(), "dcha_state", value); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Intent intent; + finishAndRemoveTask(); + if (Settings.System.canWrite(this)) { + setDchaState(3); + intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); + try { + if (getEnabled(Settings.Global.ADB_ENABLED) && getEnabled(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED)) { + new Handler(Looper.getMainLooper()).postDelayed(() -> setDchaState(0), 1000); + } + } catch (Settings.SettingNotFoundException ignored) { + } + } else { + intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, Uri.parse("package:" + getPackageName())).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + } + startActivity(intent); + } +} diff --git a/CT3/src/main/res/drawable-mdpi-v4/ic_settings_development_alpha.png b/CT3/src/main/res/drawable-mdpi-v4/ic_settings_development_alpha.png new file mode 100644 index 0000000000000000000000000000000000000000..01bc25c8ba5cc26e63617ca5dcc32324f91b4adf GIT binary patch literal 425 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaAqghgnPbqH%ui z#MgXH20X3j!x%-|mHZsuUHV?{rk-r!>v1L3{#M=IIi&~YyL)V6^L%(b^QdA@lYm;N z0*{%#l0a@HJ7;nEp56z$Jl|Muo9A%mcls$FCc7JKEzIn40dp)SY=}A_sJ{PE3X@+* z)j63H=U(b~KUnm$>yFyf9h>&~cyY8|S}N?Xu~jS0|IxGaJ1P%P<-cMSBNaN8d1~O- zqs-ZPYJ1&s4}WFi$UVL{HtBrq? + + + + + + + + + + + + + + + + + + + + + diff --git a/CTX/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java b/CTX/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java new file mode 100644 index 0000000..aed5432 --- /dev/null +++ b/CTX/src/main/java/me/s1204/benesse/touch/support/DchaStateChanger.java @@ -0,0 +1,18 @@ +package me.s1204.benesse.touch.support; + +import android.app.Activity; +import android.os.BenesseExtension; +import android.os.Bundle; + +public class DchaStateChanger extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + finishAndRemoveTask(); + if (BenesseExtension.getDchaState() == 3) { + BenesseExtension.setDchaState(0); + } else { + BenesseExtension.setDchaState(3); + } + } +} diff --git a/CTX/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java b/CTX/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java new file mode 100644 index 0000000..994cdfd --- /dev/null +++ b/CTX/src/main/java/me/s1204/benesse/touch/support/DevelopmentOptions.java @@ -0,0 +1,28 @@ +package me.s1204.benesse.touch.support; + +import android.app.Activity; +import android.content.Intent; +import android.os.BenesseExtension; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.provider.Settings; + +public class DevelopmentOptions extends Activity { + private boolean getEnabled(String variable) throws Settings.SettingNotFoundException { + return Settings.Global.getInt(getContentResolver(), variable) == 1; + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + BenesseExtension.setDchaState(3); + finishAndRemoveTask(); + startActivity(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS)); + try { + if (getEnabled(Settings.Global.ADB_ENABLED) && getEnabled(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED)) { + new Handler(Looper.getMainLooper()).postDelayed(() -> BenesseExtension.setDchaState(0), 1000); + } + } catch (Settings.SettingNotFoundException ignored) { + } + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_settings_development_alpha.png b/CTX/src/main/res/drawable-hdpi-v4/ic_settings_development_alpha.png similarity index 100% rename from app/src/main/res/drawable-hdpi/ic_settings_development_alpha.png rename to CTX/src/main/res/drawable-hdpi-v4/ic_settings_development_alpha.png diff --git a/app/build.gradle b/app/build.gradle index 34f4978..623fd73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,8 @@ android { //noinspection ExpiredTargetSdkVersion targetSdk 22 versionCode 10 - versionName "3.1.0" + versionName "4.0.0" + proguardFiles += 'proguard-rules.pro' } signingConfigs { @@ -26,22 +27,13 @@ android { buildTypes { debug { signingConfig signingConfigs.android - minifyEnabled true - shrinkResources true - proguardFiles += 'proguard-rules.pro' + minifyEnabled false } release { - signingConfig signingConfigs.android minifyEnabled true shrinkResources true - proguardFiles += 'proguard-rules.pro' } } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } } dependencies { diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index e7d8d7e..d37199d 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,2 +1 @@ --keep class jp.co.benesse.dcha.dchaservice.IDchaService --keep class jp.co.benesse.touch.setuplogin.** \ No newline at end of file +-keep class jp.co.benesse.dcha.dchaservice.IDchaService \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0302589..cf8adad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ @@ -19,179 +19,13 @@ android:alwaysRetainTaskState="true" android:clearTaskOnLaunch="true" android:exported="true" - android:screenOrientation="landscape" - android:label="Nova Direct Installer"> + android:screenOrientation="landscape"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/assets/ALL.apk b/app/src/main/assets/ALL.apk new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/assets/CT3.apk b/app/src/main/assets/CT3.apk new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/assets/CTX.apk b/app/src/main/assets/CTX.apk new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/assets/base.apk b/app/src/main/assets/base.apk deleted file mode 100644 index 88993168add7366f6de31e00d306d9fa03384061..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5163 zcmWIWW@cdk0uBa64n?NVY@YVJ85tN7fMUWxQOCTLqWsJh-^9GkwAA7fy^7qNsgpMP zNjr+TzJGITgQ1y3w~~g*#1#_^7L;guw(Cf#WbyPJEXoPn&ArG+^dsZS06WF_3F{a7 zxq7mvAKP3Jc~j`ki>k7B)$jLNpO@CUq4%=+N@u5MD9f=h|4q>{^0%B$o_$Y zNqKFf*$>ut2jUCzD@(*n7p@Dcy}Y#Qm!GS%GVcYeM>basW1MOn?!3}}`AgJzZMK%P z=0(fpIeuTYo=Y#{oSFWn{f%Vc>YIu7s@K!zPP7l=`P_UWXYE(>l&9~GeUY@B-uUfH zt8Ggrvvs51N4e1HAz$yv?p|?h1>Xz9LW`F>k8UvvTeJRF;?g7f7i4!zZu9oaeP3|= zCGSn)qTuqnyM{$v$$qudCtAjDoPBA+{o?0;7k^Iq`(>riiksJ`?yk*0xA%T<@eiZL z9X(fm-e4yi!Qjl(N0wFS4DDBSGV~=i4v`K;xPL z9M=nv2<>bD#x)4@0pq$TwK%`DC^@xQFR`dNnTdf1ECZBeU}TU1LL>kbg!7pc7$boE zdZ2V7gB}o%T%Z67EFiFf(jYcQ*a5|0VTU0H)CZIM!4J~Sz+l1-p{3e63w3~O4Iq94 z%$+(wVGST=2I^4&(zEPyuRSr!n6cL;7UP)qRoK z71H}R8EmaM#Nxcqr$}Ol+gC-=whtBy{W=frv#9UecfSAB;ahT#4NktAd|~;)y`|rOuC1e6V$p@Z3N?i(_A`rWZCL&l&6J&afA%_y1)Id{7t2Ox{d+0T#K^q3@sB~{ zPXk$C!ja`;5n~bYh-3(}Ro8J_C)mciq(pKJ=cyh+gT|8}d1aQyg9eTJ8nCKa*f?uR z>Nco3Ykw2=iOb$!mv-%Rfog-P~EnLb!+DClh9G{ z+ZZhPCG>{Mwy@hz?kG7-)GclM*D+O=amBx_>!O?zf@6P}7_zD;x%HSm($R|hIpvz{ zb%U%YC%;XVUVKnrR#N2dF?p$^Te?5gzcK$?nqaLH!n?PIagN!pO|zT|4~pLpvblZq zb7Pg~gZImL_STn(*H!sT+B$zxVlPU|^YLwdxHqbeqvo@}?i=@EFFx8nF-eO>e9FNqqzy#8*II66IOz5Ibq zQCTHZPG<|fQ}K#j72LQ!{vh+YoqrYyvu_qY>5wtAD=ER3$Iw<~)o=4G{eTkrkjFC5 zenxw;?zZdR%a(aEFjuK9YVr%ouQB~|w&xZuU2nZf$*o;x+u}fm8yumE@h=+F{hgw& zLScusuU+1IlkF*!Q;=P)Z__`|Y5q@N&&u$xoFR9rTOr~q>x1{Y z8F5|jjhkiHANryK3weU{wGXZ-%pX2+X#e0t%hcWbramuBO@%Tw?A22Wq` z@9g)S3Z?Uxr1BpH_%mi6GcG(){wPW@BKR8n%LK`@KYfa}x{A*))R7E-BhLY`y*#zZ z3F?kfYBU5!Ltr!nMnhmU1V%$(Gz35)0PE*F26!t3XQnGS<>V)4E0`Dscr!9VLJ0fF p9BSxc8K*-SfPJ_JVZa+;a}ss%C%~JP4J6M5gtb6=252mh0RS_V3e^Ar diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/BootCompletedReceiver.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/BootCompletedReceiver.java deleted file mode 100644 index 4be3e75..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/BootCompletedReceiver.java +++ /dev/null @@ -1,21 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.os.BenesseExtension; -import android.provider.Settings; - -import java.util.Objects; - -public class BootCompletedReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_BOOT_COMPLETED)) { - BenesseExtension.setDchaState(0); - Settings.System.putInt(context.getContentResolver(), "hide_navigation_bar", 0); - context.startService(new Intent(context, BypassService.class)); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/BypassActivity.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/BypassActivity.java deleted file mode 100644 index 45aaff0..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/BypassActivity.java +++ /dev/null @@ -1,93 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -/* - Based by: Kobold831/BypassRevokePermission - */ - -import android.app.Activity; -import android.app.ActivityManager; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.BenesseExtension; -import android.os.Bundle; -import android.os.Handler; -import android.os.IBinder; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import jp.co.benesse.dcha.dchaservice.IDchaService; - -public class BypassActivity extends Activity { - - private static final String BASE_APK = "base.apk"; - - @Override - public void onCreate(Bundle bundle) { - super.onCreate(bundle); - run(this); - finishAndRemoveTask(); - } - - @Deprecated - public static void run(final Context context) { - BenesseExtension.setDchaState(3); - copyAssetsFile(context); - context.bindService(new Intent(LoginSettingActivity.DCHA_SERVICE).setPackage(LoginSettingActivity.DCHA_PACKAGE), new ServiceConnection() { - @Override - public void onServiceConnected(ComponentName componentName, IBinder iBinder) { - IDchaService mDchaService = IDchaService.Stub.asInterface(iBinder); - try { - mDchaService.hideNavigationBar(false); - mDchaService.installApp(context.getExternalFilesDir("") + "/" + BASE_APK, 2); - mDchaService.uninstallApp("a.a", 1); - } catch (Exception ignored) { - } - context.unbindService(this); - } - - @Override - public void onServiceDisconnected(ComponentName componentName) { - } - }, Context.BIND_AUTO_CREATE); - - Runnable runnable = () -> BenesseExtension.setDchaState(0); - new Handler().postDelayed(runnable, 800); - - if (!isActiveBypassService(context)) { - context.startService(new Intent(context, BypassService.class)); - } - } - - public static void copyAssetsFile(Context context) { - try { - if (new File(context.getExternalFilesDir("") + "/" + BASE_APK).exists()) { - return; - } - InputStream inputStream = context.getAssets().open(BASE_APK); - FileOutputStream fileOutputStream = new FileOutputStream(context.getExternalFilesDir("") + "/" + BASE_APK, false); - byte[] buffer = new byte[1024]; - int length; - while ((length = inputStream.read(buffer)) >= 0) { - fileOutputStream.write(buffer, 0, length); - } - fileOutputStream.close(); - inputStream.close(); - } catch (IOException ignored) { - } - } - - @Deprecated - public static boolean isActiveBypassService(Context context) { - for (ActivityManager.RunningServiceInfo serviceInfo : ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getRunningServices(Integer.MAX_VALUE)) { - if (BypassService.class.getName().equals(serviceInfo.service.getClassName())) { - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/BypassService.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/BypassService.java deleted file mode 100644 index a45e765..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/BypassService.java +++ /dev/null @@ -1,24 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - - -import android.app.Service; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.IBinder; - -public class BypassService extends Service { - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(Intent.ACTION_SHUTDOWN); - intentFilter.addAction(Intent.ACTION_SCREEN_ON); - registerReceiver(new DynamicReceiver(), intentFilter); - return START_STICKY; - } -} \ No newline at end of file diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaCopyFile.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaCopyFile.java deleted file mode 100644 index 2e5552e..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaCopyFile.java +++ /dev/null @@ -1,75 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import static android.content.pm.PackageManager.*; - -import android.app.Activity; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; -import android.view.View; -import android.widget.EditText; -import android.widget.Toast; - -import jp.co.benesse.dcha.dchaservice.IDchaService; - -public class DchaCopyFile extends Activity { - IDchaService mDchaService; - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.copyfile); - - // DchaService をバインド - if (bindService(new Intent("jp.co.benesse.dcha.dchaservice.DchaService").setPackage("jp.co.benesse.dcha.dchaservice"), new ServiceConnection() { - @Override - public void onServiceConnected(ComponentName componentName, IBinder iBinder) { - mDchaService = IDchaService.Stub.asInterface(iBinder); - } - @Override - public void onServiceDisconnected(ComponentName componentName) { - unbindService(this); - Toast.makeText(getApplicationContext(), "DchaService から切断されました", Toast.LENGTH_LONG).show(); - finishAndRemoveTask(); - } - }, Context.BIND_AUTO_CREATE)) { - - // copyFile(from, to) - findViewById(R.id.exec).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - EditText fromBox = findViewById(R.id.copyFile_from); - EditText toBox = findViewById(R.id.copyFile_to); - String fromPath = fromBox.getText().toString(); - String toPath = toBox.getText().toString(); - if (!fromPath.startsWith("/") || !toPath.startsWith("/")) { - Toast.makeText(getApplicationContext(), "フルパスで入力してください", Toast.LENGTH_SHORT).show(); - return; - } - if (fromPath.endsWith("/") || toPath.endsWith("/")) { - Toast.makeText(getApplicationContext(), "ファイルを指定してください", Toast.LENGTH_SHORT).show(); - return; - } - try { - String result = String.valueOf(mDchaService.copyFile(fromPath, toPath)); - Toast.makeText(getApplicationContext(), "実行結果:" + result, Toast.LENGTH_LONG).show(); - } catch (RemoteException ignored) { - } - } - }); - } else { - Toast.makeText(this, "DchaService をバインド出来ませんでした\nアクティビティを無効化します", Toast.LENGTH_LONG).show(); - getPackageManager().setComponentEnabledSetting(new ComponentName(this, DchaCopyFile.class), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP); - finishAndRemoveTask(); - } - } - - @Deprecated - @Override - public void onBackPressed() { - finish(); - } -} diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaInstallApp.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaInstallApp.java deleted file mode 100644 index d2f7b3d..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaInstallApp.java +++ /dev/null @@ -1,78 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import static android.content.pm.PackageManager.*; - -import android.app.Activity; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; -import android.view.View; -import android.widget.EditText; -import android.widget.Toast; - -import jp.co.benesse.dcha.dchaservice.IDchaService; - -public class DchaInstallApp extends Activity { - IDchaService mDchaService; - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.installapp); - - // DchaService をバインド - if (bindService(new Intent("jp.co.benesse.dcha.dchaservice.DchaService").setPackage("jp.co.benesse.dcha.dchaservice"), new ServiceConnection() { - @Override - public void onServiceConnected(ComponentName componentName, IBinder iBinder) { - mDchaService = IDchaService.Stub.asInterface(iBinder); - } - @Override - public void onServiceDisconnected(ComponentName componentName) { - unbindService(this); - Toast.makeText(getApplicationContext(), "DchaService から切断されました", Toast.LENGTH_LONG).show(); - finishAndRemoveTask(); - } - }, Context.BIND_AUTO_CREATE)) { - - // installApp(file) - findViewById(R.id.exec).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - EditText fileBox = findViewById(R.id.installApp_packagePath); - EditText flagBox = findViewById(R.id.installApp_flag); - String filePath = fileBox.getText().toString(); - String flag = flagBox.getText().toString(); - if (!filePath.startsWith("/")) { - Toast.makeText(getApplicationContext(), "フルパスで入力してください", Toast.LENGTH_SHORT).show(); - return; - } - if (!filePath.endsWith(".apk")) { - Toast.makeText(getApplicationContext(), "APKファイルを指定してください", Toast.LENGTH_SHORT).show(); - return; - } - if (flag.equals("")) { - flag = "2"; - } - try { - String result = String.valueOf(mDchaService.installApp(filePath, Integer.parseInt(flag))); - Toast.makeText(getApplicationContext(), "実行結果:" + result, Toast.LENGTH_LONG).show(); - } catch (RemoteException ignored) { - } - } - }); - } else { - Toast.makeText(this, "DchaService をバインド出来ませんでした\nアクティビティを無効化します", Toast.LENGTH_LONG).show(); - getPackageManager().setComponentEnabledSetting(new ComponentName(this, DchaInstallApp.class), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP); - finishAndRemoveTask(); - } - } - - @Deprecated - @Override - public void onBackPressed() { - finish(); - } -} diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger.java deleted file mode 100644 index 3bff80f..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger.java +++ /dev/null @@ -1,18 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import android.app.Activity; -import android.os.Bundle; - -import static android.os.BenesseExtension.*; - -public class DchaStateChanger extends Activity { - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - finishAndRemoveTask(); - if (getDchaState() == 3) { - setDchaState(0); - } else { - setDchaState(3); - } - } -} diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger3.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger3.java deleted file mode 100644 index 69aceb8..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateChanger3.java +++ /dev/null @@ -1,26 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; - -import static android.net.Uri.parse; -import static android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS; -import static android.provider.Settings.System.*; - -public class DchaStateChanger3 extends Activity { - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - final String DCHA_STATE = "dcha_state"; - finishAndRemoveTask(); - if (canWrite(this)) { - if (getInt(getContentResolver(), DCHA_STATE, 0) == 3) { - putInt(getContentResolver(), DCHA_STATE, 0); - } else { - putInt(getContentResolver(), DCHA_STATE, 3); - } - } else { - startActivity(new Intent(ACTION_MANAGE_WRITE_SETTINGS, parse("package:" + getPackageName())).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); - } - } -} diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateReceiver.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateReceiver.java deleted file mode 100644 index 45b4a49..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DchaStateReceiver.java +++ /dev/null @@ -1,22 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import android.annotation.SuppressLint; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import static android.os.BenesseExtension.setDchaState; -import static android.provider.Settings.System.canWrite; -import static android.provider.Settings.System.putInt; - -public class DchaStateReceiver extends BroadcastReceiver { - @SuppressLint("UnsafeProtectedBroadcastReceiver") - public void onReceive(Context c, Intent i) { - setDchaState(3); - if (canWrite(c)) { - // ナビバーを表示 - putInt(c.getContentResolver(), "hide_navigation_bar", 0); - // スクリーンショットを有効化 - putInt(c.getContentResolver(), "allow_screen_shot", 1); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions.java deleted file mode 100644 index 395ea4b..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions.java +++ /dev/null @@ -1,26 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; - -import static android.os.BenesseExtension.setDchaState; -import static android.provider.Settings.*; -import static android.provider.Settings.Global.*; - -public class DevelopmentOptions extends Activity { - @Deprecated - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setDchaState(3); - finishAndRemoveTask(); - startActivity(new Intent(ACTION_APPLICATION_DEVELOPMENT_SETTINGS)); - try { - if ((getInt(getContentResolver(), ADB_ENABLED) == 1) && (getInt(getContentResolver(), DEVELOPMENT_SETTINGS_ENABLED) == 1)) { - new Handler().postDelayed(() -> setDchaState(0), 1000); - } - } catch (SettingNotFoundException ignored) { - } - } -} diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions3.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions3.java deleted file mode 100644 index ee7305b..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DevelopmentOptions3.java +++ /dev/null @@ -1,44 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Intent; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.provider.Settings; -import android.provider.Settings.System; -import static android.net.Uri.parse; -import static android.provider.Settings.Global.*; - -public class DevelopmentOptions3 extends Activity { - - @Deprecated - @Override - public void onBackPressed() { - finish(); - } - - @TargetApi(Build.VERSION_CODES.M) - @Deprecated - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - final String DCHA_STATE = "dcha_state"; - Intent intent; - finishAndRemoveTask(); - if (System.canWrite(this)) { - System.putInt(getContentResolver(), DCHA_STATE, 3); - intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); - try { - if ((getInt(getContentResolver(), ADB_ENABLED) == 1) && (getInt(getContentResolver(), DEVELOPMENT_SETTINGS_ENABLED) == 1)) { - new Handler().postDelayed(() -> System.putInt(getContentResolver(), DCHA_STATE, 0), 1000); - } - } catch (Settings.SettingNotFoundException ignored) { - } - } else { - intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, parse("package:" + getPackageName())).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - } - startActivity(intent); - } -} diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DeviceAdminReceiver.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DeviceAdminReceiver.java deleted file mode 100644 index 6bbe977..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DeviceAdminReceiver.java +++ /dev/null @@ -1,4 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -public class DeviceAdminReceiver extends android.app.admin.DeviceAdminReceiver { -} \ No newline at end of file diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/DynamicReceiver.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/DynamicReceiver.java deleted file mode 100644 index 1048d3c..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/DynamicReceiver.java +++ /dev/null @@ -1,26 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import static jp.co.benesse.touch.setuplogin.BypassActivity.isActiveBypassService; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.os.BenesseExtension; - -import java.util.Objects; - -public class DynamicReceiver extends BroadcastReceiver { - @Deprecated - @Override - public void onReceive(Context context, Intent intent) { - if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_SHUTDOWN)) { - BenesseExtension.setDchaState(3); - } - - if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_SCREEN_ON)) { - if (!isActiveBypassService(context)) { - context.startService(new Intent(context, BypassService.class)); - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/LoginSettingActivity.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/LoginSettingActivity.java index 148e553..1325715 100644 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/LoginSettingActivity.java +++ b/app/src/main/java/jp/co/benesse/touch/setuplogin/LoginSettingActivity.java @@ -4,78 +4,73 @@ import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; +import android.provider.Settings; -import static android.content.pm.PackageManager.*; -import static android.os.Build.MODEL; -import static android.provider.Settings.System.putInt; - -import java.io.File; -import java.util.Arrays; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import jp.co.benesse.dcha.dchaservice.IDchaService; public class LoginSettingActivity extends Activity { - public static final String DCHA_PACKAGE = "jp.co.benesse.dcha.dchaservice"; - public static final String DCHA_SERVICE = DCHA_PACKAGE + ".DchaService"; + private static final String DCHA_PACKAGE = "jp.co.benesse.dcha.dchaservice"; + private static final String DCHA_SERVICE = DCHA_PACKAGE + ".DchaService"; + private static final String CT2S = "TAB-A03-BS"; + private static final String CT2K = "TAB-A03-BR"; + private static final String CT2L = "TAB-A03-BR2"; + private static final String CT3 = "TAB-A03-BR3"; + private static final String CTX = "TAB-A05-BD"; + private static final String CTZ = "TAB-A05-BA1"; + private static final String APK_EXT = ".apk"; IDchaService mDchaService; - public void ofDisable(Class cls) { - getPackageManager().setComponentEnabledSetting(new ComponentName(this, cls), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP); - } - public void ofEnable(Class cls) { - getPackageManager().setComponentEnabledSetting(new ComponentName(this, cls), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP); + // Based by Kobold831 + private String copyAssetsFile(String model) throws IOException{ + final String ASSET_APK = model + APK_EXT; + final String APK_PATH = getApplicationContext().getFilesDir().getPath() + "/" + ASSET_APK; + InputStream inputStream = getApplicationContext().getAssets().open(ASSET_APK); + FileOutputStream fileOutputStream = new FileOutputStream(APK_PATH, false); + byte[] buffer = new byte[1024]; + int length; + while ((length = inputStream.read(buffer)) >= 0) { + fileOutputStream.write(buffer, 0, length); + } + fileOutputStream.close(); + inputStream.close(); + return APK_PATH; } - public void onCreate(Bundle savedInstanceState) { + @Override + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + final String CT_MODEL = Build.MODEL; final String BC_PASSWORD_HIT_FLAG = "bc_password_hit"; final int PASSWORD_FLAG = 1; final int UNDIGICHALIZE = 0; final int DIGICHALIZING_DL_COMPLETE = 2; final int DIGICHALIZED = 3; final int INSTALL_FLAG = 2; + final int UNINSTALL_FLAG = 1; final int REBOOT_DEVICE = 0; + final String DSW_PACKAGE = "jp.co.benesse.dcha.setupwizard"; final String DSS_PACKAGE = "jp.co.benesse.dcha.systemsettings"; final String DSS_ACTIVITY = DSS_PACKAGE + ".TabletInfoSettingActivity"; final String LAUNCHER3 = "com.android.launcher3"; - final String NOVA_PACKAGE = "com.teslacoilsw.launcher"; - final String LOCAL_PATH = "/storage/emulated/0/Download/"; - final String SD_PATH = "/storage/sdcard1/APK/"; - final String SD_PATH_GAPPS = SD_PATH + "GApps"; - final String SD_PATH_GAPPS2 = SD_PATH + "GApps2"; - final String CT2S = "TAB-A03-BS"; - final String CT2K = "TAB-A03-BR"; - final String CT2L = "TAB-A03-BR2"; - final String CT3 = "TAB-A03-BR3"; - final String CTX = "TAB-A05-BD"; - final String CTZ = "TAB-A05-BA1"; - // SDカードのルートに NovaLauncher のAPKを置く(CT2/3とCTX/Zで分ける) - final String NOVA6_SD_PATH = SD_PATH + "NovaLauncher_6.2.19.apk"; - final String NOVA7_SD_PATH = SD_PATH + "NovaLauncher_7.0.58.apk"; - final String NOVA_LOCAL_PATH = LOCAL_PATH + "NovaLauncher.apk"; - // Googleサービス - // CTZ - final String[] GApps = { - "GoogleServicesFramework", - "GmsCore", - "Phonesky" - }; - // CT2 - final String[] GApps2 = { - "GoogleLoginService" + Arrays.toString(GApps) - }; - final String APK_EXT = ".apk"; + final String CUSTOMIZE_TOOL = "com.saradabar.cpadcustomizetool"; + final String KOBOLD_STORE = "com.saradabar.vending"; - // DchaSystemSettings を呼び出し (外部なら何でも良い) + // DchaSystemSettings を呼び出し startActivity(new Intent().setClassName(DSS_PACKAGE, DSS_ACTIVITY)); + // (ループ)プログレスバー実装 // // 再起動時にADBの状態を保持する - putInt(getContentResolver(), BC_PASSWORD_HIT_FLAG, PASSWORD_FLAG); + Settings.System.putInt(getContentResolver(), BC_PASSWORD_HIT_FLAG, PASSWORD_FLAG); // DchaService をバインド bindService(new Intent(DCHA_SERVICE).setPackage(DCHA_PACKAGE), new ServiceConnection() { @@ -84,63 +79,30 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) { mDchaService = IDchaService.Stub.asInterface(iBinder); try { // DchaState を変更 - mDchaService.setSetupStatus(DIGICHALIZING_DL_COMPLETE); + mDchaService.setSetupStatus(UNDIGICHALIZE); // ナビゲーションバーを表示 mDchaService.hideNavigationBar(false); - // CT3 のみ直接インストール - if (MODEL.equals(CT3)) { - // アクティビティを無効化 - ofDisable(DchaStateChanger.class); - ofDisable(DevelopmentOptions.class); - ofDisable(DeviceAdminReceiver.class); - // 有効化 - ofEnable(DchaStateChanger3.class); - ofEnable(DevelopmentOptions3.class); - // APKをインストール - mDchaService.installApp(NOVA6_SD_PATH, INSTALL_FLAG); - - // CTX/Z は内部にコピーしてからインストール - } else { - // SDカードからローカルにAPKをコピー - mDchaService.copyFile(NOVA7_SD_PATH, NOVA_LOCAL_PATH); - // APKをインストール - mDchaService.installApp(NOVA_LOCAL_PATH, INSTALL_FLAG); - // コピーしたAPKを削除 - new File(NOVA_LOCAL_PATH).delete(); - - // CTZ は GMS もインストール - if (MODEL.equals(CTZ)) { - // アクティビティを無効化 - ofDisable(DchaCopyFile.class); - ofDisable(DchaInstallApp.class); - ofDisable(DevelopmentOptions.class); - // 有効化 - ofEnable(PlayUpgradeActivity.class); - ofEnable(DchaStateReceiver.class); - // DchaState を 3 にする - mDchaService.setSetupStatus(DIGICHALIZED); - // Googleサービス - for (String pkg : GApps) { - mDchaService.copyFile(SD_PATH_GAPPS + pkg + APK_EXT, LOCAL_PATH + pkg + APK_EXT); - mDchaService.installApp(LOCAL_PATH + pkg + APK_EXT, INSTALL_FLAG); - new File(LOCAL_PATH + pkg + APK_EXT).delete(); - } - } + // インストール部分 // + // CT2はバイパス必須 + //mDchaService.installApp(copyAssetsFile("ALL"), INSTALL_FLAG); + if (CT_MODEL.equals(CT3) && !Build.ID.startsWith("01")) { + mDchaService.installApp(copyAssetsFile("CT3"), INSTALL_FLAG); + } else if (CT_MODEL.equals(CTX) || CT_MODEL.equals(CTZ)) { + mDchaService.installApp(copyAssetsFile("CTX"), INSTALL_FLAG); } + // Launcher3 の関連付けを解除 mDchaService.clearDefaultPreferredApp(LAUNCHER3); // 既定のランチャーを変更 (CTX/Z のみ機能) - mDchaService.setDefaultPreferredHomeApp(NOVA_PACKAGE); - // DchaState を 0 にする - if (!MODEL.equals(CTZ)) { - mDchaService.setSetupStatus(UNDIGICHALIZE); - } - // このアクティビティを無効化 - ofDisable(LoginSettingActivity.class); + mDchaService.setDefaultPreferredHomeApp(KOBOLD_STORE); + // DchaSetupWizard をタスクキル + mDchaService.removeTask(DSW_PACKAGE); // 再起動 mDchaService.rebootPad(REBOOT_DEVICE, null); - } catch (RemoteException ignored) { + // このアプリを削除 + mDchaService.uninstallApp(getPackageName(), UNINSTALL_FLAG); + } catch (RemoteException | IOException ignored) { } unbindService(this); } diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/PackageReceiver.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/PackageReceiver.java deleted file mode 100644 index bc08c20..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/PackageReceiver.java +++ /dev/null @@ -1,44 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import static jp.co.benesse.touch.setuplogin.BypassActivity.isActiveBypassService; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -import java.util.Objects; - -public class PackageReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction()) && !Objects.requireNonNull(intent.getExtras()).getBoolean(Intent.EXTRA_REPLACING)) { - _run(context, intent); - } - - if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { - if (Objects.requireNonNull(intent.getExtras()).getBoolean(Intent.EXTRA_DATA_REMOVED) && intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) { - _run(context, intent); - } - - if (!intent.getExtras().getBoolean(Intent.EXTRA_DATA_REMOVED) && intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) { - _run(context, intent); - } - } - - if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(intent.getAction())) { - _run(context, intent); - } - } - - @Deprecated - private void _run(Context context, Intent intent) { - if (!Objects.requireNonNull(intent.getData()).toString().replace("package:", "").equals("a.a")) { - context.startActivity(new Intent(context, BypassActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); - } - - if (!isActiveBypassService(context)) { - context.startService(new Intent(context, BypassService.class)); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/PlayUpgradeActivity.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/PlayUpgradeActivity.java deleted file mode 100644 index de02d45..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/PlayUpgradeActivity.java +++ /dev/null @@ -1,84 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -import static android.content.pm.PackageManager.*; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ComponentName; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Bundle; -import android.os.PowerManager; -import android.widget.Toast; - -public class PlayUpgradeActivity extends Activity { - private static final String GmsCore = "com.google.android.gms"; - private static final String Phonesky = "com.android.vending"; - private static final int GMS_MIN_VER = 18719037; - private static final int FINSKY_MIN_VER = 82195010; - - public void makeToast(String msg) { - Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); - } - - public void ofDisable(Class cls) { - getPackageManager().setComponentEnabledSetting(new ComponentName(this, cls), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP); - } - public void ofEnable(Class cls) { - getPackageManager().setComponentEnabledSetting(new ComponentName(this, cls), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP); - } - - @Deprecated - @Override - public void onCreate(Bundle bundle) { - super.onCreate(bundle); - Intent intent; - try { - final int GMS_VER = getPackageManager().getPackageInfo(GmsCore, 0).versionCode; - final int FINSKY_VER = getPackageManager().getPackageInfo(Phonesky, 0).versionCode; - if (GMS_VER > GMS_MIN_VER && FINSKY_VER > FINSKY_MIN_VER) { - new AlertDialog.Builder(this) - .setTitle(getApplicationInfo().loadLabel(getPackageManager()).toString()) - .setIcon(getPackageManager().getApplicationIcon(getPackageName())) - .setMessage("BypassRevokePermission を有効にすると大幅に利便性が向上します。\nただし、 Play ストアが正しく動作しなくなる可能性があります。\n\n続行しますか?") - .setPositiveButton("はい", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface d, int s) { - ofEnable(DevelopmentOptions.class); - // Enable BypassRevokePermission - ofEnable(BypassActivity.class); - ofEnable(BypassService.class); - ofEnable(DynamicReceiver.class); - ofEnable(BootCompletedReceiver.class); - ofEnable(PackageReceiver.class); - // Disable - ofDisable(DchaStateReceiver.class); - ofDisable(DchaStateReceiver.class); - // Reboot - ((PowerManager) getSystemService(POWER_SERVICE)).reboot(null); - } - }) - .setNegativeButton("いいえ", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface d, int s) { - finishAndRemoveTask(); - makeToast("キャンセルされました"); - } - }) - .show(); - } else { - finishAndRemoveTask(); - if (GMS_VER <= GMS_MIN_VER) { - makeToast("Play ストアから 「Google Play開発者サービス」 を更新してください"); - // Require Google account - intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + GmsCore)); - } else { - makeToast("設定から[Play ストアのバージョン]をタップして、ストアを更新してください"); - intent = new Intent(Intent.ACTION_MAIN).setPackage(Phonesky); - } - startActivity(intent); - } - } catch (PackageManager.NameNotFoundException ignored) { - } - } -} diff --git a/app/src/main/java/jp/co/benesse/touch/setuplogin/RebootActivity.java b/app/src/main/java/jp/co/benesse/touch/setuplogin/RebootActivity.java deleted file mode 100644 index f170302..0000000 --- a/app/src/main/java/jp/co/benesse/touch/setuplogin/RebootActivity.java +++ /dev/null @@ -1,4 +0,0 @@ -package jp.co.benesse.touch.setuplogin; - -public class RebootActivity { -} diff --git a/app/src/main/res/layout/copyfile.xml b/app/src/main/res/layout/copyfile.xml deleted file mode 100644 index 6f58bbe..0000000 --- a/app/src/main/res/layout/copyfile.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - -