Skip to content

Commit e113a55

Browse files
committed
Update
1 parent a1fac94 commit e113a55

6 files changed

Lines changed: 227 additions & 108 deletions

File tree

.github/module/termux/py/ext4.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -845,15 +845,12 @@ def xattrs(self, check_inline=True, check_block=True, force_inline=False, prefix
845845

846846
xattrs_header = ext4_xattr_header.from_buffer_copy(xattrs_block)
847847
if not self.volume.ignore_magic and xattrs_header.h_magic != 0xEA020000:
848-
try:
849-
raise MagicError(
850-
"Invalid magic value in xattrs block header at offset 0x{xattrs_block_start:X} of inode {inode:d}: 0x{xattrs_header} (expected 0xEA020000)".format(
851-
inode=self.inode_idx,
852-
xattrs_block_start=xattrs_block_start,
853-
xattrs_header=xattrs_header.h_magic
854-
))
855-
except:
856-
pass
848+
raise MagicError(
849+
"Invalid magic value in xattrs block header at offset 0x{xattrs_block_start:X} of inode {inode:d}: 0x{xattrs_header} (expected 0xEA020000)".format(
850+
inode=self.inode_idx,
851+
xattrs_block_start=xattrs_block_start,
852+
xattrs_header=xattrs_header.h_magic
853+
))
857854

858855
if xattrs_header.h_blocks != 1:
859856
raise Ext4Error(
@@ -960,4 +957,4 @@ def seek(self, seek, seek_mode=io.SEEK_SET):
960957
return seek
961958

962959
def tell(self):
963-
return self.cursor
960+
return self.cursor

.github/module/termux/py/img2sdat.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def main(INPUT_IMAGE, OUTDIR='.', VERSION=None, PREFIX='system'):
6161
# Get sparse image
6262
image = sparse_img.SparseImage(INPUT_IMAGE, tempfile.mkstemp()[1], '0')
6363

64+
# blockimgdiff needs common.OPTIONS.cache_size to size its stash/transfer
65+
# logic correctly. img2sdat never sets it, so it silently defaults to
66+
# None and blockimgdiff falls back to a hard-coded 100MB with a warning
67+
# ("Cache size is not set, defaulting to a fallback size."). Set it
68+
# explicitly here so the warning goes away and stash sizing is correct.
69+
if common.OPTIONS.cache_size is None:
70+
common.OPTIONS.cache_size = 100 * 1024 * 1024 # 100MB, safe default
71+
6472
# Generate output files
6573
b = blockimgdiff.BlockImageDiff(image, None, VERSION)
6674
b.Compute(OUTDIR)
@@ -96,4 +104,4 @@ def main(INPUT_IMAGE, OUTDIR='.', VERSION=None, PREFIX='system'):
96104
else:
97105
PREFIX = 'system'
98106

99-
main(INPUT_IMAGE, OUTDIR, VERSION, PREFIX)
107+
main(INPUT_IMAGE, OUTDIR, VERSION, PREFIX)

.github/module/termux/py/mke2fs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ def main(argv):
232232

233233
# run mke2fs
234234
with tempfile.NamedTemporaryFile() as conf_file:
235-
conf_path = os.path.expandvars("$ETC/mke2fs.conf")
236-
with open(conf_path, "rb") as f:
237-
conf_file.write(f.read())
238-
conf_file.flush()
239-
mke2fs_env = {"MKE2FS_CONFIG": conf_file.name}
235+
conf_path = os.path.expandvars("$ETC/mke2fs.conf")
236+
with open(conf_path, "rb") as f:
237+
conf_file.write(f.read())
238+
conf_file.flush()
239+
mke2fs_env = {"MKE2FS_CONFIG": conf_file.name}
240240

241241
if args.timestamp:
242242
mke2fs_env["E2FSPROGS_FAKE_TIME"] = args.timestamp
@@ -263,4 +263,4 @@ def main(argv):
263263

264264

265265
if __name__ == '__main__':
266-
main(sys.argv[1:])
266+
main(sys.argv[1:])

app/src/main/assets/home/bin/repack_img

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ if [[ "$partition" =~ ^(erofs|f2fs|ext)$ ]]; then
332332
zstd --progress -f -$lvnen --format=$FORMATS --compress "$saved" -o "${out_saved%.*}.img.$CONVER" 2>&1 | tee "$TMP/repzstd.log" || killtree "Conver $FORMATS error"
333333
elif [ "$CONVER" == 'dat' ] || [ "$CONVER" == 'br' ]; then
334334
img2simg "$saved"
335+
echo 1
335336
img2sdat "$saved" -o "$OUTPUT/out" -v 4 -p "${INPUT##*/}" >$TMP/img2sdat.log
337+
echo 2
336338
[ -f "$OUTPUT/out/${INPUT##*/}.new.dat" ] || killtree "Error creating file ${INPUT##*/}.new.dat failed"
337339
if [ "$CONVER" == 'br' ]; then
338340
LEVEL="$(echo "$lvnen / 2" | bc)"

app/src/main/java/com/omarea/common/ui/DialogHelper.kt

Lines changed: 73 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import androidx.core.graphics.drawable.toDrawable
2121
import com.tool.tree.ThemeModeState
2222
import android.graphics.Bitmap
2323
import android.graphics.drawable.BitmapDrawable
24+
import java.util.concurrent.ExecutorService
25+
import java.util.concurrent.Executors
2426

2527
class DialogHelper {
2628
class DialogButton(val text: String, val onClick: Runnable? = null, val dismiss: Boolean = true)
@@ -75,6 +77,11 @@ class DialogHelper {
7577
// 是否禁用模糊背景
7678
var disableBlurBg = false
7779

80+
// Dùng chung 1 thread nền cho việc xử lý blur ảnh nền dialog, tránh tạo/hủy thread
81+
// mới mỗi lần mở dialog. Việc blur (GPU RenderEffect hoặc CPU StackBlur) không đụng
82+
// tới View hierarchy nên chạy an toàn ở đây, tách khỏi main thread.
83+
private val blurExecutor: ExecutorService = Executors.newSingleThreadExecutor()
84+
7885
fun animDialog(dialog: AlertDialog?): DialogWrap? {
7986
if (dialog != null && !dialog.isShowing) {
8087
dialog.window?.run {
@@ -402,38 +409,78 @@ class DialogHelper {
402409
return ThemeModeState.isDarkMode()
403410
}
404411

412+
// Nền fallback (màu đặc theo theme, hoặc dim nếu là dialog dạng floating).
413+
// Tách riêng để có thể hiện ngay lập tức, không phải đợi bước blur ảnh nền phía sau.
414+
private fun applyFallbackWindowBg(window: Window, activity: Activity, wallpaperMode: Boolean) {
415+
window.run {
416+
try {
417+
val bg = getWindowBackground(activity)
418+
if (bg == Color.TRANSPARENT) {
419+
if (isFloating) {
420+
setBackgroundDrawable(bg.toDrawable())
421+
setDimAmount(0.8f)
422+
return
423+
} else {
424+
val d = if (wallpaperMode || isNightMode(context)) {
425+
Color.argb(255, 18, 18, 18).toDrawable()
426+
} else {
427+
Color.argb(255, 245, 245, 245).toDrawable()
428+
}
429+
setBackgroundDrawable(d)
430+
}
431+
} else {
432+
setBackgroundDrawable(bg.toDrawable())
433+
}
434+
} catch (_: Exception) {
435+
setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
436+
}
437+
}
438+
}
439+
405440
// Trong setWindowBlurBg
406441
fun setWindowBlurBg(window: Window, activity: Activity) {
407442
val wallpaperMode = activity.window.attributes.flags and WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER != 0
408-
window.run {
409-
val blurBitmap = if (disableBlurBg) {
443+
444+
// Hiện nền fallback NGAY LẬP TỨC để dialog xuất hiện tức thì. Nếu blur bật và
445+
// thành công, nền này sẽ được thay bằng ảnh mờ ngay khi xử lý xong ở bước dưới -
446+
// đánh đổi một nhịp hiện nền tạm để đổi lấy việc không giật main thread khi mở
447+
// dialog như cách làm đồng bộ trước đây.
448+
applyFallbackWindowBg(window, activity, wallpaperMode)
449+
450+
if (disableBlurBg) return
451+
452+
// Bước chụp BẮT BUỘC chạy trên main thread vì cần view.draw() với view hierarchy
453+
// hiện tại. Nhờ chụp trực tiếp ở CAPTURE_SCALE (10%) thay vì full-res nên bước
454+
// này rất nhẹ, không đáng kể tới hiệu năng main thread.
455+
val smallBmp = FastBlurUtility.takeScreenShot(activity, FastBlurUtility.CAPTURE_SCALE) ?: return
456+
457+
val decorView = window.decorView
458+
val targetW = decorView.width
459+
val targetH = decorView.height
460+
if (targetW <= 0 || targetH <= 0) {
461+
if (!smallBmp.isRecycled) smallBmp.recycle()
462+
return
463+
}
464+
465+
// Phần xử lý blur (GPU RenderEffect / CPU StackBlur + phóng to) là phần nặng thực
466+
// sự và không đụng tới View hierarchy, nên chạy an toàn trên background thread -
467+
// đây chính là phần trước đây làm main thread bị giật mỗi khi mở dialog.
468+
blurExecutor.execute {
469+
val blurred = try {
470+
FastBlurUtility.blurCapturedBitmap(smallBmp, targetW, targetH)
471+
} catch (e: Throwable) {
410472
null
411-
} else {
412-
FastBlurUtility.getBlurBackgroundDrawer(activity)
413473
}
414-
if (blurBitmap != null) {
415-
setBackgroundDrawable(blurBitmap.toDrawable(activity.resources))
416-
} else {
417-
try {
418-
val bg = getWindowBackground(activity)
419-
if (bg == Color.TRANSPARENT) {
420-
if (isFloating) {
421-
setBackgroundDrawable(bg.toDrawable())
422-
setDimAmount(0.8f)
423-
return
424-
} else {
425-
val d = if (wallpaperMode || isNightMode(context)) {
426-
Color.argb(255, 18, 18, 18).toDrawable()
427-
} else {
428-
Color.argb(255, 245, 245, 245).toDrawable()
429-
}
430-
setBackgroundDrawable(d)
431-
}
432-
} else {
433-
setBackgroundDrawable(bg.toDrawable())
474+
if (blurred != null) {
475+
decorView.post {
476+
// Dialog có thể đã bị dismiss / activity đã finish trong lúc blur chạy
477+
// nền -> luôn kiểm tra lại trước khi set background để tránh crash
478+
// hoặc rò rỉ view/bitmap.
479+
if (!activity.isFinishing && decorView.isAttachedToWindow) {
480+
window.setBackgroundDrawable(blurred.toDrawable(activity.resources))
481+
} else if (!blurred.isRecycled) {
482+
blurred.recycle()
434483
}
435-
} catch (_: Exception) {
436-
setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
437484
}
438485
}
439486
}

0 commit comments

Comments
 (0)