Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate 5.0 doxygen API for XMS part #6

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading