Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobold831 committed Jun 1, 2024
1 parent 210f44b commit db4ebd4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 96 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
minSdk 28
//noinspection ExpiredTargetSdkVersion
targetSdk 22
versionCode 2
versionName "1.0.1"
versionCode 3
versionName "1.1"
proguardFiles += 'proguard-rules.pro'
multiDexEnabled false
}
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" tools:ignore="ProtectedPermissions" />
<uses-permission android:name="jp.co.benesse.dcha.permission.ACCESS_SYSTEM" />

<application
Expand All @@ -13,11 +15,14 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:windowSoftInputMode="stateAlwaysHidden">
android:windowSoftInputMode="stateAlwaysHidden"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
</application>
Expand Down
111 changes: 53 additions & 58 deletions app/src/main/java/com/saradabar/easyblu/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.saradabar.easyblu;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -10,10 +12,8 @@
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ScrollView;
import android.widget.TextView;

Expand Down Expand Up @@ -45,67 +45,43 @@ protected void onCreate(Bundle savedInstanceState) {
addText("****************************");
addText("Welcome to Easy BLU ! :)");
addText("Easy BLU へようこそ!");
addText("");
addText("続行するには、該当する数字を入力してください");
addText("- 1:shrinker を実行し、Permissive に成れたら frp.bin を修正します。");
addText("- 0:終了");
addText("****************************");
addText("fingerprint:" + Build.FINGERPRINT);
init();
}

void init() {
EditText editText = findViewById(R.id.edit);
editText.setEnabled(true);
Button button = findViewById(R.id.button);
button.setEnabled(true);
button.setOnClickListener(v -> {
switch (editText.getText().toString()) {
case "1":
confirm();
break;
case "0":
finishAffinity();
break;
default:
addText("- 通知:" + "コマンド [" + editText.getText().toString() + "] は実行できません");
break;
}
editText.getEditableText().clear();
});
}

@Deprecated
void confirm() {
addText("- 確認:よろしいですか?続行するには 0 を入力してください");
Button button = findViewById(R.id.button);
button.setOnClickListener(v -> {
EditText editText = findViewById(R.id.edit);
if (editText.getText().toString().equals("0")) {
editText.setEnabled(false);
button.setEnabled(false);
addText("- 通知:shrinker を実行しました");
addText("- 警告:デバイスには絶対に触れないでください。処理が終了するまでお待ち下さい。");
addText("- 警告:デバイスが再起動した場合は失敗です。起動後に再度実行してください。");
new Handler().postDelayed(() -> {
String result = shrinker();
if (result.contains("result 49")) {
addText("- 通知:成功しました。");
addText("- 通知:frp.bin の修正を試みます。");
new Handler().postDelayed(this::overwriteFrp, 5000);
} else {
addText("- 通知:失敗しました。再度実行します。");
new Handler().postDelayed(this::retry, 5000);
new AlertDialog.Builder(this)
.setCancelable(false)
.setTitle("実行しますか?")
.setMessage("続行するには OK を押下してください\n\nキャンセルを押すと Android 設定に遷移します")
.setPositiveButton("OK", (dialog, which) -> {
addText("- 通知:shrinker を実行しました");
addText("- 警告:デバイスには絶対に触れないでください。処理が終了するまでお待ち下さい。");
addText("- 警告:デバイスが再起動した場合は失敗です。起動後に再度実行してください。");
new Handler().postDelayed(() -> {
String result = shrinker();
if (result.contains("result 49")) {
addText("- 通知:成功しました。");
addText("- 通知:frp.bin の修正を試みます。");
new Handler().postDelayed(this::overwriteFrp, 5000);
} else {
addText("- 通知:失敗しました。再度実行します。");
new Handler().postDelayed(this::retry, 5000);
}
}, 5000);
})
.setNegativeButton("キャンセル", (dialog, which) -> {
try {
Settings.System.putInt(getContentResolver(), "dcha_state", 3);
} catch (Exception ignored) {
}
}, 5000);
} else {
addText("- 通知:この操作はキャンセルされました");
init();
}
editText.getEditableText().clear();
});
startActivity(new Intent().setClassName("com.android.settings", "com.android.settings.Settings"));
})
.show();
}

@SuppressLint("SdCardPath")
String shrinker() {
stringBuilder = new StringBuilder();
addText("- 通知:" + getFilesDir() + " にファイルをコピーしています。");
Expand All @@ -120,7 +96,7 @@ String shrinker() {
return text;
}

@Deprecated
@SuppressLint("SdCardPath")
void retry() {
execute("/data/data/com.saradabar.easyblu/files/shrinker");
String text = getText().toString();
Expand Down Expand Up @@ -203,6 +179,7 @@ void overwriteFrp() {
addText("- 通知:DchaService にバインドしています。");
if (!bindService(new Intent("jp.co.benesse.dcha.dchaservice.DchaService").setPackage("jp.co.benesse.dcha.dchaservice"), new ServiceConnection() {

@SuppressLint("SdCardPath")
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
IDchaService mDchaService = IDchaService.Stub.asInterface(iBinder);
Expand Down Expand Up @@ -253,8 +230,26 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
mDchaService.copyUpdateImage("/sdcard/tmp.bin", "/cache/../dev/block/by-name/frp");

addText("- 通知:すべての操作が終了しました。");
addText("- 通知:コンピュータから bootloader モードを起動してブートローダをアンロックしてください。");
} catch (IOException | RemoteException e) {
addText("- 通知:ADB から bootloader モードを起動してブートローダをアンロックしてください。");

new AlertDialog.Builder(MainActivity.this)
.setCancelable(false)
.setTitle("開発者オプションを開きますか?")
.setMessage("続行すると、学習環境にして開発者オプションを開きます\nADB を有効にしたい場合は、開いてください\n\n注意:開発者向けオプションが有効になっていない場合は設定を開きます\n設定から開発者向けオプションを有効にして開いてください\nパスワード無しで開くことができます")
.setPositiveButton("OK", (dialog, which) -> {
try {
mDchaService.setSetupStatus(3);
if (Settings.Secure.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) {
startActivity(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
} else {
startActivity(new Intent().setClassName("com.android.settings", "com.android.settings.Settings"));
}
} catch (Exception ignored) {
}
})
.setNeutralButton("キャンセル", (dialog, which) -> dialog.dismiss())
.show();
} catch (Exception e) {
addText("- 通知:エラーが発生しました。");
addText(e.toString());
init();
Expand Down
39 changes: 6 additions & 33 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ScrollView
android:id="@+id/scroll"
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</ScrollView>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:inputType="number"
android:hint="コマンド入力" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="コマンド実行" />
</LinearLayout>
</LinearLayout>
android:layout_height="wrap_content" />
</ScrollView>

0 comments on commit db4ebd4

Please sign in to comment.