Merge "Fix crash when unfolding a device." into tm-dev