mirror of
https://github.com/openharmony/accessibility.git
synced 2026-08-25 11:51:38 -04:00
@@ -30,7 +30,8 @@ namespace Accessibility {
|
||||
|
||||
enum ShortKeyDialogType {
|
||||
FUNCTION_SELECT = 0,
|
||||
RECONFIRM = 1
|
||||
RECONFIRM = 1,
|
||||
READER_EXCLUSIVE = 2
|
||||
};
|
||||
|
||||
class ShortkeyAbilityConnection : public AAFwk::AbilityConnectionStub {
|
||||
@@ -69,6 +70,24 @@ private:
|
||||
std::string commandStr_;
|
||||
};
|
||||
|
||||
class ExclusiveAbilityConnection : public AAFwk::AbilityConnectionStub {
|
||||
public:
|
||||
explicit ExclusiveAbilityConnection(const std::string commandStr)
|
||||
{
|
||||
commandStr_ = commandStr;
|
||||
}
|
||||
|
||||
virtual ~ExclusiveAbilityConnection() = default;
|
||||
|
||||
void OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int32_t resultCode) override;
|
||||
void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int32_t resultCode) override;
|
||||
std::string GetCommandString();
|
||||
|
||||
private:
|
||||
std::string commandStr_;
|
||||
};
|
||||
|
||||
class AccessibilityShortkeyDialog {
|
||||
public:
|
||||
AccessibilityShortkeyDialog();
|
||||
@@ -84,6 +103,7 @@ private:
|
||||
private:
|
||||
sptr<ShortkeyAbilityConnection> functionSelectConn_ {nullptr};
|
||||
sptr<ReConfirmAbilityConnection> reConfirmConn_ {nullptr};
|
||||
sptr<ExclusiveAbilityConnection> readerExclusiveConn_ {nullptr};
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
|
||||
@@ -128,6 +128,52 @@ std::string ReConfirmAbilityConnection::GetCommandString()
|
||||
return commandStr_;
|
||||
}
|
||||
|
||||
void ExclusiveAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int32_t resultCode)
|
||||
{
|
||||
HILOG_DEBUG("on ability connected");
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
data.WriteInt32(SHORTKEY_DIALOG_PARAM_NUM);
|
||||
data.WriteString16(u"bundleName");
|
||||
data.WriteString16(u"com.huawei.hmos.settings");
|
||||
data.WriteString16(u"abilityName");
|
||||
data.WriteString16(u"AccessibilityIgnoreConfirmDialog");
|
||||
data.WriteString16(u"parameters");
|
||||
data.WriteString16(Str8ToStr16(GetCommandString()));
|
||||
|
||||
if (!data.WriteParcelable(&element)) {
|
||||
HILOG_ERROR("Connect done element error.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(remoteObject)) {
|
||||
HILOG_ERROR("Connect done remote object error.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(resultCode)) {
|
||||
HILOG_ERROR("Connect done result code error.");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t errCode = remoteObject->SendRequest(
|
||||
AAFwk::IAbilityConnection::ON_ABILITY_CONNECT_DONE, data, reply, option);
|
||||
HILOG_DEBUG("AbilityConnectionWrapperProxy::OnAbilityConnectDone result %{public}d", errCode);
|
||||
}
|
||||
|
||||
void ExclusiveAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
|
||||
int32_t resultCode)
|
||||
{
|
||||
HILOG_DEBUG("on ability disconnected");
|
||||
}
|
||||
|
||||
std::string ExclusiveAbilityConnection::GetCommandString()
|
||||
{
|
||||
return commandStr_;
|
||||
}
|
||||
|
||||
// dialog
|
||||
AccessibilityShortkeyDialog::AccessibilityShortkeyDialog() {}
|
||||
|
||||
@@ -161,6 +207,14 @@ bool AccessibilityShortkeyDialog::ConnectExtensionAbility(const AAFwk::Want &wan
|
||||
}
|
||||
ret = AAFwk::ExtensionManagerClient::GetInstance().ConnectServiceExtensionAbility(want,
|
||||
functionSelectConn_, nullptr, DEFAULT_VALUE_MINUS_ONE);
|
||||
} else if (dialogType == ShortKeyDialogType::READER_EXCLUSIVE) {
|
||||
readerExclusiveConn_ = new(std::nothrow) ExclusiveAbilityConnection(commandStr);
|
||||
if (readerExclusiveConn_ == nullptr) {
|
||||
HILOG_ERROR("connection_ is nullptr.");
|
||||
return false;
|
||||
}
|
||||
ret = AAFwk::ExtensionManagerClient::GetInstance().ConnectServiceExtensionAbility(want,
|
||||
readerExclusiveConn_, nullptr, DEFAULT_VALUE_MINUS_ONE);
|
||||
} else {
|
||||
reConfirmConn_ = new(std::nothrow) ReConfirmAbilityConnection(commandStr);
|
||||
if (reConfirmConn_ == nullptr) {
|
||||
@@ -210,6 +264,16 @@ bool AccessibilityShortkeyDialog::DisconnectExtension(ShortKeyDialogType dialogT
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (dialogType == ShortKeyDialogType::READER_EXCLUSIVE) {
|
||||
if (readerExclusiveConn_ == nullptr) {
|
||||
return true;
|
||||
}
|
||||
ErrCode ret = AAFwk::ExtensionManagerClient::GetInstance().DisconnectAbility(readerExclusiveConn_);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("disconnect extension ability failed ret: %{public}d.", ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (reConfirmConn_ == nullptr) {
|
||||
return true;
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
MOCK_METHOD0(GetEventTouchGuideStateFlag, bool());
|
||||
MOCK_METHOD0(GetFilteringKeyEventsFlag, bool());
|
||||
MOCK_METHOD0(GetGesturesSimulationFlag, bool());
|
||||
MOCK_METHOD0(DealWithScreenReaderState, bool());
|
||||
MOCK_METHOD0(GetInstalledAbilitiesFromBMS, bool());
|
||||
MOCK_METHOD0(GetCaptionProperty, AccessibilityConfig::CaptionProperty());
|
||||
MOCK_METHOD1(SetCaptionProperty, bool(const AccessibilityConfig::CaptionProperty& caption));
|
||||
|
||||
@@ -270,6 +270,11 @@ RetError AccessibilityAccountData::EnableAbility(const std::string &name, const
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
bool AccessibilityAccountData::DealWithScreenReaderState() {
|
||||
HILOG_DEBUG("start.");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS()
|
||||
{
|
||||
HILOG_DEBUG("start.");
|
||||
|
||||
Reference in New Issue
Block a user