Android启动器停止运行的调试

本文详细探讨了Android启动器在speed模式下整型转浮点数时遇到的问题,导致启动器停止运行。通过分析java源代码和Dalvik字节码,以及MIPS反汇编代码,问题定位到浮点数处理环节,目前问题待解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 一.开机时出现问题:很抱歉,”启动器“已停止运行,源码级调试如下:


日志中Java调用栈如下:

8044 03-27 15:37:40.747  3023  3039 E AndroidRuntime: FATAL EXCEPTION: setWallpaperDimension
8045 03-27 15:37:40.747  3023  3039 E AndroidRuntime: Process: com.android.launcher, PID: 3023
8046 03-27 15:37:40.747  3023  3039 E AndroidRuntime: java.lang.IllegalArgumentException: width and height must be > 0
8047 03-27 15:37:40.747  3023  3039 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:1544)
8048 03-27 15:37:40.747  3023  3039 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:1493)
8049 03-27 15:37:40.747  3023  3039 E AndroidRuntime:        at android.app.IWallpaperManager$Stub$Proxy.setDimensionHints(IWallpaperManager.java     :361)
8050 03-27 15:37:40.747  3023  3039 E AndroidRuntime:        at android.app.WallpaperManager.suggestDesiredDimensions(WallpaperManager.java:947)
8051 03-27 15:37:40.747  3023  3039 E AndroidRuntime:        at com.android.launcher2.Workspace$2.run(Workspace.java:864)


在源码中添加打印信息,修改如下:

    private float wallpaperTravelToScreenWidthRatio(int width, int height) {
//        float aspectRatio = width / (float) height;
        float h = (float) height;
        float aspectRatio = width / h;
        Log.d(TAG, "float height:" + h + "  aspectRatio:" + aspectRatio);


        final float ASPECT_RATIO_LANDSCAPE = 16/10f;
        final float ASPECT_RATIO_PORTRAIT = 10/16f;
        Log.d(TAG, "SCAPE:" + ASPECT_RATIO_LANDSCAPE + "  TRAIT:" + ASPECT_RATIO_PORTRAIT );


        final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE = 1.5f;
        final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT = 1.2f;
//        final float x =
//            (WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT) /
//            (ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT);
//        final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - x * ASPECT_RATIO_PORTRAIT;
//        Log.d(TAG, "x:" + x + "  y:" + y + "  aspectRatio:" + aspectRatio);
//        return x * aspectRatio + y;


       float lp = WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT;
       float st = ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT;
       final float x = lp / st;
       Log.d(TAG, "LANDSCAPE - PORTRAIT:"  + lp + "  SCAPE - TRAIT:" + st + "  x:" + x);


       float t = x * ASPECT_RATIO_PORTRAIT;
       final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - t;
       float xt = x * aspectRatio;
       Log.d(TAG, "t:" + t + "  y
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值