View Single Post
Old 01-16-2024, 11:18 AM   #23
Sentenced
Junior Member
Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'Sentenced knows the difference between 'who' and 'whom'
 
Posts: 1
Karma: 10000
Join Date: Jan 2024
Device: Paperwhite 5
The file in /var/local/mesquite/start.sh seems to be unpacked from a SquashFS img in /opt/var/local/local.sqsh at boot, which is why your change does not persist. I tried to patch it during boot, but it did not have an effect, so I'm not sure if its actually executed at any point.

But one option to change the default view is to simply wait for the home screen to load, and then use the same LIPC command to change to the library view. The tricky part is to determine when to run the command (you can't do it too early, and waiting too long is obviously not optimal either), but we can poll the activeView prop periodically to determine when KPP_HOME is active. I'm new to the Kindle ecosystem and haven't had time to properly investigate if there's a better way to force the app to load the library screen directly, but I think this is a decent compromise (the home screen shows up for less than a second before the library activates... might be possible to decrease it further by tweaking the polling frequency, or writing a custom LIPC event listener).

Example upstart script below (put into /etc/upstart/defaultscreen.conf). You should be able to test it before rebooting by going into the home screen and executing "start defaultscreen".

Code:
start on started kppmainapp

script
source /etc/upstart/functions

f_log I defaultscreen "defaultscreen.conf started"
           
sleep 2                                              

while ! lipc-get-prop com.lab126.appmgrd activeView | grep KPP_HOME >/dev/null; do               
    f_log I defaultscreen "Home screen not yet active, sleeping 300ms"               
    usleep 300000                                                
done 
                                                             
f_log I homescreen "Homescreen is active, switching screens"
                                          
lipc-set-prop com.lab126.appmgrd start app://com.lab126.KPPMainApp?view=KPP_LIBRARY
          
end script
As for the ridiculous cloud error nag screen, for some reason that part of KPPMainApp does not respect the system-wide isRegistered IPC prop (that can be set to 1 by manually creating a reginfo file) even though much of the rest of the app does. I think this might be due to some missing post registration sync operation not being executed correctly (possibly requiring the creation of additional files and/or registry entries). On a side note, I also noticed a fake registered device will quite annoyingly constantly try to sync to the cloud, even if airplane mode is enabled, causing massive spam in the system log (and possibly increased battery drain).

We can however patch the nag screen away by modifying the Hermes bytecode in /app/KPPMainApp/js/KPPMainApp.js.hbc. Below is a simple shell script patcher that works on 5.16.2.1.1, and patches the file directly (without creating a backup first, so do it manually). Separate fake registering is not required, but collection creation remains disabled, so further investigation is needed to enable that (very likely related to the sync issue I mentioned earlier).

Code:
#!/bin/sh

FILE=KPPMainApp.js.hbc
ORIGINAL_CHECKSUM=459d917210ebe4cf6908974cef9fb378
PATCHED_CHECKSUM=5a7cec166d174b5917100264ef4dba40

if [ ! -f $FILE ]; then
   echo $FILE not found in working directory
   exit
fi

checksum=$(md5sum $FILE | awk '{ print $1 }')

if [ "$checksum" != "$ORIGINAL_CHECKSUM" ]; then
   echo "$FILE has an incorrect checksum: $checksum (expected $ORIGINAL_CHECKSUM)"
   echo "This patch is compatible with fw 5.16.2.1.1 only"
   exit
fi

echo Press OK to start patching $FILE
echo NOTE: Make sure you have a backup first!

read

printf '\034' | dd of=$FILE bs=1 seek=89860 conv=notrunc
printf '\152\000\001\130\000' | dd of=$FILE bs=1 seek=1309769 conv=notrunc

echo Verifying patched file checksum...

checksum=$(md5sum $FILE | awk '{ print $1 }')

if [ "$checksum" == "$PATCHED_CHECKSUM" ]; then
    echo "Patched file checksum ok."
elif [ "$checksum" == "$ORIGINAL_CHECKSUM" ]; then
    echo "File checksum did not change. Make sure your file system is not read-only."
else
    echo "WARNING: Patched file checksum is incorrect. Something went wrong!"
fi
The standard disclaimer applies: You probably should not attempt this if you are not comfortable in the Linux/Kindle shell (i.e. know how to execute the script in the correct folder and mount your root file system rw), and do not come complaining to me if you manage to brick your device. Make sure you have SSH access at boot (or some other way to recover your device) in case KPPMainApp fails to launch correctly.
Sentenced is offline   Reply With Quote