Skip to content

Commit c832e0c

Browse files
committed
更新
1 parent b140577 commit c832e0c

File tree

4 files changed

+49
-43
lines changed

4 files changed

+49
-43
lines changed

app/src/main/java/com/saradabar/easyblu/MainActivity.java

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@
3434

3535
public class MainActivity extends Activity {
3636

37+
private static final String DCHA_PACKAGE = "jp.co.benesse.dcha.dchaservice";
38+
private static final String DCHA_SERVICE = DCHA_PACKAGE + ".DchaService";
39+
private static final String DigichalizedStatus = "dcha_state";
40+
private static final int DIGICHALIZE_STATUS_DIGICHALIZED = 3;
41+
private static final String DCHA_SYSTEM_COPY = "/cache/..";
42+
private static final String SETTINGS_PACKAGE = "com.android.settings";
43+
private static final String SETTINGS_ACTIVITY = SETTINGS_PACKAGE + ".Settings";
44+
private static final String FRP_ORIGIN_PATH = "/dev/block/by-name/frp";
45+
private static final String FRP_FIXING_FILE = "frp.bin";
46+
private static final String FRP_FIXING_PATH = "/sdcard/" + FRP_FIXING_FILE;
47+
private static final String FRP_FIXING_TEMP = "tmp.bin";
48+
private static final String SHRINKER = "shrinker";
49+
private static final String SHRINKER_SUCCESS = "Permissive";
50+
private static final String SHRINKER_BIN_PATH = "/data/data/com.saradabar.easyblu/files/";
51+
3752
DataOutputStream dos;
3853
BufferedReader bufferedReader, bufferedReader1;
3954
StringBuilder stringBuilder;
@@ -50,20 +65,21 @@ protected void onCreate(Bundle savedInstanceState) {
5065
init();
5166
}
5267

68+
@Deprecated
5369
void init() {
5470
new AlertDialog.Builder(this)
5571
.setCancelable(false)
5672
.setTitle("実行しますか?")
5773
.setMessage("続行するには OK を押下してください\n\nキャンセルを押すと Android 設定に遷移します")
5874
.setPositiveButton("OK", (dialog, which) -> {
59-
addText("- 通知:shrinker を実行しました");
75+
addText("- 通知:" + SHRINKER + " を実行しました");
6076
addText("- 警告:デバイスには絶対に触れないでください。処理が終了するまでお待ち下さい。");
6177
addText("- 警告:デバイスが再起動した場合は失敗です。起動後に再度実行してください。");
6278
new Handler().postDelayed(() -> {
6379
String result = shrinker();
64-
if (result.contains("Permissive")) {
80+
if (result.contains(SHRINKER_SUCCESS)) {
6581
addText("- 通知:成功しました。");
66-
addText("- 通知:frp.bin の修正を試みます。");
82+
addText("- 通知:" + FRP_FIXING_FILE + " の修正を試みます。");
6783
new Handler().postDelayed(this::overwriteFrp, 5000);
6884
} else {
6985
addText("- 通知:失敗しました。再度実行します。");
@@ -73,10 +89,10 @@ void init() {
7389
})
7490
.setNegativeButton("キャンセル", (dialog, which) -> {
7591
try {
76-
Settings.System.putInt(getContentResolver(), "dcha_state", 3);
92+
Settings.System.putInt(getContentResolver(), DigichalizedStatus, DIGICHALIZE_STATUS_DIGICHALIZED);
7793
} catch (Exception ignored) {
7894
}
79-
startActivity(new Intent().setClassName("com.android.settings", "com.android.settings.Settings"));
95+
startActivity(new Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_ACTIVITY));
8096
})
8197
.show();
8298
}
@@ -88,21 +104,22 @@ String shrinker() {
88104
copyAssetsFile(this);
89105
sh();
90106
addText("- 通知:実行権限を付与しています。");
91-
execute("chmod 770 " + new File(getFilesDir(), "shrinker").getAbsolutePath());
92-
execute("/data/data/com.saradabar.easyblu/files/shrinker");
107+
execute("chmod +x " + new File(getFilesDir(), SHRINKER).getAbsolutePath());
108+
execute(SHRINKER_BIN_PATH + SHRINKER);
93109
String text = getText().toString();
94110
addText("- 結果:");
95111
addText(text);
96112
return text;
97113
}
98114

99115
@SuppressLint("SdCardPath")
116+
@Deprecated
100117
void retry() {
101-
execute("/data/data/com.saradabar.easyblu/files/shrinker");
118+
execute(SHRINKER_BIN_PATH + SHRINKER);
102119
String text = getText().toString();
103120
addText("- 結果:");
104121
addText(text);
105-
if (text.contains("Permissive")) {
122+
if (text.contains(SHRINKER_SUCCESS)) {
106123
addText("- 通知:成功しました。");
107124
addText("- 通知:frp.bin の修正を試みます。");
108125
new Handler().postDelayed(this::overwriteFrp, 5000);
@@ -114,8 +131,8 @@ void retry() {
114131

115132
private void copyAssetsFile(Context context) {
116133
try {
117-
InputStream inputStream = context.getAssets().open("shrinker");
118-
FileOutputStream fileOutputStream = new FileOutputStream(new File(context.getFilesDir(), "shrinker"), false);
134+
InputStream inputStream = context.getAssets().open(SHRINKER);
135+
FileOutputStream fileOutputStream = new FileOutputStream(new File(context.getFilesDir(), SHRINKER), false);
119136
byte[] buffer = new byte[1024];
120137
int length;
121138
while ((length = inputStream.read(buffer)) >= 0) {
@@ -177,40 +194,33 @@ public void execute(String str) {
177194

178195
void overwriteFrp() {
179196
addText("- 通知:DchaService にバインドしています。");
180-
if (!bindService(new Intent("jp.co.benesse.dcha.dchaservice.DchaService").setPackage("jp.co.benesse.dcha.dchaservice"), new ServiceConnection() {
197+
if (!bindService(new Intent(DCHA_SERVICE).setPackage(DCHA_PACKAGE), new ServiceConnection() {
181198

182199
@SuppressLint("SdCardPath")
183200
@Override
184201
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
185202
IDchaService mDchaService = IDchaService.Stub.asInterface(iBinder);
186-
addText("- 通知:/dev/block/by-name/frp をコピーしています。");
203+
addText("- 通知:" + FRP_ORIGIN_PATH + " をコピーしています。");
187204
try {
188-
mDchaService.copyUpdateImage("/dev/block/by-name/frp", "/cache/../sdcard/frp.bin");
205+
mDchaService.copyUpdateImage(FRP_ORIGIN_PATH, DCHA_SYSTEM_COPY + FRP_FIXING_PATH);
189206
} catch (Exception e) {
190-
addText("- 通知:エラーが発生しました。");
207+
addText("- 通知:FRP のコピーに失敗しました。");
191208
addText(e.toString());
192209
init();
193210
return;
194211
}
195212

196213
try {
197-
File file = new File(Environment.getExternalStorageDirectory(), "frp.bin");
198-
DataInputStream dataInStream = new DataInputStream(new BufferedInputStream(new FileInputStream(new File(Environment.getExternalStorageDirectory(), "frp.bin"))));
199-
DataOutputStream dataOutStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(new File(Environment.getExternalStorageDirectory(), "tmp.bin"))));
214+
File file = new File(Environment.getExternalStorageDirectory(), FRP_FIXING_FILE);
215+
DataInputStream dataInStream = new DataInputStream(new BufferedInputStream(new FileInputStream(new File(Environment.getExternalStorageDirectory(), FRP_FIXING_FILE))));
216+
DataOutputStream dataOutStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(new File(Environment.getExternalStorageDirectory(), FRP_FIXING_TEMP))));
200217

201218
int[] tmpHex = new int[(int) file.length()];
202219
int i = 0;
203220

204-
addText("- 通知:frp.bin ファイルサイズ -> " + file.length());
221+
addText("- 通知:" + FRP_FIXING_FILE + " ファイルサイズ -> " + file.length());
205222

206-
while (true) {
207-
int b = dataInStream.read();
208-
209-
if (b == -1) {
210-
break;
211-
}
212-
213-
tmpHex[i] = b;
223+
while ((tmpHex[i] = dataInStream.read()) != -1) {
214224
i++;
215225
}
216226

@@ -225,9 +235,9 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
225235
dataInStream.close();
226236
dataOutStream.close();
227237

228-
addText("- 通知:frp.bin の修正が完了しました。");
229-
addText("- 通知:frp.bin を /dev/block/by-name/frp に上書きしています。");
230-
mDchaService.copyUpdateImage("/sdcard/tmp.bin", "/cache/../dev/block/by-name/frp");
238+
addText("- 通知:" + FRP_FIXING_FILE + " の修正が完了しました。");
239+
addText("- 通知:" + FRP_FIXING_FILE + " を " + FRP_ORIGIN_PATH + " に上書きしています。");
240+
mDchaService.copyUpdateImage(FRP_FIXING_PATH, DCHA_SYSTEM_COPY + FRP_ORIGIN_PATH);
231241

232242
addText("- 通知:すべての操作が終了しました。");
233243
addText("- 通知:ADB から bootloader モードを起動してブートローダをアンロックしてください。");
@@ -239,11 +249,11 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
239249
.setPositiveButton("OK", (dialog, which) -> {
240250
try {
241251
mDchaService.setSetupStatus(3);
242-
if (Settings.Secure.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) {
243-
startActivity(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
244-
} else {
245-
startActivity(new Intent().setClassName("com.android.settings", "com.android.settings.Settings"));
246-
}
252+
startActivity(
253+
Settings.Secure.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1
254+
? new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS)
255+
: new Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_ACTIVITY)
256+
);
247257
} catch (Exception ignored) {
248258
}
249259
})
@@ -267,11 +277,7 @@ public void onServiceDisconnected(ComponentName componentName) {
267277

268278
void addText(String str) {
269279
TextView textView = findViewById(R.id.text);
270-
if (str.isEmpty()) {
271-
textView.append(System.lineSeparator());
272-
} else {
273-
textView.append(" " + str + System.lineSeparator());
274-
}
280+
textView.append(str.isEmpty() ? System.lineSeparator() : " " + str + System.lineSeparator());
275281
ScrollView scrollView = findViewById(R.id.scroll);
276282
scrollView.fullScroll(View.FOCUS_DOWN);
277283
scrollView.post(() -> scrollView.fullScroll(ScrollView.FOCUS_DOWN));

gradle/wrapper/gradle-wrapper.jar

79 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
3+
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginManagement {
44
mavenCentral()
55
}
66
plugins {
7-
id 'com.android.application' version '8.5.1' apply false
7+
id 'com.android.application' version '8.7.2' apply false
88
}
99
}
1010

0 commit comments

Comments
 (0)