fix: catch 获取应用 meta data 时的 DeadSystemException 并上报至 sentry https://sentry.shanqu.cc/organizations/lightgame/issues/390674

Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
This commit is contained in:
chenjuntao
2024-08-15 14:26:12 +08:00
parent 2dcccc22a8
commit e19ee25839

View File

@ -12,6 +12,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.DeadSystemException;
import android.os.PowerManager;
import android.text.TextUtils;
@ -222,8 +223,19 @@ public class PackageUtils {
if (metaDate != null) {
return metaDate.get(name);
}
} catch (NameNotFoundException e) {
// e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && e instanceof DeadSystemException) {
// 有些设备会出现 DeadSystemException
SentryHelper.INSTANCE.onEvent(
"GET_META_DATA_ERROR",
"packageName",
packageName,
"exception_digest",
e.getLocalizedMessage()
);
}
}
return null;
}