方法|rk3568開發平臺如何去除android正在啟動彈窗

TQwangbin發表於2023-12-21

去除android正在啟動彈窗   

開機以後,裝置會有一個android is starting的彈框,該介面就是FallbackHome。

FallbackHome機制是為了在系統還沒有解鎖前先進入Setting中的android正在啟動彈窗 的頁面等系統完全解鎖後,然後進入預設Launcher但是彈窗也會影響產品效果,所以最後去掉這個彈窗不顯示在桌面桌布,直接進入Launcher。

1、延長開機動畫 在解鎖後直接進去Launcher  

在WindowManagerService.java中,註釋掉退出開機動畫的邏輯,延時開機動畫            
路徑:frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java            
           
private void performEnableScreen() {            
    synchronized (mGlobalLock) {            
        if (DEBUG_BOOT) Slog.i(TAG_WM, "performEnableScreen: mDisplayEnabled=" + mDisplayEnabled            
                + " mForceDisplayEnabled=" + mForceDisplayEnabled            
                + " mShowingBootMessages=" + mShowingBootMessages            
                + " mSystemBooted=" + mSystemBooted            
                + " mOnlyCore=" + mOnlyCore,            
                new RuntimeException("here").fillInStackTrace());            
        if (mDisplayEnabled) {            
            return;            
        }            
        if (!mSystemBooted && !mShowingBootMessages) {            
            return;            
        }            
           
        if (!mShowingBootMessages && !mPolicy.canDismissBootAnimation()) {            
            return;            
        }            
           
        // Don't enable the screen until all existing windows have been drawn.            
        if (!mForceDisplayEnabled            
                // TODO(multidisplay): Expand to all displays?            
                && getDefaultDisplayContentLocked().checkWaitingForWindows()) {            
            return;            
        }            
        //在這裡處理播放完開機動畫後是否退出開機動畫,所以註釋掉            
        //phoebe add for Extend Animation at ActivityRecord.java onWindowsDrawn start            
        /*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 (!mForceDisplayEnabled && !checkBootAnimationCompleteLocked()) {            
            if (DEBUG_BOOT) Slog.i(TAG_WM, "performEnableScreen: Waiting for anim complete");            
            return;            
        }            
        try {            
            IBinder surfaceFlinger = ServiceManager.getService("SurfaceFlinger");            
            if (surfaceFlinger != null) {            
                Slog.i(TAG_WM, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");            
                Parcel data = Parcel.obtain();            
                data.writeInterfaceToken("android.ui.ISurfaceComposer");            
                surfaceFlinger.transact(IBinder.FIRST_CALL_TRANSACTION, // BOOT_FINISHED            
                        data, null, 0);            
                data.recycle();            
            }            
        } catch (RemoteException ex) {            
            Slog.e(TAG_WM, "Boot completed: SurfaceFlinger is dead!");            
        }*/            
        //phoebe add for Extend Animation at ActivityRecord.java onWindowsDrawn end            
                    
        EventLog.writeEvent(EventLogTags.WM_BOOT_ANIMATION_DONE, SystemClock.uptimeMillis());            
        Trace.asyncTraceEnd(TRACE_TAG_WINDOW_MANAGER, "Stop bootanim", 0);            
        mDisplayEnabled = true;            
        if (DEBUG_SCREEN_ON || DEBUG_BOOT) Slog.i(TAG_WM, "******************** ENABLING SCREEN!");            
           
        // Enable input dispatch.            
        mInputManagerCallback.setEventDispatchingLw(mEventDispatchingEnabled);            
    }            
           
    try {            
        mActivityManager.bootAnimationComplete();            
    } catch (RemoteException e) {            
    }            
           
    mPolicy.enableScreenAfterBoot();            
           
    // Make sure the last requested orientation has been applied.            
    updateRotationUnchecked(false, false);            
}            
   

2、 解鎖結束後退出開機動畫在ActivityRecord中onWindowsDrawn( 退出動畫 開啟系統手勢觸控功能)  

路徑:frameworks/base/services/core/java/com/android/server/wm/ActivityRecord.java            
/** Called when the windows associated app window container are drawn. */            
public void onWindowsDrawn(boolean drawn, long timestamp) {            
    synchronized (mAtmService.mGlobalLock) {            
        mDrawn = drawn;            
        if (!drawn) {            
            return;            
        }            
        final WindowingModeTransitionInfoSnapshot info = mStackSupervisor            
                .getActivityMetricsLogger().notifyWindowsDrawn(getWindowingMode(), timestamp);            
        final int windowsDrawnDelayMs = info != null ? info.windowsDrawnDelayMs : INVALID_DELAY;            
        final @LaunchState int launchState = info != null ? info.getLaunchState() : -1;            
        mStackSupervisor.reportActivityLaunchedLocked(false /* timeout */, this,            
                windowsDrawnDelayMs, launchState);            
        mStackSupervisor.stopWaitingForActivityVisible(this);            
        finishLaunchTickingLocked();            
        if (task != null) {            
            task.hasBeenVisible = true;            
        }            
        //解鎖後退出開機動畫            
        // phoebe add for exit bootanim start            
        if (isHomeIntent(intent) && shortComponentName != null && !shortComponentName.contains("FallbackHome")) {            
            SystemProperties.set("service.bootanim.exit", "1");            
            android.util.Log.e("ActivityRecord", "real home....." + shortComponentName);            
           
            try {            
                IBinder surfaceFlinger = ServiceManager.getService("SurfaceFlinger");            
                if (surfaceFlinger != null) {            
                    Slog.i(TAG_WM, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");            
                    Parcel data = Parcel.obtain();            
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");            
                    surfaceFlinger.transact(IBinder.FIRST_CALL_TRANSACTION, // BOOT_FINISHED            
                            data, null, 0);            
                    data.recycle();            
                }            
            } catch (RemoteException ex) {            
                Slog.e(TAG, "Boot completed: SurfaceFlinger is dead!");            
            }            
        }            
        // phoebe add for exit bootanim end            
           
        //modify for performance begin            
        Bundle b = new Bundle();            
        b.putLong(ProcessInfo.KEY_LAUNCH_TIME, (long)windowsDrawnDelayMs);            
        b.putBoolean(ProcessInfo.KEY_FULLSCREEN, (task != null && task.mFullscreen));            
        mAtmService.notifyActivityStateChange(this.intent, ProcessInfo.ACTIVITY_STATE_LAUNCHDONE, b);            
        //modify for performance end            
    }            
}            

3、 去掉Settings 的Android 正在啟動… 彈窗  

//packages\apps\Settings\src\com\android\settings\FallbackHome.java            
    private final Runnable mProgressTimeoutRunnable = () -> {            
        //phoebe add for remove android is starting tips            
//        View v = getLayoutInflater().inflate(            
//                R.layout.fallback_home_finishing_boot, null /* root */);            
//        setContentView(v);            
//        v.setAlpha(0f);            
//        v.animate()            
//                .alpha(1f)            
//                .setDuration(500)            
//                .setInterpolator(AnimationUtils.loadInterpolator(            
//                        this, android.R.interpolator.fast_out_slow_in))            
//                .start();            
        getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);            
    };            

重新編譯燒錄即可!



-END-


來自 “ ITPUB部落格 ” ,連結:https://blog.itpub.net/70032144/viewspace-3000979/,如需轉載,請註明出處,否則將追究法律責任。

相關文章