Merge with upstream MIUI changes and fix a lot of errors