Eject Bug Hack

From Exploitee.rs
Revision as of 04:52, 13 March 2012 by Catrane (talk | contribs) (Add patch describing eject bug workaround.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Here is a git patch that consists of a script to detect and recover from the eject bug and the modification necessary to make that script be run as a service. Nothing about this install process is automatic, though once installed it runs fully automatic. If you don't know how to read a git patch, you'd best learn how. Improper application of the contents of this patch to your system could certainly brick it.

Unformatted patch follows:

From f5b9194ad7865bfdaf43ad676965ff77c5895465 Mon Sep 17 00:00:00 2001
From: Catrane <catrane@gtvhacker>
Date: Mon, 12 Mar 2012 23:21:14 -0500
Subject: [PATCH] Hack workaround to make disc eject work on rooted NSZ-GT1.
 Includes 60 second delay before activating as a safety
 window.

---
 init.eagle.rc                      |    5 +++
 system/bin/eject_bug_workaround.sh |   53 ++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 system/bin/eject_bug_workaround.sh

diff --git a/init.eagle.rc b/init.eagle.rc
index 2004d8a..685ce6f 100644
--- a/init.eagle.rc
+++ b/init.eagle.rc
@@ -329,6 +329,7 @@ on init
     setprop com.sony.btv.discplayer.enable 1
     export DISCPLAYER_KEEP_DMIX_ASIS true
     export DISCPLAYER_LOG_VERBOSE true
+    start ejectworkaround
 
   ## for lighttpd
     mkdir /var/log/lighttpd 0750 system system
@@ -439,6 +440,10 @@ service discplayer /system/bin/discplayer
     user root
     group system
 
+service ejectworkaround /system/bin/eject_bug_workaround.sh 60
+    user root
+    group system
+
 on property:com.sony.btv.discplayer.enable=1
     start discplayer
     start discservice
diff --git a/system/bin/eject_bug_workaround.sh b/system/bin/eject_bug_workaround.sh
new file mode 100644
index 0000000..1f4f282
--- /dev/null
+++ b/system/bin/eject_bug_workaround.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# Reason:
+# There is a known problem that, for an unknown reason, disc eject fails on rooted NSZ-GT1 systems.
+# Side effects of this problem include the possibility that the disc is not ejected and in all cases
+# the problem that discs cannot be played after attempted eject.
+# Rebooting the system fixes the problem, but this solution eliminates the need for reboot.
+
+# Alternative solutions:
+# Restart the device via the power cord or ctrl-alt-del.
+
+# Caveats:
+# This fix does not detect the occurrence of any error, but rather occurrence of a known event which
+# reliably preceeds the error and is reliably followed by the error situation.
+# Error messages and odd behavior may be observed onscreen at the moment of eject, though none of
+# this causes any side-effects.
+
+# Stimulus:
+# From command: logcat -b main
+# Output: I DiscPlayerManager: onStartCommand: com.sony.btv.discplayer.EJECT_DISC
+
+# Response:
+# setprop com.sony.btv.discplayer.enable 0
+# busybox eject /dev/block/sr0
+# setprop com.sony.btv.discplayer.enable 1
+
+# Usage:
+#   eject_bug_workaround.sh &
+#   - Runs workaround in background.
+#   eject_bug_workaround.sh 600 &
+#   - Sleeps for 600 seconds before running, all in background.
+#   - Useful for ensuring a window of recovery in case any side-effects occur.
+
+if [ ! -z "$1" ]
+then
+   sleep $1
+fi
+
+LASTDECT=$(date)
+
+logcat -b main DiscPlayerManager:I *:S|busybox awk '/onStartCommand: com.sony.btv.discplayer.EJECT_DISC/ {system("echo onStartCommand: com.sony.btv.discplayer.EJECT_DISC")}'|while busybox awk '/onStartCommand: com.sony.btv.discplayer.EJECT_DISC/ {exit 0}'
+do
+   if [ "$LASTDECT" != "$(date)" ]
+   then
+       echo Detected eject failure.
+       setprop com.sony.btv.discplayer.enable 0
+       busybox eject /dev/block/sr0
+       setprop com.sony.btv.discplayer.enable 1
+       echo Eject failure repair complete.
+       LASTDECT=$(date)
+   fi
+done
+
-- 
1.7.6.1