Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed rebooting
  • Loading branch information
Timothy Caraballo committed Apr 12, 2010
1 parent 2e42357 commit d458577
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.pixelpod.typefresh" android:versionName="0.9.2" android:versionCode="15">
package="net.pixelpod.typefresh" android:versionName="0.9.2" android:versionCode="16">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
Expand Down
Binary file removed res/drawable-nodpi/ic_menu_clear_playlist.png
Binary file not shown.
2 changes: 1 addition & 1 deletion res/values-es/strings.xml
Expand Up @@ -9,7 +9,7 @@
<string name="firstrun_message">Gracias por ulitizar a Type Fresh! Como cualquier programa que funciona como root, debe hacer un Nandroid backup primero. También haga un backup de su fuentes existente para que se puede restaurar lo a cualquier momento.\n\nÉste programa necesita AndExplorer para selectar ficheros, y es disponible en el Android Market.</string>
<string name="firstrun_title">Bienvenido a Type Fresh!</string>
<string name="reboot_title">Necesia Rebutear</string>
<string name="reboot_message">Su systema necesita rebutear para cargar los nuevos funetes. Por favor, rebutear tan pronto come sea posible.</string>
<string name="reboot_message">Su systema necesita rebutear para cargar los nuevos fuentes. Quieres hacerlo ahora?</string>
<string name="reboot_ok">Rebutear ahora</string>
<string name="reboot_cancel">No</string>
<string name="about_title">Type Fresh v0.9</string>
Expand Down
2 changes: 1 addition & 1 deletion res/values-ja/strings.xml
Expand Up @@ -9,7 +9,7 @@
<string name="firstrun_message">Thank you for using Type Fresh! As with any program that does work as root, you should perform a Nandroid backup first. Also, use the menu to create a backup of your existing system fonts so that you can restore them at any time.\n\nThis program requires AndExplorer for file selections, and is available on the Android Market.</string>
<string name="firstrun_title">ようこそType Fresh!</string>
<string name="reboot_title">リブート required</string>
<string name="reboot_message">Your system needs to be rebooted to load your new fonts. Please do so as soon as possible.</string>
<string name="reboot_message">Your system needs to be rebooted to load your new fonts. Would you like to reboot now?</string>
<string name="reboot_ok">はい</string>
<string name="reboot_cancel">いいえ</string>
<string name="about_title">Type Fresh v0.9</string>
Expand Down
4 changes: 2 additions & 2 deletions res/values/strings.xml
Expand Up @@ -9,7 +9,7 @@
<string name="firstrun_message">Thank you for using Type Fresh! As with any program that does work as root, you should perform a Nandroid backup first. Also, use the menu to create a backup of your existing system fonts so that you can restore them at any time.\n\nThis program requires AndExplorer for file selections, and is available on the Android Market.</string>
<string name="firstrun_title">Welcome to Type Fresh!</string>
<string name="reboot_title">Reboot required</string>
<string name="reboot_message">Your system needs to be rebooted to load your new fonts. Please do so as soon as possible.</string>
<string name="reboot_message">Your system needs to be rebooted to load your new fonts. Would you like to reboot now?</string>
<string name="reboot_ok">Reboot now</string>
<string name="reboot_cancel">Cancel</string>
<string name="about_title">Type Fresh v0.9</string>
Expand All @@ -19,7 +19,7 @@
<string name="need_root_message">Error copying files. Are you rooted?</string>
<string name="need_root_title">su command error</string>
<string name="reboot_failed_title">Reboot error</string>
<string name="reboot_failed_message">Could not reboot the system. Please do so manually.</string>
<string name="reboot_failed_message">Could not reboot the system. Your system needs to be rebooted to load your new fonts. Please do so as soon as possible.</string>
<string name="mkdir_failed_title">Error</string>
<string name="mkdir_failed_message">Could not create Fonts directory on sdcard</string>
<string name="remount_failed_title">Error remounting</string>
Expand Down
9 changes: 0 additions & 9 deletions src/net/pixelpod/typefresh/FileCopier.java
Expand Up @@ -133,13 +133,6 @@ protected Void doInBackground(Object... params) {
su.destroy();
}

if (remountRequired) {
if (!remount(READ_ONLY)) {
// TODO: it ALWAYS fails right now, so stop yelling ;_;
// publishProgress(TypeFresh.DIALOG_REMOUNT_FAILED);
}
}

if (needReboot) {
publishProgress(TypeFresh.DIALOG_NEED_REBOOT);
}
Expand Down Expand Up @@ -188,8 +181,6 @@ public void setActivity(TypeFresh owner) {
typeFresh = owner;
}

// TODO: Error remounting: "mount: mounting /dev/block/mtdblock3 on /system failed:
// Device or resource busy"
/**
* Remounts /system read/write.
*
Expand Down
26 changes: 15 additions & 11 deletions src/net/pixelpod/typefresh/TypeFresh.java
Expand Up @@ -25,6 +25,7 @@

package net.pixelpod.typefresh;

import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -426,8 +427,6 @@ public void onClick(DialogInterface dialog, int id) {
R.string.remount_failed_title, R.string.remount_failed_message);
break;
case DIALOG_NEED_REBOOT:
// I want to reboot myself, but I haven't figured it out yet
/*
dialog = (new AlertDialog.Builder(this))
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.reboot_message)
Expand All @@ -440,6 +439,9 @@ public void onClick(DialogInterface dialog, int id) {
} catch (IOException e) {
Log.e(TAG, e.toString());
showDialog(TypeFresh.DIALOG_REBOOT_FAILED);
} catch (InterruptedException e) {
Log.e(TAG, e.toString());
showDialog(TypeFresh.DIALOG_REBOOT_FAILED);
}
}
})
Expand All @@ -449,9 +451,6 @@ public void onClick(DialogInterface dialog, int id) {
}
}
).create();
*/
dialog = makeSimpleAlertDialog(android.R.drawable.ic_dialog_alert,
R.string.reboot_title, R.string.reboot_message);
break;
case DIALOG_REBOOT:
progressDialog = new ProgressDialog(this);
Expand Down Expand Up @@ -504,16 +503,14 @@ public void onClick(DialogInterface dialog, int id) {
).create();
}

// TODO: Figure out why reboot is random
// reboot works, but can happen any time from 10 seconds to 5 minutes after being called
// possible cause is my app still holding references to files on /system after copying to it,
// as shown by running lsof
/**
* Reboots the system.
*
* @throws IOException If our <code>su</code> process has a problem.
* @throws InterruptedException If our <code>su</code> process has a problem.
*/
protected void reboot() throws IOException {
protected void reboot() throws IOException, InterruptedException {
// it never actually shows the dialog, though :'/
showDialog(DIALOG_REBOOT);

if (fileCopier != null) {
Expand All @@ -524,11 +521,18 @@ protected void reboot() throws IOException {
try {
Log.i(TAG,"Calling reboot");
Process su = runtime.exec("/system/bin/su");
su.getOutputStream().write("reboot".getBytes());
DataOutputStream stream = new DataOutputStream(su.getOutputStream());
stream.writeBytes("reboot\nexit\n");
stream.flush();
su.waitFor();
} catch (IOException e) {
// get rid of our dialog first and then throw the exception back
dismissDialog(DIALOG_PROGRESS);
throw e;
} catch (InterruptedException e) {
// get rid of our dialog first and then throw the exception back
dismissDialog(DIALOG_PROGRESS);
throw e;
}

if (progressDialog.isShowing()) {
Expand Down

0 comments on commit d458577

Please sign in to comment.