Skip to content

Instantly share code, notes, and snippets.

@marshall
Created September 17, 2012 17:57
Show Gist options
  • Save marshall/3738776 to your computer and use it in GitHub Desktop.
Save marshall/3738776 to your computer and use it in GitHub Desktop.
Force AUS update check
#!/bin/bash
DEVICE_TIME=$(date -j -f "%a %b %d %T %Z %Y" "`adb -d shell date`" "+%s" 2>/dev/null)
PROFILE_PREFS=$(adb -d shell cat '/data/b2g/mozilla/*.default/prefs.js')
PROFILE_DIR=$(adb -d shell ls -l /data/b2g/mozilla | grep .default)
PROFILE_REGEX="([^ ]+\.default)"
if [[ "$PROFILE_DIR" =~ $PROFILE_REGEX ]]; then
PROFILE_DIR=/data/b2g/mozilla/${BASH_REMATCH[1]}
else
echo "Couldn't find Profile directory :("
exit 1
fi
# change last update time to 2 days ago. expr doesn't like localtime
TWO_DAYS_AGO=`python -c "print $DEVICE_TIME - (60 * 60 * 24 * 2)"`
echo $TWO_DAYS_AGO
TIMER_PREF=app.update.lastUpdateTime.background-update-timer
adb -d shell cat "$PROFILE_DIR/prefs.js" | \
sed -E "s/user_pref\(\"$TIMER_PREF\", [0-9]+\)\;/user_pref\(\"$TIMER_PREF\", $TWO_DAYS_AGO\)\;/" \
> /tmp/force-update-prefs.js
echo 'user_pref("app.update.timerFirstInterval", 10000); // force check update after 10s' \
>> /tmp/force-update-prefs.js
echo 'user_pref("app.update.timerMinimumDelay", 1); // minimum delay' \
>> /tmp/force-update-prefs.js
# backup the old prefs
adb -d pull "$PROFILE_DIR/prefs.js" /tmp/prefs.js.bak
adb -d push /tmp/prefs.js.bak "$PROFILE_DIR/prefs.js.bak"
adb -d push /tmp/force-update-prefs.js $PROFILE_DIR/prefs.js
adb -d shell "stop b2g; start b2g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment