Android Launcher3各启动场景源码分析

news2024/11/17 5:52:57

文章目录

  • 一、概述
  • 二、开机启动Launcher
    • 2.1、开机启动Launcher流程图
    • 2.2、开机启动流程源码分析
  • 三、短压Home键启动Launcher
    • 3.1、短压Home键启动Launcher流程图
    • 3.2、短压Home键启动Launcher源码分析
  • 四、Launcher异常崩溃后的自启动
    • 4.1、Launcher异常崩溃后的自启动流程图
    • 4.2、Launcher异常崩溃后的自启动源码分析


  团队博客: 汽车电子社区


一、概述

  Launcher3是Android系统提供的默认桌面应用(Launcher),它的源码路径在**“packages/apps/Launcher3/”**。Launcher3的启动场景主要包括:
    1、开机后启动:开机时,android ams服务拉起Launcher。
    2、按键启动:比如短压home键,android wms中的PhoneWindowManager拉起Launcher。
    3、异常崩溃后启动:Launcher异常崩溃后,android ams再次拉起Launcher。
  针对这三种情况,分析一下Aosp源码如何实现。

二、开机启动Launcher

2.1、开机启动Launcher流程图

在这里插入图片描述

2.2、开机启动流程源码分析

  Launcher的开机启动由Android的AMS服务完成。AMS在SystemReady阶段会调用startHomeOnAllDisplays函数。Android支持多Display(虚拟Display或者由硬件上报的实际Display),多Display情况下一般Launcher会针对不同Display做不同的效果。

// frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
public void systemReady(final Runnable goingCallback, TimingsTraceLog traceLog) {
    traceLog.traceBegin("PhaseActivityManagerReady");
    synchronized(this) {
        if (mSystemReady) {
            // If we're done calling all the receivers, run the next "boot phase" passed in
            // by the SystemServer
            if (goingCallback != null) {
                goingCallback.run();
            }
            return;
        }

        mLocalDeviceIdleController
                = LocalServices.getService(DeviceIdleController.LocalService.class);
        mActivityTaskManager.onSystemReady();
        // Make sure we have the current profile info, since it is needed for security checks.
        mUserController.onSystemReady();
        mAppOpsService.systemReady();
        mSystemReady = true;
    }

    try {
        sTheRealBuildSerial = IDeviceIdentifiersPolicyService.Stub.asInterface(
                ServiceManager.getService(Context.DEVICE_IDENTIFIERS_SERVICE))
                .getSerial();
    } catch (RemoteException e) {}

    ArrayList<ProcessRecord> procsToKill = null;
    synchronized(mPidsSelfLocked) {
        for (int i=mPidsSelfLocked.size()-1; i>=0; i--) {
            ProcessRecord proc = mPidsSelfLocked.valueAt(i);
            if (!isAllowedWhileBooting(proc.info)){
                if (procsToKill == null) {
                    procsToKill = new ArrayList<ProcessRecord>();
                }
                procsToKill.add(proc);
            }
        }
    }

    synchronized(this) {
        if (procsToKill != null) {
            for (int i=procsToKill.size()-1; i>=0; i--) {
                ProcessRecord proc = procsToKill.get(i);
                Slog.i(TAG, "Removing system update proc: " + proc);
                mProcessList.removeProcessLocked(proc, true, false, "system update done");
            }
        }

        // Now that we have cleaned up any update processes, we
        // are ready to start launching real processes and know that
        // we won't trample on them any more.
        mProcessesReady = true;
    }

    Slog.i(TAG, "System now ready");
    EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_AMS_READY, SystemClock.uptimeMillis());

    mAtmInternal.updateTopComponentForFactoryTest();
    mAtmInternal.getLaunchObserverRegistry().registerLaunchObserver(mActivityLaunchObserver);

    watchDeviceProvisioning(mContext);

    retrieveSettings();
    mUgmInternal.onSystemReady();

    final PowerManagerInternal pmi = LocalServices.getService(PowerManagerInternal.class);
    if (pmi != null) {
        pmi.registerLowPowerModeObserver(ServiceType.FORCE_BACKGROUND_CHECK,
                state -> updateForceBackgroundCheck(state.batterySaverEnabled));
        updateForceBackgroundCheck(
                pmi.getLowPowerState(ServiceType.FORCE_BACKGROUND_CHECK).batterySaverEnabled);
    } else {
        Slog.wtf(TAG, "PowerManagerInternal not found.");
    }

    if (goingCallback != null) goingCallback.run();
    // Check the current user here as a user can be started inside goingCallback.run() from
    // other system services.
    final int currentUserId = mUserController.getCurrentUserId();
    Slog.i(TAG, "Current user:" + currentUserId);
    if (currentUserId != UserHandle.USER_SYSTEM && !mUserController.isSystemUserStarted()) {
        // User other than system user has started. Make sure that system user is already
        // started before switching user.
        throw new RuntimeException("System user not started while current user is:"
                + currentUserId);
    }
    traceLog.traceBegin("ActivityManagerStartApps");
    mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_RUNNING_START,
            Integer.toString(currentUserId), currentUserId);
    mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START,
            Integer.toString(currentUserId), currentUserId);

    // On Automotive, at this point the system user has already been started and unlocked,
    // and some of the tasks we do here have already been done. So skip those in that case.
    // TODO(b/132262830): this workdound shouldn't be necessary once we move the
    // headless-user start logic to UserManager-land
    final boolean bootingSystemUser = currentUserId == UserHandle.USER_SYSTEM;

    if (bootingSystemUser) {
        mSystemServiceManager.startUser(currentUserId);
    }

    synchronized (this) {
        // Only start up encryption-aware persistent apps; once user is
        // unlocked we'll come back around and start unaware apps
        startPersistentApps(PackageManager.MATCH_DIRECT_BOOT_AWARE);

        // Start up initial activity.
        mBooting = true;
        // Enable home activity for system user, so that the system can always boot. We don't
        // do this when the system user is not setup since the setup wizard should be the one
        // to handle home activity in this case.
        if (UserManager.isSplitSystemUser() &&
                Settings.Secure.getInt(mContext.getContentResolver(),
                     Settings.Secure.USER_SETUP_COMPLETE, 0) != 0) {
            ComponentName cName = new ComponentName(mContext, SystemUserHomeActivity.class);
            try {
                AppGlobals.getPackageManager().setComponentEnabledSetting(cName,
                        PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0,
                        UserHandle.USER_SYSTEM);
            } catch (RemoteException e) {
                throw e.rethrowAsRuntimeException();
            }
        }

        if (bootingSystemUser) {
            // 启动Home,也就是Launcher
            mAtmInternal.startHomeOnAllDisplays(currentUserId, "systemReady");
        }

        mAtmInternal.showSystemReadyErrorDialogsIfNeeded();

        if (bootingSystemUser) {
            final int callingUid = Binder.getCallingUid();
            final int callingPid = Binder.getCallingPid();
            long ident = Binder.clearCallingIdentity();
            try {
                Intent intent = new Intent(Intent.ACTION_USER_STARTED);
                intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
                        | Intent.FLAG_RECEIVER_FOREGROUND);
                intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
                broadcastIntentLocked(null, null, intent,
                        null, null, 0, null, null, null, OP_NONE,
                        null, false, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
                        currentUserId);
                intent = new Intent(Intent.ACTION_USER_STARTING);
                intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
                intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
                broadcastIntentLocked(null, null, intent,
                        null, new IIntentReceiver.Stub() {
                            @Override
                            public void performReceive(Intent intent, int resultCode, String data,
                                    Bundle extras, boolean ordered, boolean sticky, int sendingUser)
                                    throws RemoteException {
                            }
                        }, 0, null, null,
                        new String[] {INTERACT_ACROSS_USERS}, OP_NONE,
                        null, true, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
                        UserHandle.USER_ALL);
            } catch (Throwable t) {
                Slog.wtf(TAG, "Failed sending first user broadcasts", t);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        } else {
            Slog.i(TAG, "Not sending multi-user broadcasts for non-system user "
                    + currentUserId);
        }
        mAtmInternal.resumeTopActivities(false /* scheduleIdle */);
        if (bootingSystemUser) {
            mUserController.sendUserSwitchBroadcasts(-1, currentUserId);
        }

        BinderInternal.nSetBinderProxyCountWatermarks(BINDER_PROXY_HIGH_WATERMARK,
                BINDER_PROXY_LOW_WATERMARK);
        BinderInternal.nSetBinderProxyCountEnabled(true);
        BinderInternal.setBinderProxyCountCallback(
                new BinderInternal.BinderProxyLimitListener() {
                    @Override
                    public void onLimitReached(int uid) {
                        Slog.wtf(TAG, "Uid " + uid + " sent too many Binders to uid "
                                + Process.myUid());
                        BinderProxy.dumpProxyDebugInfo();
                        if (uid == Process.SYSTEM_UID) {
                            Slog.i(TAG, "Skipping kill (uid is SYSTEM)");
                        } else {
                            killUid(UserHandle.getAppId(uid), UserHandle.getUserId(uid),
                                    "Too many Binders sent to SYSTEM");
                        }
                    }
                }, mHandler);

        traceLog.traceEnd(); // ActivityManagerStartApps
        traceLog.traceEnd(); // PhaseActivityManagerReady
    }
}

  调用ActivityTaskManagerInternal类型的接口startHomeOnAllDisplays,这个接口ActivityTaskManagerService.java文件中实现。

// android/frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
final class LocalService extends ActivityTaskManagerInternal {
    @Override
    public boolean startHomeOnAllDisplays(int userId, String reason) {
        synchronized (mGlobalLock) {
            // 这个对象是RootActivityContainer类型
            return mRootActivityContainer.startHomeOnAllDisplays(userId, reason);
        }
    }
}

  接下来调用RootActivityContainer的接口startHomeOnAllDisplays,第二个参数reson的值为“systemReady”。

// frameworks/base/services/core/java/com/android/server/wm/RootActivityContainer.java
boolean startHomeOnAllDisplays(int userId, String reason) {
    boolean homeStarted = false;
    for (int i = mActivityDisplays.size() - 1; i >= 0; i--) {
        final int displayId = mActivityDisplays.get(i).mDisplayId;
        homeStarted |= startHomeOnDisplay(userId, reason, displayId);
    }
    return homeStarted;
}

  遍历mActivityDisplays对于所有处于Active状态的Display调用startHomeOnDisplay,在每个Display上都启动Home(Launcher)。

boolean startHomeOnDisplay(int userId, String reason, int displayId) {
    // allowInstrumenting :false
    // fromHomeKey : false
    return startHomeOnDisplay(userId, reason, displayId, false /* allowInstrumenting */,
            false /* fromHomeKey */);
}
    
boolean startHomeOnDisplay(int userId, String reason, int displayId, boolean allowInstrumenting,
        boolean fromHomeKey) {
    // 如果DisplayID是非法的,使用当前处于顶层焦点的 Display
    // Fallback to top focused display if the displayId is invalid.
    if (displayId == INVALID_DISPLAY) {
        displayId = getTopDisplayFocusedStack().mDisplayId;
    }
    
    // 构建一个Intent
    Intent homeIntent = null;
    ActivityInfo aInfo = null;
    if (displayId == DEFAULT_DISPLAY) {
        // 如果DisplayID是默认的Display(一般是主屏)
        // 调用ActivityTaskManagerService的getHomeIntent,拿到用来启动Home的Intent
        homeIntent = mService.getHomeIntent();
        // 查找当前系统里包含 android.intent.category.HOME的Activity。
        // 择优选择使用哪个Activity
        aInfo = resolveHomeActivity(userId, homeIntent);
    } else if (shouldPlaceSecondaryHomeOnDisplay(displayId)) {
        // 如果不是默认Display屏幕
        Pair<ActivityInfo, Intent> info = resolveSecondaryHomeActivity(userId, displayId);
        aInfo = info.first;
        homeIntent = info.second;
    }
    if (aInfo == null || homeIntent == null) {
        return false;
    }
    
    // 判断是否运行启动Home
    if (!canStartHomeOnDisplay(aInfo, displayId, allowInstrumenting)) {
        return false;
    }

    // 更新Home Intent
    // Updates the home component of the intent.
    homeIntent.setComponent(new ComponentName(aInfo.applicationInfo.packageName, aInfo.name));
    homeIntent.setFlags(homeIntent.getFlags() | FLAG_ACTIVITY_NEW_TASK);
    // 如果是从HomeKey启动的,添加额外参数、
    // Updates the extra information of the intent.
    if (fromHomeKey) {
        homeIntent.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, true);
    }
    // Update the reason for ANR debugging to verify if the user activity is the one that
    // actually launched.
    final String myReason = reason + ":" + userId + ":" + UserHandle.getUserId(
            aInfo.applicationInfo.uid) + ":" + displayId;
    // 启动Home
    mService.getActivityStartController().startHomeActivity(homeIntent, aInfo, myReason,
            displayId);
    return true;
}

  startHomeOnDisplay函数中查询当前系统中包含 android.intent.category.HOME信息的Activity(resolveHomeActivity),如果找到了多个Activity则选择高优先级的。根据查找的Activity信息构建Intent,使用ActivityTaskManagerService的ActivityStartController启动Home对应的Activity。
  getHomeIntent函数在ActivityTaskManagerService中实现。

// frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
Intent getHomeIntent() {
        // String mTopAction = Intent.ACTION_MAIN;
    Intent intent = new Intent(mTopAction, mTopData != null ? Uri.parse(mTopData) : null);
    intent.setComponent(mTopComponent);
    intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
    if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
            // 非FactoryTest模式下走这里。
            // android.intent.category.HOME
        intent.addCategory(Intent.CATEGORY_HOME);
    }
    return intent;
}

  resolveHomeActivity函数用于查找包含android.intent.category.HOME信息的Activity。实现上是通过PMS完成的。

// frameworks/base/services/core/java/com/android/server/wm/RootActivityContainer.java
/**
 * This resolves the home activity info.
 * @return the home activity info if any.
 */
@VisibleForTesting
ActivityInfo resolveHomeActivity(int userId, Intent homeIntent) {
        final ComponentName comp = homeIntent.getComponent();
        try {
                if (comp != null) {
                        // Factory test.
                } else {
                        final String resolvedType =
                                        homeIntent.resolveTypeIfNeeded(mService.mContext.getContentResolver());
                        // 调用PMS查找信息
                        final ResolveInfo info = AppGlobals.getPackageManager()
                                        .resolveIntent(homeIntent, resolvedType, flags, userId);
                        if (info != null) {
                                aInfo = info.activityInfo;
                        }
                }
        } catch (RemoteException e) {
                // ignore
        }

        aInfo = new ActivityInfo(aInfo);
        aInfo.applicationInfo = mService.getAppInfoForUser(aInfo.applicationInfo, userId);
        return aInfo;
}

  当找到所需信息后,调用ActivityStartController的startHomeActivity启动Home。该接口与AMS的startActivity和startActivityAsUser实现上基本原理一样,都是通过Intent启动Activity(fork一个进程出来)。

// frameworks/base/services/core/java/com/android/server/wm/ActivityStartController.java
void startHomeActivity(Intent intent, ActivityInfo aInfo, String reason, int displayId) {
        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);
        if (!ActivityRecord.isResolverActivity(aInfo.name)) {
                // The resolver activity shouldn't be put in home stack because when the foreground is
                // standard type activity, the resolver activity should be put on the top of current
                // foreground instead of bring home stack to front.
                options.setLaunchActivityType(ACTIVITY_TYPE_HOME);
        }
        options.setLaunchDisplayId(displayId);
        // 启动Activity
        mLastHomeActivityStartResult = obtainStarter(intent, "startHomeActivity: " + reason)
                        .setOutActivity(tmpOutRecord)
                        .setCallingUid(0)
                        .setActivityInfo(aInfo)
                        .setActivityOptions(options.toBundle())
                        .execute();
        mLastHomeActivityStartRecord = tmpOutRecord[0];
        final ActivityDisplay display =
                        mService.mRootActivityContainer.getActivityDisplay(displayId);
        final ActivityStack homeStack = display != null ? display.getHomeStack() : null;
        if (homeStack != null && homeStack.mInResumeTopActivity) {
                // If we are in resume section already, home activity will be initialized, but not
                // resumed (to avoid recursive resume) and will stay that way until something pokes it
                // again. We need to schedule another resume.
                mSupervisor.scheduleResumeTopActivities();
        }
}

三、短压Home键启动Launcher

3.1、短压Home键启动Launcher流程图

在这里插入图片描述

3.2、短压Home键启动Launcher源码分析

  短压与长按区分,点一下Home键就属于短压。短压Home键后,Android会启动Home。

// frameworks/base/services/core/java/com/android/server/input/InputManagerService.java

// Native callback.
private long interceptKeyBeforeDispatching(IBinder focus, KeyEvent event, int policyFlags) {
        // native层的 inputservice,通过这个接口上报回调
    return mWindowManagerCallbacks.interceptKeyBeforeDispatching(focus, event, policyFlags);
}
// frameworks/base/services/core/java/com/android/server/wm/InputManagerCallback.java
/**
Provides an opportunity for the window manager policy to process a key before
ordinary dispatch.
*/
@Override
public long interceptKeyBeforeDispatching(IBinder focus, KeyEvent event, int policyFlags) {
         WindowState windowState = mService.windowForClientLocked(null, focus, false);
         return mService.mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags);
}

  mService是WindowManagerService类型,WindowManagerService中的mPolicy是PhoneWindowManager。PhoneWindowManager作为WMS的Policy配置文件,专门用来处理与UI行为有关的事件。PhoneWindowManager会拦截HomeKey事件进行相应处理后选择不再派发Home(PhoneWindowManager处理完就不需要其他人处理了),或者继续派发HomeKey给当前焦点View。

// frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
private long interceptKeyBeforeDispatchingInner(WindowState win, KeyEvent event,
            int policyFlags) {
    final boolean keyguardOn = keyguardOn();
    final int keyCode = event.getKeyCode();
    final int repeatCount = event.getRepeatCount();
    final int metaState = event.getMetaState();
    final int flags = event.getFlags();
    final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
    final boolean canceled = event.isCanceled();
    final int displayId = event.getDisplayId();

    // First we always handle the home key here, so applications
    // can never break it, although if keyguard is on, we do let
    // it handle it, because that gives us the correct 5 second
    // timeout.
    if (keyCode == KeyEvent.KEYCODE_HOME) {
            // 处理HomeKey
            DisplayHomeButtonHandler handler = mDisplayHomeButtonHandlers.get(displayId);
            if (handler == null) {
                    handler = new DisplayHomeButtonHandler(displayId);
                    mDisplayHomeButtonHandlers.put(displayId, handler);
            }
            return handler.handleHomeButton(win, event);
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
    // 省略
    }
}

/** A handler to handle home keys per display */
private class DisplayHomeButtonHandler {
    int handleHomeButton(WindowState win, KeyEvent event) {
        final boolean keyguardOn = keyguardOn();
        final int repeatCount = event.getRepeatCount();
        final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
        final boolean canceled = event.isCanceled();
        // If we have released the home key, and didn't do anything else
        // while it was pressed, then it is time to go home!
        if (!down) {
                // 省略
                // Post to main thread to avoid blocking input pipeline.
                // 处理短压Home
                mHandler.post(() -> handleShortPressOnHome(mDisplayId));
                return -1;
        }
        // 省略
        return -1;
    }
}

private void handleShortPressOnHome(int displayId) {
    // Turn on the connected TV and switch HDMI input if we're a HDMI playback device.
    final HdmiControl hdmiControl = getHdmiControl();
    if (hdmiControl != null) {
            hdmiControl.turnOnTv();
    }

    // If there's a dream running then use home to escape the dream
    // but don't actually go home.
    if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) {
            mDreamManagerInternal.stopDream(false /*immediate*/);
            return;
    }

    // 启动Home
    // Go home!
    launchHomeFromHotKey(displayId);
}

  PhoneWindowManager针对每个Display创建一个DisplayHomeButtonHandler ,通过它处理HomeKey。在启动Home期间如果开始了dream模式(类似于屏保),会先退出dream。最后调用launchHomeFromHotKey来启动Home,后续流程基本上与Home开机启动一致了。

四、Launcher异常崩溃后的自启动

4.1、Launcher异常崩溃后的自启动流程图

在这里插入图片描述

4.2、Launcher异常崩溃后的自启动源码分析

  Launcher意外退出(比如崩溃了)时,会触发AMS的forceStopPackage。AMS会再次将Home拉起。

//frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@Override
public void forceStopPackage(final String packageName, int userId) {
    try {
        IPackageManager pm = AppGlobals.getPackageManager();
        synchronized(this) {
            int[] users = userId == UserHandle.USER_ALL
                            ? mUserController.getUsers() : new int[] { userId };
            for (int user : users) {
                if (mUserController.isUserRunning(user, 0)) {
                    // 对每个运行的User,停掉 packageName对应的应用
                    forceStopPackageLocked(packageName, pkgUid, "from pid " + callingPid);
                    finishForceStopPackageLocked(packageName, pkgUid);
                }
            }
        }
    } finally {
        Binder.restoreCallingIdentity(callingId);
    }
}

  forceStopPackageLocked函数中,会先Kill掉应用对应的进程。然后 resume focused app,在resume的过程中会拉起Home。

//frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@GuardedBy("this")
final boolean forceStopPackageLocked(String packageName, int appId,
        boolean callerWillRestart, boolean purgeCache, boolean doit,
        boolean evenPersistent, boolean uninstalling, int userId, String reason) {
    // kill进程
    boolean didSomething = mProcessList.killPackageProcessesLocked(packageName, appId, userId,
    ProcessList.INVALID_ADJ, callerWillRestart, true /* allowRestart /, doit,
*                        evenPersistent, true /* setRemoved */,
    packageName == null ? ("stop user " + userId) : ("stop " + packageName));

    if (doit) {
        if (purgeCache && packageName != null) {
            AttributeCache ac = AttributeCache.instance();
            if (ac != null) {
                    ac.removePackage(packageName);
            }
        }
        if (mBooted) {
            // resume focused app
            // 通过这个函数重新拉起Home
            mAtmInternal.resumeTopActivities(true /* scheduleIdle */);
        }
    }

    return didSomething;
}

  调用ActivityTaskManagerServiced的resumeTopActivities函数。在 Home崩溃的情况下,调用这个函数,可以保证Home重新被拉起(这个函数最终会调用到RootActivityContainer 的resumeHomeActivity函数。感兴趣的可以继续顺着代码往下看)

//frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@Override
public void resumeTopActivities(boolean scheduleIdle) {
    synchronized (mGlobalLock) {
        mRootActivityContainer.resumeFocusedStacksTopActivities();
        if (scheduleIdle) {
            mStackSupervisor.scheduleIdleLocked();
        }
    }
}
// frameworks/base/services/core/java/com/android/server/wm/RootActivityContainer.java
boolean resumeFocusedStacksTopActivities(
            ActivityStack targetStack, ActivityRecord target, ActivityOptions targetOptions) {
    for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
        // 省略
        if (!resumedOnDisplay) {
            // In cases when there are no valid activities (e.g. device just booted or launcher
            // crashed) it's possible that nothing was resumed on a display. Requesting resume
            // of top activity in focused stack explicitly will make sure that at least home
            // activity is started and resumed, and no recursion occurs.
            final ActivityStack focusedStack = display.getFocusedStack();
            if (focusedStack != null) {
                    focusedStack.resumeTopActivityUncheckedLocked(target, targetOptions);
            }
        }
    }

    return result;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1396874.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

刷题总结1.19

这句话是不正确的。当对链接队列进行出队操作时&#xff0c;front指针会发生变化。 链接队列是一种基于链表实现的队列数据结构。队列的特点是先进先出&#xff0c;即首先进队的元素将首先出队。在出队操作中&#xff0c;我们需要移动front指针&#xff0c;将其指向下一个元素…

什么是兼容性测试?有哪些作用?

兼容性测试是软件测试中至关重要的一个方面&#xff0c;它主要关注确保应用程序在不同环境和平台上的正常运行&#xff0c;以提供一致、流畅的用户体验。本文将介绍什么是兼容性测试以及它在软件开发生命周期中的作用。 什么是兼容性测试? 兼容性测试是一种确保软件在各种操作…

CodeGeex全能的智能编程助手

大家好我是在看&#xff0c;记录普通人学习探索AI之路。 一、介绍 CodeGeeX&#xff0c;一款由清华大学知识工程实验室研发的基于大型模型的全能智能编程辅助工具&#xff0c;能够实现包括代码生成与补全、自动注释添加、代码翻译以及智能问答等多种功能。经过对包含前后端工…

入门设计者不容错过!5款网页原型设计工具推荐!

即时设计 即时设计是一种支持团队合作的原型设计工具&#xff0c;不限于设备和人群的使用&#xff0c;浏览器可以打开和使用。在即时设计中&#xff0c;您可以从0到1创建一个Web页面原型&#xff0c;具有钢笔、矩形、矢量编辑、轮廓、文本、色彩填充等设计功能&#xff0c;足以…

鸿蒙原生应用/元服务实战-AGC团队账户

多人及内外结合去开发运营鸿蒙原生应用元服务时&#xff0c;需要用到团队账户&#xff0c;AGC提供了强大的团队角色与权限分工能力。 团队帐号是开发者联盟为实名开发者提供的多个成员帐号登录与权限管理服务。当前团队帐号支持成员参与应用市场&#xff08;付费推广、应用内付…

openGauss:准备知识1【IP地址/SSH协议/PuTTY安装和使用】

最近研究在openEuler 22.03 LTS上使用openGauss数据库。如果想要远端访问服务器&#xff0c;那么就先要了解IP地址、SSH协议等内容。 IP代表“Internet Protocol”&#xff0c;是一种网络协议&#xff0c;它定义了计算机在网络上的地址和数据传输方式。简言之&#xff0c;可以…

Unity XR 设置VR设备手柄按键按下事件

一、Unity设置 1、导入XR Interaction Toolkit插件&#xff0c;导入示例资源&#xff08;如下图&#xff09;。 2、设置新版XR输入事件 ①打开XRI Default Input Action 面板。 ②设置左手柄上的按键就点击Action Maps 列表下的 XRI LeftHand Interaction选项&#xff0c;设置…

基于HFSS的微带线特性阻抗仿真-与基于FDTD的计算电磁学方法对比(Matlab)

基于HFSS的微带线特性阻抗仿真-与基于FDTD的计算电磁学方法对比&#xff08;Matlab&#xff09; 工程下载&#xff1a; HFSS的微带线特性阻抗仿真工程文件&#xff08;注意版本&#xff1a;HFSS2023R2&#xff09;&#xff1a; https://download.csdn.net/download/weixin_445…

npm pnpm yarn 报错或常见问题处理集锦

各种卡死&#xff0c;报错问题处理汇总 1. npm 安装 卡死了怎么办&#xff0c;npm # 切换源 npm config set registry https://registry.npmmirror.com # 查看源 npm config get registry2. pnpm安装 卡死了怎么办 方法1&#xff1a;切换源 npx pnpm config set registry h…

从QObject类及非QObject类实现多继承,需把QObject放在继承链最前面

在开发中&#xff0c;有时需要实现多继承&#xff0c;如下定义了一个抽象类作为接口&#xff1a; // 接收CAN数据接口类#ifndef _RECVCANDATA_INTERFACE_H #define _RECVCANDATA_INTERFACE_H#include"cansocketlinux.h" class CRecvCanDataInterface {public: // vi…

C++ 设计模式之备忘录模式

【声明】本题目来源于卡码网&#xff08;题目页面 (kamacoder.com)&#xff09; 【提示&#xff1a;如果不想看文字介绍&#xff0c;可以直接跳转到C编码部分】 【设计模式大纲】 【简介】 -- 什么是备忘录模式 &#xff08;第17种模式&#xff09; 备忘录模式&#xff08;Meme…

KubeSphere 核心实战之一【在kubesphere平台上部署mysql】(实操篇 1/4)

文章目录 1、登录kubesphere平台2、kubesphere部署应用分析2.1、工作负载2.2、服务2.3、应用路由2.4、任务2.5、存储与配置2.6、部署应用三要素 3、部署mysql3.1、mysql容器启动实例3.2、mysql部署分析3.3、创建mysql的配置3.4、创建mysql的数据卷pvc3.5、创建mysql工作负载3.6…

力扣第236题——二叉树的最近公共祖先 (C语言题解)

题目描述 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为&#xff1a;“对于有根树 T 的两个节点 p、q&#xff0c;最近公共祖先表示为一个节点 x&#xff0c;满足 x 是 p、q 的祖先且 x 的深度尽可能大&#xff08;一个节点也可以…

C#MQTT编程07--MQTT服务器和客户端(wpf版)

1、前言 上篇完成了winform版的mqtt服务器和客户端&#xff0c;实现了订阅和发布&#xff0c;效果666&#xff0c;长这样 这节要做的wpf版&#xff0c;长这样&#xff0c;效果也是帅BBBB帅&#xff0c;wpf技术是cs程序软件的福音。 wpf的基础知识和案例项目可以看我的另一个专…

定义域【高数笔记】

【定义域】 1&#xff0c;{知识点} 对于一个函数&#xff0c;f(x)&#xff0c;"f"是起到两个作用&#xff0c;第一&#xff0c;是对自变量的范围的约束&#xff0c;第二&#xff0c;是对运算的约束&#xff0c;同一个"f" 就有同一个约束效果 2&#xff0c;…

TPU编程竞赛系列|第八届集创赛“算能杯“报名开启!

近日&#xff0c;第八届全国大学生集成电路创新创业大赛正式开幕&#xff0c;"算能杯"以 基于TPU处理器的边缘计算系统设计 为赛题&#xff0c;围绕算能提供的多款TPU硬件&#xff0c;展开软硬件协同设计&#xff0c;创新开发算法及探索新兴应用。我们诚邀全国高校的…

表的增删改查 进阶(二)

&#x1f3a5; 个人主页&#xff1a;Dikz12&#x1f525;个人专栏&#xff1a;MySql&#x1f4d5;格言&#xff1a;那些在暗处执拗生长的花&#xff0c;终有一日会馥郁传香欢迎大家&#x1f44d;点赞✍评论⭐收藏 目录 3.新增 4.查询 聚合查询 聚合函数 GROUP BY子句 HA…

php反序列化之pop链构造(基于重庆橙子科技靶场)

常见魔术方法的触发 __construct() //创建类对象时调用 __destruct() //对象被销毁时触发 __call() //在对象中调用不可访问的方法时触发 __callStatic() //在静态方式中调用不可访问的方法时触发 __get() //调用类中不存在变量时触发&#xff08;找有连续箭头的…

Git学习笔记(第3章):Git常用命令

目录 3.1 设置用户签名 3.2 初始化本地库 3.3 查看本地库状态 3.4 添加暂存区 3.5 提交本地库 3.6 历史版本 3.7 修改文件 3.8 版本穿梭 小结 命令 作用 git config --global user.name 用户名 设置用户签名 git config --global user.email 邮箱 设置用户签名 …

机器学习顶会ICLR 2024录用论文合集,包含时间序列、图大模型、agent等热门主题

朋友们&#xff0c;ICLR 2024这周放榜了&#xff01;据统计&#xff0c;本届会议共收到了7262篇论文&#xff0c;整体接收率约为31%&#xff0c;与去年&#xff08;31.8%&#xff09;基本持平。其中Spotlight论文比例为5%&#xff0c;Oral论文比例为1.2%。 不知道各位看完有什…