Android P系统启动时间优化

1、services/core/java/com/android/server/policy/PhoneWindowManager.java

    @Override
    public boolean canDismissBootAnimation() {
        /*synchronized (mLock) {
            return mKeyguardDrawComplete;
        }*/
        return true;
    }

2、services/core/java/com/android/server/wm/WindowManagerService.java

	// Poll interval in milliseconds for watching boot animation finished.
    private static final int BOOT_ANIMATION_POLL_INTERVAL = 200;
    private static final int BOOT_ANIMATION_DELAY_INTERVAL = 2000;
if (!mBootAnimationStopped) {
    Trace.asyncTraceBegin(TRACE_TAG_WINDOW_MANAGER, "Stop bootanim", 0);
    // stop boot animation
    // formerly we would just kill the process, but we now ask it to exit so it
    // can choose where to stop the animation.
    SystemProperties.set("service.bootanim.exit", "1");
    mBootAnimationStopped = true;
}

修改成:

if(mDelayBootAnimation) {
    mDelayBootAnimation = false;
    mDelayWaiting = true;
    mH.sendEmptyMessageDelayed(H.DELAY_BOOT_ANIMATION_FINISHED,
             BOOT_ANIMATION_DELAY_INTERVAL);
} else {
    if(mDelayWaiting) return;
    if (!mBootAnimationStopped) {
        Trace.asyncTraceBegin(TRACE_TAG_WINDOW_MANAGER, "Stop bootanim", 0);
        // stop boot animation
        // formerly we would just kill the process, but we now ask it to exit so it
        // can choose where to stop the animation.
        Log.d("BootAnimation", "WMS SET service.bootanim.exit to 1");
        SystemProperties.set("service.bootanim.exit", "1");
        mBootAnimationStopped = true;
}

handleMessage中增加逻辑:

public static final int DELAY_BOOT_ANIMATION_FINISHED = 62;
case DELAY_BOOT_ANIMATION_FINISHED: {
    mDelayWaiting = false;
    performEnableScreen();
}
break;

3、frameworks\base\cmds\bootanimation\bootanim.rc

	service bootanim /system/bin/bootanimation
    class core animation
    user system
    group system audio
    disabled
    oneshot
    writepid /dev/stune/top-app/tasks

修改成:

service bootanim /system/bin/bootanimation
    class core animation
    user graphics
    group graphics audio
    oneshot
    writepid /dev/stune/top-app/tasks

4、packages\apps\Settings\src/com/android/settings/FallbackHome.java

feat:reduce delay time

    private void maybeFinish() {
        if (getSystemService(UserManager.class).isUserUnlocked()) {
            final Intent homeIntent = new Intent(Intent.ACTION_MAIN)
                    .addCategory(Intent.CATEGORY_HOME);
            final ResolveInfo homeInfo = getPackageManager().resolveActivity(homeIntent, 0);
            if (Objects.equals(getPackageName(), homeInfo.activityInfo.packageName)) {
                if (UserManager.isSplitSystemUser()
                        && UserHandle.myUserId() == UserHandle.USER_SYSTEM) {
                    // This avoids the situation where the system user has no home activity after
                    // SUW and this activity continues to throw out warnings. See b/28870689.
                    return;
                }
                Log.d(TAG, "User unlocked but no home; let's hope someone enables one soon?");
                // mHandler.sendEmptyMessageDelayed(0, 500);  modify 500ms to 100ms
                mHandler.sendEmptyMessageDelayed(0, 100);
            } else {
                Log.d(TAG, "User unlocked and real home found; let's go!");
                getSystemService(PowerManager.class).userActivity(
                        SystemClock.uptimeMillis(), false);
                finish();
            }
        }
    }

feat: remove fallbackhome anim

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set ourselves totally black before the device is provisioned so that
    // we don't flash the wallpaper before SUW
  	/* mProvisioned = Settings.Global.getInt(getContentResolver(),
            Settings.Global.DEVICE_PROVISIONED, 0) != 0;
            
    if (!mProvisioned) {
        setTheme(R.style.FallbackHome_SetupWizard);
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    } else {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    }*/


	registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
    maybeFinish();
}

@Override
protected void onResume() {
    super.onResume();
    if (mProvisioned) {
        //mHandler.postDelayed(mProgressTimeoutRunnable, PROGRESS_TIMEOUT);
    }
}

@Override
protected void onPause() {
    super.onPause();
   // mHandler.removeCallbacks(mProgressTimeoutRunnable);
}

5、cmds/bootanimation/BootAnimation.cpp

更改开机动画加载的路径:

static const char* bootFiles[] =
        {PRODUCT_BOOTANIMATION_FILE, OEM_BOOTANIMATION_FILE, SYSTEM_BOOTANIMATION_FILE};
static const char* shutdownFiles[] =
        {PRODUCT_SHUTDOWNANIMATION_FILE, OEM_SHUTDOWNANIMATION_FILE, SYSTEM_SHUTDOWNANIMATION_FILE};

modify to:

static const char* bootFiles[] =
        {SYSTEM_BOOTANIMATION_FILE, PRODUCT_BOOTANIMATION_FILE, OEM_BOOTANIMATION_FILE};
static const char* shutdownFiles[] =
        {PRODUCT_SHUTDOWNANIMATION_FILE, OEM_SHUTDOWNANIMATION_FILE, SYSTEM_SHUTDOWNANIMATION_FILE};

6、services/java/com/android/server/SystemServer.java
feat:optimize boot time

private boolean isAndroidAuto = false;

modify to:

private boolean isAndroidAuto = true;
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sunxiaolin2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值