@@ -66,11 +66,11 @@ public class MainActivity extends Activity {
6666
6767 private static final String LAUNCHER3 = "com.android.launcher3" ;
6868 private static final String APP_PACKAGE = "com.saradabar.easyblu" ;
69+ private static final String SETTINGS = "com.android.settings" ;
6970
7071 private static final String DCHA_PACKAGE = "jp.co.benesse.dcha.dchaservice" ; // DchaService を使用
7172 private static final String DCHA_SERVICE = DCHA_PACKAGE + ".DchaService" ; // copyUpdateImage を使ってシステム権限でファイルを操作
7273 private static final int DIGICHALIZE_STATUS_UNDIGICHALIZE = 0 ;
73- private static final int DIGICHALIZE_STATUS_DIGICHARIZING_DL_COMPLETE = 2 ;
7474 private static final int DIGICHALIZE_STATUS_DIGICHALIZED = 3 ; // 開発者向けオプションのロック(BenesseExtension.checkPassword)の阻止
7575 private static final String DCHA_SYSTEM_COPY = "/cache/.." ; // 内部の if 文で弾かれるのを防ぐ
7676 private IDchaService mDchaService = null ;
@@ -98,11 +98,6 @@ public void onServiceDisconnected(ComponentName componentName) {
9898 protected void onCreate (Bundle savedInstanceState ) {
9999 super .onCreate (savedInstanceState );
100100 setContentView (R .layout .activity_main );
101- echo ("""
102- ****************************
103- Welcome to Easy BLU ! :)
104- Easy BLU へようこそ!
105- ****************************""" );
106101 echo ("fingerprint:" + Build .FINGERPRINT );
107102 init ();
108103 }
@@ -112,6 +107,7 @@ protected void onDestroy() {
112107 super .onDestroy ();
113108 try {
114109 setEnvWithDcha (true );
110+ setSetupStatus (DIGICHALIZE_STATUS_UNDIGICHALIZE );
115111 } catch (Exception e ) {
116112 error (e );
117113 }
@@ -176,7 +172,12 @@ private StringBuilder exec(String cmd) throws RuntimeException {
176172 process .waitFor ();
177173
178174 String data ;
179- while ((data = bufferedReader .readLine ()) != null ) stringBuilder .append (data ).append (System .lineSeparator ());
175+ while ((data = bufferedReader .readLine ()) != null ) {
176+ data .trim ();
177+ if (data .startsWith ("Temp" ) || data .startsWith ("Home" ) || data .startsWith ("----" ) || data .startsWith ("http" )) continue ;
178+ stringBuilder .append (data );
179+ if (!data .isEmpty ()) stringBuilder .append (System .lineSeparator ());
180+ }
180181 bufferedReader .close ();
181182 bufferedWriter .close ();
182183 process .destroy ();
@@ -238,6 +239,7 @@ private void warning(String str) {
238239 */
239240 private void error (Exception e ) {
240241 echo ("- エラー:" + System .lineSeparator () + e );
242+ setSetupStatus (DIGICHALIZE_STATUS_UNDIGICHALIZE );
241243 TextView textView = findViewById (R .id .text_status );
242244 textView .setText ("始めからやり直しますか?" );
243245 Button mainButton = findViewById (R .id .button_main );
@@ -260,6 +262,7 @@ private void error(Exception e) {
260262 */
261263 private void stop (String str ) {
262264 echo ("- エラー:" + System .lineSeparator () + str );
265+ setSetupStatus (DIGICHALIZE_STATUS_UNDIGICHALIZE );
263266 TextView textView = findViewById (R .id .text_status );
264267 textView .setText ("アプリを終了してください。" );
265268 Button mainButton = findViewById (R .id .button_main );
@@ -282,40 +285,51 @@ private void stop(String str) {
282285 * @since v1.0
283286 */
284287 private void init () {
288+ TextView textView = findViewById (R .id .text_status );
289+ Button mainButton = findViewById (R .id .button_main );
290+ Button subButton = findViewById (R .id .button_sub );
291+
285292 if (!CT3 && !CTX && !CTZ ) {
286293 stop ("対象端末ではありません" );
287294 } else if (!bindService (BIND_DCHA , mConn , Context .BIND_AUTO_CREATE )) {
288295 stop ("DchaService に接続できませんでした" );
296+ } else if (BenesseExtension .getDchaState () == DIGICHALIZE_STATUS_DIGICHALIZED ) {
297+ mainButton .setOnClickListener (v -> {
298+ mainButton .setEnabled (false );
299+ mainButton .setText (" " );
300+ subButton .setEnabled (false );
301+ subButton .setText (" " );
302+ notify ("エクスプロイトを実行しています" );
303+ copyAssets (CT3 ? MTK_SU : SHRINKER );
304+ callFunc (this ::setup );
305+ });
306+ subButton .setOnClickListener (v -> {
307+ setEnvWithDcha (true );
308+ setSetupStatus (DIGICHALIZE_STATUS_UNDIGICHALIZE );
309+ finish ();
310+ });
289311 } else {
290- TextView textView = findViewById (R .id .text_status );
291312 textView .setText ("""
292313 ブートローダーアンロックに必要なシステム改ざん処理を実行しますか?
293- この処理を実行したことによる損害等について開発者は一切の責任を取りません。
314+ この処理を実行したことによる損害等について開発者は一切の責任を取りません
294315
295316 続行するには [実行] を押下してください""" );
296- Button mainButton = findViewById (R .id .button_main );
297- Button subButton = findViewById (R .id .button_sub );
298- mainButton .setEnabled (true );
299317 mainButton .setText ("実行" );
300318 mainButton .setOnClickListener (v -> {
301319 setEnvWithDcha (false );
320+ setSetupStatus (DIGICHALIZE_STATUS_DIGICHALIZED );
302321 mainButton .setEnabled (false );
303322 mainButton .setText (" " );
304323 subButton .setEnabled (false );
305324 subButton .setText (" " );
306- textView .setText ("""
307- デバイスには処理が終了するまで絶対に触れないでください。
308-
309- デバイスが再起動した場合は、再度実行してください。""" );
310- notify ("エクスプロイトをコピーしています。" );
325+ textView .setText ("デバイスには処理が終了するまで絶対に触れないでください" );
326+ notify ("エクスプロイトを実行しています" );
311327 copyAssets (CT3 ? MTK_SU : SHRINKER );
312328 callFunc (this ::setup );
313329 });
314- subButton .setEnabled (true );
315330 subButton .setText ("設定アプリを開く" );
316331 subButton .setOnClickListener (v -> {
317332 setEnvWithDcha (true );
318- setDchaStateCompleted ();
319333 startActivity (new Intent (Settings .ACTION_SETTINGS ));
320334 finish ();
321335 });
@@ -355,9 +369,9 @@ private void setup() { // retry() と同様
355369 */
356370 private void copyFile (String src , String dst ) {
357371 try {
358- MainActivity .this .notify (src + " を " + dst + " にコピーしています。 " );
372+ MainActivity .this .notify (src + " を " + dst + " にコピーしています" );
359373 if (mDchaService .copyUpdateImage (src , DCHA_SYSTEM_COPY + dst )) {
360- MainActivity .this .notify (src + " を削除しています。 " );
374+ MainActivity .this .notify (src + " を削除しています" );
361375 new File (src ).delete ();
362376 }
363377 } catch (Exception e ) {
@@ -404,24 +418,8 @@ private void setSetupStatus(int status) {
404418 }
405419 }
406420
407- /**
408- * BenesseExtension の保護状況に基づき DchaState を変更
409- * @author Syuugo
410- * @since v3.2
411- */
412- private void setDchaStateCompleted () {
413- try {
414- if (COUNT_DCHA_COMPLETED_FILE .exists ()) {
415- setSetupStatus (DIGICHALIZE_STATUS_DIGICHALIZED );
416- }
417- } catch (Exception e ) {
418- error (e );
419- }
420- }
421-
422421 private void setEnvWithDcha (boolean completed ) {
423422 hideNavigationBar (!completed );
424- setSetupStatus (completed ? DIGICHALIZE_STATUS_UNDIGICHALIZE : DIGICHALIZE_STATUS_DIGICHARIZING_DL_COMPLETE );
425423 clearDefaultPreferredApp (completed ? APP_PACKAGE : LAUNCHER3 );
426424 setDefaultPreferredHomeApp (completed ? LAUNCHER3 : APP_PACKAGE );
427425 }
@@ -430,8 +428,8 @@ private void updateTouchpanelFw() {
430428 notify ("タッチパネルのファームウェアを更新しています" );
431429 copyAssets (NVT_TP_FW );
432430 try {
433- notify ( "結果:" + BenesseExtension .putString (BC_NVT_TP_FW_UPDATE , NVT_TP_FW_UPDATE ) );
434- notify ( "バージョン:" + BenesseExtension . getString ( BC_NVT_TP_FW_VERSION ) );
431+ BenesseExtension .putString (BC_NVT_TP_FW_UPDATE , NVT_TP_FW_UPDATE );
432+ warning ( "しばらく画面の操作は受け付けません" );
435433 } catch (Exception e ) {
436434 error (e );
437435 }
@@ -446,10 +444,10 @@ private void updateTouchpanelFw() {
446444 * @since v1.0
447445 */
448446 private void overwriteFrp () {
449- notify (FRP + " の修正を試みます。 " );
447+ notify (FRP + " の修正を試みます" );
450448 copyAssets (FRP );
451449 try {
452- notify (FRP + " を書き換えます。 " );
450+ notify (FRP + " を書き換えます" );
453451 copyFile (FRP_COPY , FRP_BLOCK ); // 修正済み FRP を適用
454452 } catch (Exception e ) {
455453 error (e );
@@ -482,7 +480,7 @@ private void parted(String cmd) {
482480 @ NonNull
483481 private String getBlockDeviceSize () {
484482 copyAssets (PARTED );
485- notify ("BOOTDEVICE の詳細を出力します。 " );
483+ notify ("BOOTDEVICE の詳細を出力します" );
486484 return exec (PARTED_CMD + "print" ).toString ();
487485 }
488486
@@ -495,14 +493,14 @@ private String getBlockDeviceSize() {
495493 * @since v2.0
496494 */
497495 private void checkFixed () {
498- notify ("BenesseExtension による保護を回避します。 " );
496+ notify ("BenesseExtension による保護を回避します" );
499497 exec ("touch /factory/ignore_dcha_completed" );
500498 notify (EXPDB + " のサイズを計算します。" );
501499 if (getBlockDeviceSize ().contains ("124MB 134MB" )) { // 純正 expdb のセクタ範囲
502- notify (EXPDB + " は修正されていません。 " );
500+ notify (EXPDB + " は修正されていません" );
503501 } else {
504- notify (EXPDB + " は既に修正済みです。 " );
505- notify ("既存の " + FRP + " を削除します。 " );
502+ notify (EXPDB + " は既に修正済みです" );
503+ notify ("既存の " + FRP + " を削除します" );
506504 parted ("rm 24" );
507505 }
508506 callFunc (this ::fixExpdb );
@@ -516,13 +514,13 @@ private void checkFixed() {
516514 * @since v2.0
517515 */
518516 private void fixExpdb () {
519- notify (EXPDB + " を削除します。 " );
517+ notify (EXPDB + " を削除します" );
520518 parted ("rm 13" );
521- notify (EXPDB + " を 9MB で再生成します。 " );
519+ notify (EXPDB + " を 9MB で再生成します" );
522520 parted ("mkpart " + EXPDB + " 124MB 133MB" );
523- notify (EXPDB + " のラベルを設定します。 " );
521+ notify (EXPDB + " のラベルを設定します" );
524522 parted ("name 13 " + EXPDB );
525- notify (EXPDB + " のフラグを修正します。 " );
523+ notify (EXPDB + " のフラグを修正します" );
526524 parted ("toggle 13 msftdata" );
527525 callFunc (this ::createFrp );
528526 }
@@ -535,13 +533,13 @@ private void fixExpdb() {
535533 * @since v2.0
536534 */
537535 private void createFrp () {
538- notify (FRP + " を 1MB で生成します。 " );
536+ notify (FRP + " を 1MB で生成します" );
539537 parted ("mkpart " + FRP + " 133MB 134MB" );
540- notify (FRP + " のラベルを設定します。 " );
538+ notify (FRP + " のラベルを設定します" );
541539 parted ("name 24 " + FRP );
542- notify (FRP + " のフラグを修正します。 " );
540+ notify (FRP + " のフラグを修正します" );
543541 parted ("toggle 24 msftdata" );
544- notify (PART24 + " を上書き修正します。 " );
542+ notify (PART24 + " を上書き修正します" );
545543 copyAssets (FRP );
546544 exec ("dd if=" + FRP_COPY + " of=" + PART24 ); // 必ずフルパス
547545 callFunc (this ::openSettings );
@@ -556,13 +554,12 @@ private void openSettings() {
556554 setEnvWithDcha (true );
557555 notify ("すべての修正が完了しました!" );
558556 TextView textView = findViewById (R .id .text_status );
559- textView .setText ("設定 または 開発者向けオプション を開きますか?" );
557+ textView .setText ("[設定] または [ 開発者向けオプション] を開きますか?" );
560558 Button mainButton = findViewById (R .id .button_main );
561559 Button subButton = findViewById (R .id .button_sub );
562560 mainButton .setEnabled (true );
563561 mainButton .setText ("開く" );
564562 mainButton .setOnClickListener (v -> {
565- setDchaStateCompleted ();
566563 startActivity (new Intent (
567564 Settings .Secure .getInt (getContentResolver (), Settings .Global .DEVELOPMENT_SETTINGS_ENABLED , 0 ) == 1
568565 ? Settings .ACTION_APPLICATION_DEVELOPMENT_SETTINGS // 開発者向けオプションが解放されている場合は開く
0 commit comments