Commits on Mar 10, 2017
  1. Version 3.1.N0-0

    mdmower committed Mar 9, 2017
    Change-Id: If5cc2bb9e5e97c6eb0023d02801036eebe3d510f
  2. Cleanup reboot functions and usage

    mdmower committed Feb 25, 2017
    * Split-out the actual android reboot functions into their own
      Reboot() function and use TW_Reboot()  (renamed from tw_reboot to be
      a bit more consistent in coding style) for all of the TWRP specific
    * Create Get_RebootCommand() to fetch tw_reboot_arg and translate it
      to a RebootCommand.
    * Make sure the same procedure is followed by each different method of
      rebooting the device.
    Change-Id: I5126b47f5fee8578b9c90031a02108f9cf9dc8f4
  3. Create general sleep_and_reboot page

    mdmower committed Feb 21, 2017
    * Repurpose the flash_sleep_and_reboot page for more general usage.
      Any operation (e.g. ORS) that would otherwise directly reboot the
      device without warning can optionally use this page to give users a
      notice and the option to cancel before the reboot occurs.
    * Optionally set tw_complete_text1 before entering sleep_and_reboot to
      change the header text (the sub-header contains the countdown).
    * Do not reset user-configurable option tw_install_reboot if cancel is
      pressed on the sleep_and_reboot page.
    * Go to main if cancel is pressed.
    * End sleepcounter operation more quickly when cancel is pressed by
      breaking the timer loop.
    * Do not call another sleep operation just to ensure the UI updates
      when the timer expires. Handle it in sleepcounter.
    * tw_sleep_total is a constant (perhaps configurable someday).
    Change-Id: I7d2dddad329a84791210f7952db4f64f4de7f87f
  4. Support sideload-auto-reboot

    mdmower committed Feb 25, 2017
    * Recent versions of adb support sideload-auto-reboot with the
      description: "reboots into the sideload mode, then reboots
      automatically after the sideload regardless of the result."
    Change-Id: I3b1869f5779276b89b2799c943e9a1a34da8616e
  5. Lang: Degree symbol is fine in XML

    mdmower committed Feb 18, 2017
    Change-Id: If8f1263cc8df05a77874f2ae0d0c9703949f4e25
  6. Disable encrypted backups

    mdmower committed Feb 26, 2017
    Encrypted backups are poorly implemented (both by TWRP for padding a
    password with zeros to achieve an AES key and openaes for using
    non-standard CBC) and not to be trusted. Do not give users a false
    sense of security by offering this option. Remove the ability to use
    openaes to encrypt backups, but still allow already openaes-encrypted
    backups to be restored.
    Ref: TeamWin/Team-Win-Recovery-Project#817
    Change-Id: Ibc1802372d8caa8c475039e66fb08ce163df27e9
  7. Revert "Default to disabling encrypted backups"

    mdmower committed Feb 27, 2017
    This reverts commit 9cc66d7.
    Change-Id: I5178caf02cd6c2d3cf038856dca5fed33c59ce18
  8. Remove stray prebuilts

    mdmower committed Feb 25, 2017
    * Leftovers from removal of SuperSU, HTC Dumlock, parted,
    Change-Id: Ib674693820130a3edda57b0fe66ee8550e793c01
Commits on Mar 9, 2017
  1. vold_decrypt: Add back missing xml and get rid of compiler warning

    nkk71 authored and mdmower committed Mar 6, 2017
    Change-Id: I883112e2618f560e96002e2076e2735cc20cfac3
  2. crypto: Use system's vold for decryption

    nkk71 authored and mdmower committed Jan 5, 2017
      If TWRP crypto fails to decrypt partition, mount the system
      partition and use system's own vold to attempt decryption.
      This provides a fallback for proprietary OEM encryption as well as
      encryption methods which TWRP hasn't been updated for.
      Requirements in device tree:
      * fstab.{ro.hardware} in device/recovery/root
        The fstab does not need to be complete, but it does need the
        data partition and the encryption entries.
      * 'TW_CRYPTO_USE_SYSTEM_VOLD := true' in BoardConfig
      * 'TW_CRYPTO_USE_SYSTEM_VOLD := <list of services>'
      * Setting the flag to 'true' will just use system's vdc+vold
      * Setting the flag with additional services, will also start them
        prior to attempting vdc+vold decryption, eg: for qualcomm based
        devices you usually need 'TW_CRYPTO_USE_SYSTEM_VOLD := qseecomd'
      * For each service listed an additional import will be automatically
        added to the vold_decrypt.rc file in the form of
        You will need to add any not already existing .rc files in
        your device/recovery/root folder.
      * The service names specified in the vold_decrypt.{service}.rc files
        have to be named 'sys_{service}'
        eg: 'service sys_qseecomd /system/bin/qseecomd'
      * Any service already existing in TWRP as {service} or sbin{service} will
        be stopped and restarted as needed.
      * You can override the default init.recovery.vold_decrypt.rc file(s)
        by placing same named ones in your device/recovery/root folder.
        If you do, you'll need to manually add the needed imports.
      * If /vendor and /firmware folders are temporarily moved and symlinked
        to the folders and files in the system partition, the properties
        'vold_decrypt.symlinked_vendor' and 'vold_decrypt.symlinked_firmware'
        will be set to 1.
        This allows for additional control in the .rc files for any extra
        actions (symlinks, cp files, etc) that may be needed for decryption
        by using: on property:vold_decrypt.symlinked_vendor=1 and/or
        on property:vold_decrypt.symlinked_firmware=1 triggers.
      Debug mode: 'TW_CRYPTO_SYSTEM_VOLD_DEBUG := true' in BoardConfig
      * Specifying this flag, will enable strace on init and vdc, which will
        create separate log files in /tmp for every process created, allowing
        for detailed analysis of which services and files are being accessed.
      * Note that enabling strace will expose the password in the logs!!
      * You need to manually add strace to your build.
    Thanks to @Captain_Throwback for co-authoring and testing.
    Tested successfully on HTC devices:
    M8 (KK through MM), M9 (MM and N), A9 (N), 10 (N), Bolt (N),
    Desire 626s (MM), U Ultra (N)
    HTC One X9 (MTK device)
    And by Nikolay Jeliazkov on: Xiaomi Mi Max
    Change-Id: I4d22ab55baf6a2a50adde2e4c1c510c142714227
  3. file_contexts: remove symlink to binary file and use text version ins…

    CaptainThrowback authored and mdmower committed Mar 7, 2017
    Some older update binaries can't read the binary file_contexts, so include
    the text version of the file to prevent errors. This removes the symlink
    to the binary version of the file and uses the concatenated file_contexts
    from the OUT build folder.
    Change-Id: Ia57c9b47c95945721d3dfa1ec8e18c4bb199adff
  4. Timeout for decrypt

    Dees-Troy authored and mdmower committed Jan 19, 2017
    Sometimes, usually because of proprietary binaries related to keymaster,
    decrypt will hang waiting for the keymaster to initialize forever. This patch
    enables a timeout so that we don't get stuck trying to decrypt forever.
    A timeout is especially important when dealing with the default password
    because the user has no option to cancel when TWRP tries to decrypt.
    NOTE: This patch only adds a timeout for FDE. FBE will require some special
    handling because we need access to some static data and that data is not
    available across a fork.
    Special thanks to nkk71 for cleaning up some issues in my patch set.
    Change-Id: Iccf2fe769ac27a7dcd6bfebfe7d2e9eddd034308
  5. gui: preserve order of gui_print vs gui_msg

    that1 authored and mdmower committed Feb 23, 2017
    - rename __gui_print to internal_gui_print (__* is reserved for compiler)
    - translate outstanding messages in internal_gui_print
    - add locking because background thread could print while we render
    - minor cleanup
    Change-Id: Ib687d2cfb4763ad08ad4d4b76daf5b129d61d2e2
  6. twrpDigest: don't crash when zip.md5 file is empty

    that1 authored and mdmower committed Feb 23, 2017
    Change-Id: I14145b32c7993bb0cd236b2982ed00bc2c791282
Commits on Feb 24, 2017
  1. Run from inside languages dir

    mdmower committed Feb 18, 2017 and make different assumptions about
    the directory from which they are called. Assume the script is run from
    within the languages directory for both.
    Change-Id: I4207919360d82dcd3cfbdebcff38f0e872554744
  2. Tweak MTP startup routine

    mdmower committed Feb 16, 2017
    * As a precaution, (non-permanently) disable MTP if TWRP crashes.
    * Remove a duplicate logging of 'Starting MTP'.
    * Combine and improve readability of conditions before MTP starts.
    * Remove unnecessary Disable_MTP() call if conditions unsatisfied.
    Change-Id: I61ac772fc123da5b84c3061fbcf2116531bc4e2f
  3. Improve handling of USB config during MTP switching

    mdmower committed Feb 23, 2017
    It is possible that devices could run into issues with MTP startup due
    to sys.usb.config not yet being set. This is actually due to a poor
    design decision in Enable_MTP(), where sys.usb.config would not be
    configured for mtp if sys.usb.config had never been set. It is not
    necessary to check for a previous value, just set it.
    Fix the USB PID for adb-only mode in Disable_MTP().
    Change-Id: I21b5e64c9bdcd3104372a8b4eb8ea50cf4561892
Commits on Feb 22, 2017
  1. Fix "ordered comparison between pointer and zero".

    MinSeong Kim authored and mdmower committed Nov 11, 2016
    From Clang 4.x releases, DR583 and DR1512 will be addressed.
    This patch, in advance, fixes the error(s).
    Test: `mmma bootable/recovery`
    Change-Id: I29dc85ae681307c322ab3a698c3f3bbad1c784ee
    Signed-off-by: MinSeong Kim <>
  2. cryptfs: Fix encryption issue due to stack corruption.

    nijel8 authored and mdmower committed Feb 19, 2017
    Ioctl BLKGETSIZE expects pointer to unsigned long as argument.
    On 64bit target using pointer to unsigned int can cause stack
    corruption due to type mismatch.
    props to aopp/android_system_vold@f8b8787
    Change-Id: I1d76c65e29479c8f0cd44b6892069b21b8249b95
  3. Use LOGI/LOGE for non-EVENT_LOGGING events

    mdmower committed Feb 13, 2017
    Change-Id: Iaebc613a25a727a91205d2f361e9d7719036d88d
  4. Add a listxattr tool for listing xattrs

    Dees-Troy authored and mdmower committed Feb 3, 2017
    Change-Id: Ib80bab2b605ce77cd8fdc717d8bcfa8085516679
  5. libtar: support backing up and restoring new Android user.* xattr

    Dees-Troy authored and mdmower committed Feb 3, 2017
    Support for backing up and restoring user.default, user.inode_cache, and
    user.inode_code_cache xattrs introduced in Android 7.x
    Change-Id: I6e0aa7fc9cd30ed004ef28ebb58d60a82e518123
Commits on Feb 18, 2017
  1. Update MTP debugging tags

    mdmower committed Feb 15, 2017
    Change-Id: I8cf8b32d5a98ac2470386cbaf70cfc87f44e94f6
  2. Only change USB mode to mtp when ready for MTP

    mdmower committed Feb 15, 2017
    Commit 'Do not toggle USB ID during MTP startup if not needed' changed
    the default USB mode to 'mtp,adb'. Depending on the device, this can
    result in an unfortunate side effect of crashing an ORS sideload
    midway through the process (it's not clear to me whether the kernel or
    the connected computer is responsible). Only put USB into mtp mode
    when MTP storage is starting-up.
    The hack to change the USB mode to adb when a user compiles TWRP
    without MTP support is no longer necessary now that 'adb' is the
    startup mode.
    Change-Id: I8ed13d6ab8e85621533997b8c37ef7ebec0fcf85
  3. Do not unconditionally remove MTP storage on unmount

    mdmower committed Feb 15, 2017
    * It is not necessary to Remove_MTP_Storage() for a partition if an
      MTP_Storage_ID has not been assigned.
    * The hack to force-set tw_mtp_enabled=1 should no longer be necessary
      now that we're checking whether MTP really needs to be disabled for
      a volume before running Disable_MTP().
    Change-Id: I1b7233eedd9da7c6be0c67fc60243f3837105173
  4. Partition: Remove unused has_data_media variable

    mdmower committed Feb 15, 2017
    Change-Id: Ic1a3aa2b57db5539ce6f6740a63bfe6d33890d70
  5. Symlink file_contexts --> file_contexts.bin

    mdmower committed Feb 18, 2017
    The presence of /file_contexts is still important to TWRP:
    - files written while in adb shell only pick up contexts if
      /file_contexts is present
    - fixContexts looks for /file_contexts
    - if !USE_EXT4 (is this possible), then make_ext4fs looks for
      /file_contexts when wiping
    In the event than file_contexts.bin also becomes more important in the
    future, leave it in place and create a symlink to it.
    Change-Id: Ic87852248d42d5ea6bf936df160efa41294b6520
Commits on Feb 13, 2017
  1. Version 3.0.N2-0

    mdmower committed Feb 13, 2017
Commits on Feb 12, 2017
  1. Fix bldr msg file open mode when offset specified

    mdmower committed Feb 12, 2017
    It was pointed out to me by gmrt that O_APPEND is incorrect, as lseek
    before writing would be undone (perhaps we avoided this issue due to
    an inability to write beyond the end of a partition) and O_RDWR is not
    necessary to lseek. When AOSP switched from fopen to open, they also
    removed the full partition wipe (fopen in wb mode) before each write,
    so this is no longer an issue. Completely restore the original AOSP
    file access mode flags.
    Change-Id: I42b4efc5f499360ce5b761d3a2a5d4dac4cdfb65
  2. Lang: update German

    z31s1g authored and mdmower committed Feb 12, 2017
  3. Lang: update Chinese

    kaneawk authored and mdmower committed Dec 28, 2016
  4. Lang: update Russian

    SevenMaxs authored and mdmower committed Dec 21, 2016
  5. Lang: update Italian

    CastagnaIT authored and mdmower committed Feb 10, 2017
Commits on Feb 9, 2017
  1. GUI: Improve automatic determination of TW_THEME

    mdmower committed Jan 19, 2017
    * If TW_THEME is not defined, then check both DEVICE_RESOLUTION and
      the determined width and height to automatically select landscape,
      portrait, or watch, as well as associated mdpi/hdpi.
    * Improve the display of the error message so it fits in a standard 80
      character width terminal without line wraps.
    * Write relevant errors for missing themes that clarify what went
    Change-Id: I94b02349ce38bf6a9cecde403d78ff2490821d8a