~toykeeper/+junk/flash-helper

« back to all changes in this revision

Viewing changes to flash.sh

  • Committer: Selene Scriven
  • Date: 2016-04-06 00:03:56 UTC
  • Revision ID: selene.scriven@canonical.com-20160406000356-i5on1enpy6hp4lcf
Added an adb access workaround for old images with new UDF or new recovery.img.
  (tries to add .adb_onlock during flash while device is wide open)
Also fixed a small bug while pushing photos;
  tried to chown files in the wrong directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
echo ubuntu-device-flash $SERVER $REVARGS touch --channel=$CHANNEL --device $MODEL $DEVMODE $RECOVERY --wipe $DEVTAR $EXTRA
237
237
ubuntu-device-flash $SERVER $REVARGS touch --channel=$CHANNEL --device $MODEL $DEVMODE $RECOVERY --wipe $DEVTAR $EXTRA
238
238
 
 
239
# Try to ensure adb is going to work
 
240
# (create the access file during the "magic window"
 
241
# when recovery.img is still running)
 
242
# (add it repeatedly to make sure it happens *after* /userdata gets formatted)
 
243
sleep 15
 
244
if [ x$ADB = xyes ]; then
 
245
  COUNT=10  # try this many times
 
246
  ADB_ENABLED=
 
247
  while [ "$COUNT" -gt 0 ]; do
 
248
    # display progress if we haven't succeeded yet
 
249
    if [ -z "$ADB_ENABLED" ]; then
 
250
      echo "Trying to add .adb_onlock ($COUNT tries remaining)"
 
251
    fi
 
252
    # create and verify the file
 
253
    if adb shell echo success | grep success > /dev/null ; then
 
254
      # no rootcmd is needed since recovery mode is already root
 
255
      adb shell touch /data/.adb_onlock
 
256
      if adb shell ls /data/.adb_onlock | grep adb_onlock > /dev/null ; then
 
257
        ADB_ENABLED=yes
 
258
      fi
 
259
    fi
 
260
    COUNT=$(expr "$COUNT" - 1)
 
261
    sleep 6
 
262
  done
 
263
  # final result
 
264
  if [ x"$ADB_ENABLED" = x"yes" ]; then
 
265
    echo 'Added .adb_onlock successfully.'
 
266
  else
 
267
    echo 'Failed to add .adb_onlock.'
 
268
  fi
 
269
fi
 
270
 
239
271
echo 'waiting for device to boot'
240
272
adb wait-for-device
241
 
echo 'waiting a few seconds for boot'
 
273
echo 'waiting a few more seconds for boot'
242
274
sleep 5
243
275
 
244
 
# Try to ensure adb is going to work
 
276
# Try again to ensure adb is going to work
245
277
# (may require a human to help)
246
 
if [ x$ADB = xyes ]; then
 
278
if [ x"$ADB" = x"yes"  -a  x"$ADB_ENABLED" != x"yes" ]; then
247
279
  # make sure adb shell works
248
280
  FAILED=no
249
281
  while ! adb shell echo success | grep success > /dev/null ; do
251
283
    FAILED=yes
252
284
    sleep 3
253
285
  done
254
 
  # FIXME: also should copy ~/.android/adb_key.pub to /data/misc/adb/adb_keys
 
286
  # FIXME?: also should copy ~/.android/adb_key.pub to /data/misc/adb/adb_keys
255
287
  rootcmd touch /userdata/.adb_onlock
 
288
  ADB_ENABLED=yes
256
289
  # alternate method:  (if $FAILED)
257
290
  # - adb reboot bootloader
258
291
  # - fastboot boot device/recovery.img
259
292
  # - make sure /data is mounted
260
293
  # - touch /data/.adb_onlock
261
294
  # - adb reboot
262
 
else
 
295
fi
 
296
if [ x"$ADB_ENABLED" != x"yes" ]; then
263
297
  # No ADB means we can't do anything else, so exit.
 
298
  echo 'Adb not enabled or not requested; exiting.'
264
299
  if [ x"$BEEP" = x"yes" ]; then beep ; fi
265
300
  exit 0
266
301
fi
301
336
  pushd media/photos
302
337
  for f in * ; do adb push $f /home/phablet/Pictures ; done
303
338
  popd
304
 
  adb shell 'cd /home/phablet/Photos && chown phablet.phablet *'
 
339
  adb shell 'cd /home/phablet/Pictures && chown phablet.phablet *'
305
340
fi
306
341
 
307
342
# Maybe push some extra scripts?