From 1c26ab10ae2b1eed0a4c126ec56b8549715212e5 Mon Sep 17 00:00:00 2001 From: JBirdVegas Date: Mon, 16 Jan 2012 17:20:51 -0500 Subject: [PATCH] handle mounting safely --- .../settings/switches/BootAnimSwitch.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/com/liquid/settings/switches/BootAnimSwitch.java b/src/com/liquid/settings/switches/BootAnimSwitch.java index 5f08128..09aadea 100644 --- a/src/com/liquid/settings/switches/BootAnimSwitch.java +++ b/src/com/liquid/settings/switches/BootAnimSwitch.java @@ -78,18 +78,17 @@ public int establishState() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (mStateMachineEvent) { - Log.d(TAG, "mStateMachineEvent is true returning"); + Log.d(TAG, "onCheckedChanged mStateMachineEvent is true returning"); return; + } else { + Log.d(TAG, "onCheckedChanged mStateMachienEvent is false not returning"); } + boolean success_0 = false; boolean success_1 = false; - //TODO handle mounting for killing and appending prop - //we can only dyanically set android:id to an int so we parce our real name and use an variable for reference - try { - int bootanimation_android_id = Integer.parseInt("bootanimations_preference_screen"); - } catch(NumberFormatException nfe) { - Log.d(TAG, "Could not parse " + nfe); + if (!RootHelper.remountRW()) { + throw new RuntimeException("we couldn't mount /system"); } if (isChecked) { @@ -101,8 +100,18 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { success_1 = RootHelper.killProp(String.format(KILL_PROP_CMD, "debug.sf.nobootanimation")); Global.bootanimations_switch_on = false; } - if (!success_0 && ! success_1) { + + if (!success_0) { //TODO do something when we fail + Log.d(TAG, "ro.kernel.android.bootanim failed"); + } else if (!success_1) { + //TODO find a way to handle these failures gracefully + Log.d(TAG, "debug.sf.nobootanimation failed"); + } + + if (!RootHelper.remountRO()) { + Log.d(TAG, "Couldn't remount /system as read only"); + //TODO notify user of failure } return; }