Skip to content

Commit

Permalink
Generate 5.0 doxygen API for XMS part
Browse files Browse the repository at this point in the history
  • Loading branch information
liaozhiwei-liaozhiwei committed Feb 24, 2025
1 parent 506bca5 commit 2b62b6c
Show file tree
Hide file tree
Showing 15 changed files with 1,764 additions and 152 deletions.
173 changes: 163 additions & 10 deletions include/am/ActivityManagerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,202 @@ using os::app::IServiceConnection;

class ActivityManagerInner;

/**
* @class ActivityManagerService
* @brief Service that manages activities and services in the system.
*/
class ActivityManagerService : public os::am::BnActivityManager {
public:
/**
* @brief Constructor to initialize the ActivityManagerService.
*
* @param[in] looper The event loop associated with the service.
*/
ActivityManagerService(uv_loop_t* looper);
/**
* @brief Destructor for the ActivityManagerService.
*/
~ActivityManagerService();

/***binder api***/
/**
* @brief Attaches an application to the service.
*
* @param[in] app The application thread to be attached.
* @param[in] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status attachApplication(const sp<os::app::IApplicationThread>& app, int32_t* ret) override;

/**
* @brief Starts an activity.
*
* @param[in] token The token associated with the activity.
* @param[in] intent The intent used to start the activity.
* @param[in] code The request code associated with the activity.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status startActivity(const sp<IBinder>& token, const Intent& intent, int32_t code,
int32_t* ret) override;
/**
* @brief Stops an activity.
*
* @param[in] intent The intent used to stop the activity.
* @param[in] resultCode The result code to return when stopping the activity.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status stopActivity(const Intent& intent, int32_t resultCode, int32_t* ret) override;
/**
* @brief Stops an application.
*
* @param[in] token The token associated with the application to stop.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status stopApplication(const sp<IBinder>& token, int32_t* ret) override;

/**
* @brief Finishes an activity.
*
* @param[in] token The token associated with the activity.
* @param[in] resultCode The result code of the activity.
* @param[in] resultData Optional data to be passed as the result.
* @param[out] ret Output parameter indicating whether the operation was successful.
* @return Status The status of the operation.
*/
Status finishActivity(const sp<IBinder>& token, int32_t resultCode,
const std::optional<Intent>& resultData, bool* ret) override;
/**
* @brief Moves an activity task to the background.
*
* @param[in] token The token associated with the activity.
* @param[in] nonRoot Whether the activity is not the root activity.
* @param[out] ret Output parameter indicating whether the operation was successful.
* @return The status of the operation.
*/
Status moveActivityTaskToBackground(const sp<IBinder>& token, bool nonRoot, bool* ret) override;

/**
* @brief Reports the status of an activity.
*
* @param[in] token The token associated with the activity.
* @param[in] status The status to report for the activity.
* @return The status of the operation.
*/
Status reportActivityStatus(const sp<IBinder>& token, int32_t status) override;

/**
* @brief Starts a service.
*
* @param[in] intent The intent used to start the service.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status startService(const Intent& intent, int32_t* ret) override;
/**
* @brief Stops a service.
*
* @param[in] intent The intent used to stop the service.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status stopService(const Intent& intent, int32_t* ret) override;
/**
* @brief Stops a service by its token.
*
* @param[in] token The token associated with the service to stop.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status stopServiceByToken(const sp<IBinder>& token, int32_t* ret) override;
/**
* @brief Reports the status of a service.
*
* @param[in] token The token associated with the service.
* @param[in] status The status to report for the service.
* @return The status of the operation.
*/
Status reportServiceStatus(const sp<IBinder>& token, int32_t status) override;

/**
* @brief Binds a service.
*
* @param[in] token The token associated with the service.
* @param[in] intent The intent used to bind the service.
* @param[in] conn The service connection used to manage the connection.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status bindService(const sp<IBinder>& token, const Intent& intent,
const sp<IServiceConnection>& conn, int32_t* ret) override;
/**
* @brief Unbinds a service.
*
* @param[in] conn The service connection used to manage the connection.
* @return The status of the operation.
*/
Status unbindService(const sp<IServiceConnection>& conn) override;
/**
* @brief Publishes a service.
*
* @param[in] token The token associated with the service.
* @param[in] service The binder object associated with the service.
* @return The status of the operation.
*/
Status publishService(const sp<IBinder>& token, const sp<IBinder>& service) override;

/**
* @brief Posts an intent to be processed by the system.
*
* @param[in] intent The intent to be posted.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status postIntent(const Intent& intent, int32_t* ret) override;
/**
* @brief Sends a broadcast intent.
*
* @param[in] intent The broadcast intent to send.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status sendBroadcast(const Intent& intent, int32_t* ret) override;
/**
* @brief Registers a receiver for a specific action.
*
* @param[in] action The action to register for.
* @param[in] receiver The receiver to be registered.
* @param[out] ret Output parameter for the result of the operation.
* @return The status of the operation.
*/
Status registerReceiver(const std::string& action, const sp<IBroadcastReceiver>& receiver,
int32_t* ret) override;
/**
* @brief Unregisters a previously registered receiver.
*
* @param[in] receiver The receiver to be unregistered.
* @return The status of the operation.
*/
Status unregisterReceiver(const sp<IBroadcastReceiver>& receiver) override;

/**
* @brief Dumps the current state of the ActivityManagerService.
*
* @param[in] fd The file descriptor to write the dump to.
* @param[in] args The arguments to filter the dump.
* @return The status of the dump operation.
*/
android::status_t dump(int fd, const android::Vector<android::String16>& args) override;

// The service is ready to start and the application can be launched
/**
* @brief Marks the service as ready for operation.
*
* This method is called when the service is ready to start and the application can be launched.
*/
void systemReady();
/**
* @brief Sets the window manager for the system.
*
* @param[in] wm The window manager service to set.
*/
void setWindowManager(sp<::os::wm::IWindowManager> wm);

private:
ActivityManagerInner* mInner;
ActivityManagerInner* mInner; /**< Internal implementation for managing activity operations. */
};

} // namespace am
Expand Down
119 changes: 115 additions & 4 deletions include/app/Activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,160 @@ namespace app {
class ActivityClientRecord;
class ApplicationThreadStub;

/**
* @class Activity
* @brief Represents a crucial component of an Android app.
*
* Activity is a component used to represent a user interface in Android.
*/
class Activity : public ContextWrapper {
public:
/**
* @brief Default constructor for Activity.
*/
Activity() = default;
/**
* @brief Default Destructor for Activity.
*/
virtual ~Activity() = default;

/**
* @brief Lifecycle method called when the Activity is created.
*/
virtual void onCreate() = 0;
/**
* @brief Lifecycle method called when the Activity becomes visible and starts interacting with
* the user.
*/
virtual void onStart() = 0;
/**
* @brief Lifecycle method called when the Activity is fully visible and interactive.
*/
virtual void onResume() = 0;
/**
* @brief Lifecycle method called when the Activity is paused and no longer in the foreground.
*/
virtual void onPause() = 0;
/**
* @brief Lifecycle method called when the Activity is no longer visible and stops interacting
* with the user.
*/
virtual void onStop() = 0;
/**
* @brief Lifecycle method called when the Activity is about to be destroyed.
*/
virtual void onDestroy() = 0;

/**
* @brief Called when the Activity is restarted after being stopped.
*/
virtual void onRestart(){};
/**
* @brief Called when the Activity receives a new Intent.
*
* @param[in] intent The new Intent that was received.
*/
virtual void onNewIntent(const Intent& intent){};
/**
* @brief Called when the Activity receives a result from another Activity.
*
* @param[in] requestCode The code identifying the request.
* @param[in] resultCode The result code of the operation.
* @param[in] resultData The data returned from the operation.
*/
virtual void onActivityResult(const int requestCode, const int resultCode,
const Intent& resultData){};
/**
* @brief Called when the back button is pressed.
*/
virtual void onBackPressed() {
finish();
}
/**
* @brief Called when the Activity receives an Intent during its lifecycle.
*
* @param[in] intent The Intent that was received.
*/
virtual void onReceiveIntent(const Intent& intent){};

/**
* @brief Sets the result for the Activity and finishes it.
*
* @param[in] resultCode The result code indicating the outcome
* @param[in] resultData The data to return to the calling Activity.
*/
void setResult(const int resultCode, const std::shared_ptr<Intent>& resultData);
/**
* @brief Finishes the Activity and removes it from the stack.
*/
void finish();
/**
* @brief Moves the Activity to the background.
*
* @param[in] nonRoot Whether to consider root status when moving to the background. Default is
* true.
* @return True if the Activity was successfully moved to the background, false otherwise.
*/
bool moveToBackground(bool nonRoot = true);
/**
* @brief Gets the window associated with the Activity.
*
* @return A shared pointer to the BaseWindow object associated with this Activity.
*/
std::shared_ptr<::os::wm::BaseWindow> getWindow() {
return mWindow;
}

private:
friend class ActivityClientRecord;
friend class ApplicationThreadStub;
/**
* @brief Attaches the Activity to a given Context.
*
* @param[in] context The Context to attach the Activity to.
* @return An integer representing the result of the attachment process.
*/
int attach(std::shared_ptr<Context> context);
/**
* @brief Performs the creation lifecycle step for the Activity.
*
* @return True if the creation was successful, false otherwise.
*/
bool performCreate();
/**
* @brief Performs the start lifecycle step for the Activity.
*
* @return True if the start was successful, false otherwise.
*/
bool performStart();
/**
* @brief Performs the resume lifecycle step for the Activity.
*
* @return True if the resume was successful, false otherwise.
*/
bool performResume();
/**
* @brief Performs the pause lifecycle step for the Activity.
*
* @return True if the pause was successful, false otherwise.
*/
bool performPause();
/**
* @brief Performs the stop lifecycle step for the Activity.
*
* @return True if the stop was successful, false otherwise.
*/
bool performStop();
/**
* @brief Performs the destroy lifecycle step for the Activity.
*
* @return True if the destroy was successful, false otherwise.
*/
bool performDestroy();

private:
int mResultCode;
std::shared_ptr<Intent> mResultData;
std::shared_ptr<::os::wm::BaseWindow> mWindow;
int mResultCode; /**< The result code returned from the activity. */
std::shared_ptr<Intent> mResultData; /**< The result data returned from the activity. */
std::shared_ptr<::os::wm::BaseWindow> mWindow; /**< The window associated with this activity. */
};

} // namespace app
Expand Down
Loading

0 comments on commit 2b62b6c

Please sign in to comment.