mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-30 02:21:35 +00:00
auto start
Signed-off-by: w00675913 <wangjin193@huawei.com>
This commit is contained in:
parent
0e5382df69
commit
f467a05033
@ -114,7 +114,7 @@ const std::string &AccessibilityAbilityInfo::GetSettingsAbility() const
|
||||
bool AccessibilityAbilityInfo::IsImportant() const
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
return isImportant_;
|
||||
return false;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -243,6 +243,7 @@ public:
|
||||
|
||||
void GetImportantEnabledAbilities(std::map<std::string, uint32_t> &importantEnabledAbilities) const;
|
||||
void UpdateImportantEnabledAbilities(std::map<std::string, uint32_t> &importantEnabledAbilities);
|
||||
void UpdateAutoStartEnabledAbilities();
|
||||
|
||||
uint32_t GetInputFilterFlag() const;
|
||||
void UpdateAbilities();
|
||||
@ -253,6 +254,9 @@ public:
|
||||
void AddUITestClient(const sptr<IRemoteObject> &obj,
|
||||
const std::string &bundleName, const std::string &abilityName);
|
||||
void RemoveUITestClient(sptr<AccessibleAbilityConnection> &connection, const std::string &bundleName);
|
||||
void SetAbilityAutoStartState(const std::string &name, const bool state);
|
||||
void DelAbilityAutoStartStatePrefKey(const std::string &name);
|
||||
void DelAutoStartPrefKeyInRemovePkg(const std::string &bundleName);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
RetError SetClickResponseTime(const uint32_t time);
|
||||
RetError SetIgnoreRepeatClickState(const bool state);
|
||||
RetError SetIgnoreRepeatClickTime(const uint32_t time);
|
||||
void SetAbilityAutoStartState(const std::string &name, const bool state);
|
||||
void DelAbilityAutoStartStatePrefKey(const std::string &name);
|
||||
|
||||
bool GetEnabledState() const;
|
||||
bool GetTouchGuideState() const;
|
||||
@ -94,6 +96,7 @@ public:
|
||||
uint32_t GetClickResponseTime() const;
|
||||
bool GetIgnoreRepeatClickState() const;
|
||||
uint32_t GetIgnoreRepeatClickTime() const;
|
||||
bool GetAbilityAutoStartState(const std::string &key);
|
||||
|
||||
void UpdateEnabledAbilities(const std::vector<std::string> &vecvalue);
|
||||
const std::vector<std::string> &GetEnabledAbilityInfos();
|
||||
|
@ -50,6 +50,8 @@ public:
|
||||
static int64_t GetSystemTime();
|
||||
static std::string GetUri(const OHOS::AppExecFwk::ElementName &elementName);
|
||||
static std::string GetUri(const std::string &bundleName, const std::string &abilityName);
|
||||
static std::string GetAbilityAutoStartStateKey(const std::string &bundleName, const std::string &abilityName,
|
||||
int32_t accountId);
|
||||
static void RecordUnavailableEvent(A11yUnavailableEvent event, A11yError errCode,
|
||||
const std::string &bundleName = "", const std::string &abilityName = "");
|
||||
static void RecordStartingA11yEvent(uint32_t flag);
|
||||
|
@ -209,7 +209,7 @@ void AccessibilityAccountData::AddEnabledAbility(const std::string &name)
|
||||
|
||||
RetError AccessibilityAccountData::RemoveEnabledAbility(const std::string &name)
|
||||
{
|
||||
HILOG_DEBUG("AddEnabledAbility start");
|
||||
HILOG_DEBUG("RemoveEnabledAbility start");
|
||||
for (auto it = enabledAbilities_.begin(); it != enabledAbilities_.end(); it++) {
|
||||
if (*it == name) {
|
||||
HILOG_DEBUG("Removed %{public}s from EnabledAbility: ", name.c_str());
|
||||
@ -400,6 +400,41 @@ void AccessibilityAccountData::UpdateMagnificationCapability()
|
||||
isScreenMagnification_ = false;
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::SetAbilityAutoStartState(const std::string &name, const bool state)
|
||||
{
|
||||
HILOG_DEBUG("start and name[%{public}s], state = [%{public}s].", name.c_str(), state ? "True" : "False");
|
||||
if (!config_) {
|
||||
config_ = std::make_shared<AccessibilitySettingsConfig>(id_);
|
||||
}
|
||||
config_->SetAbilityAutoStartState(name, state);
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::DelAbilityAutoStartStatePrefKey(const std::string &name)
|
||||
{
|
||||
HILOG_DEBUG("start and name[%{public}s]].", name.c_str());
|
||||
if (!config_) {
|
||||
config_ = std::make_shared<AccessibilitySettingsConfig>(id_);
|
||||
}
|
||||
config_->DelAbilityAutoStartStatePrefKey(name);
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::DelAutoStartPrefKeyInRemovePkg(const std::string &bundleName)
|
||||
{
|
||||
HILOG_ERROR("start and bundleName[%{public}s].", bundleName.c_str());
|
||||
if (installedAbilities_.empty()) {
|
||||
HILOG_DEBUG("There is no installed abilities.");
|
||||
return;
|
||||
}
|
||||
for (auto &installAbility : installedAbilities_) {
|
||||
if (installAbility.GetPackageName() == bundleName) {
|
||||
std::string abilityName = installAbility.GetName();
|
||||
std::string uri = Utils::GetUri(bundleName, abilityName);
|
||||
DelAbilityAutoStartStatePrefKey(uri);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RetError AccessibilityAccountData::EnableAbility(const std::string &name, const uint32_t capabilities)
|
||||
{
|
||||
HILOG_DEBUG("start and name[%{public}s] capabilities[%{public}d]", name.c_str(), capabilities);
|
||||
@ -437,6 +472,7 @@ RetError AccessibilityAccountData::EnableAbility(const std::string &name, const
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "EnableAbility:" + name);
|
||||
|
||||
enabledAbilities_.push_back(name);
|
||||
SetAbilityAutoStartState(name, true);
|
||||
UpdateAbilities();
|
||||
Utils::RecordStartingA11yEvent(name);
|
||||
return RET_OK;
|
||||
@ -573,6 +609,36 @@ void AccessibilityAccountData::UpdateImportantEnabledAbilities(
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::UpdateAutoStartEnabledAbilities()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (id_ == -1) {
|
||||
HILOG_DEBUG("Current user is -1.");
|
||||
return;
|
||||
}
|
||||
if (installedAbilities_.empty()) {
|
||||
HILOG_DEBUG("Current user has no installedAbilities.");
|
||||
return;
|
||||
}
|
||||
if (!config_) {
|
||||
HILOG_DEBUG("config_ is null.");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("installedAbilities is %{public}zu.", installedAbilities_.size());
|
||||
for (auto &installAbility : installedAbilities_) {
|
||||
std::string bundleName = installAbility.GetPackageName();
|
||||
std::string abilityName = installAbility.GetName();
|
||||
HILOG_DEBUG("installAbility's packageName is %{public}s and abilityName is %{public}s",
|
||||
bundleName.c_str(), abilityName.c_str());
|
||||
|
||||
std::string strAutoStartStateKey = Utils::GetAbilityAutoStartStateKey(bundleName, abilityName, id_);
|
||||
if (config_->GetAbilityAutoStartState(strAutoStartStateKey)) {
|
||||
std::string uri = Utils::GetUri(bundleName, abilityName);
|
||||
AddEnabledAbility(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AccessibilityAccountData::GetInputFilterFlag() const
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
@ -697,6 +763,15 @@ void AccessibilityAccountData::AddAbility(const std::string &bundleName)
|
||||
std::make_shared<AccessibilityAbilityInfo>(initParams);
|
||||
AddInstalledAbility(*accessibilityInfo);
|
||||
hasNewExtensionAbility = true;
|
||||
|
||||
std::string tmpAbilityName = accessibilityInfo->GetName();
|
||||
std::string strAutoStartStateKey = Utils::GetAbilityAutoStartStateKey(bundleName, tmpAbilityName, id_);
|
||||
if (config_ != nullptr && config_->GetAbilityAutoStartState(strAutoStartStateKey)) {
|
||||
std::string uri = Utils::GetUri(bundleName, tmpAbilityName);
|
||||
AddEnabledAbility(uri);
|
||||
RemoveConnectingA11yAbility(uri);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,6 +240,35 @@ RetError AccessibilitySettingsConfig::SetIgnoreRepeatClickTime(const uint32_t ti
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void AccessibilitySettingsConfig::SetAbilityAutoStartState(const std::string &name, const bool state)
|
||||
{
|
||||
HILOG_DEBUG("name = [%{public}s], state = [%{public}s].", name.c_str(), state ? "True" : "False");
|
||||
if (!pref_) {
|
||||
HILOG_ERROR("pref_ is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string strValue = StateChange(state);
|
||||
std::string abilityAutoStartKey = name + "/" + std::to_string(accountId_);
|
||||
pref_->PutString(abilityAutoStartKey, strValue);
|
||||
pref_->Flush();
|
||||
return;
|
||||
}
|
||||
|
||||
void AccessibilitySettingsConfig::DelAbilityAutoStartStatePrefKey(const std::string &name)
|
||||
{
|
||||
HILOG_DEBUG("name = [%{public}s].", name.c_str());
|
||||
if (!pref_) {
|
||||
HILOG_ERROR("pref_ is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string abilityAutoStartKey = name + "/" + std::to_string(accountId_);
|
||||
pref_->Delete(abilityAutoStartKey);
|
||||
pref_->Flush();
|
||||
return;
|
||||
}
|
||||
|
||||
RetError AccessibilitySettingsConfig::SetCaptionProperty(const AccessibilityConfig::CaptionProperty& caption)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
@ -454,6 +483,22 @@ uint32_t AccessibilitySettingsConfig::GetIgnoreRepeatClickTime() const
|
||||
return ignoreRepeatClickTime_;
|
||||
}
|
||||
|
||||
bool AccessibilitySettingsConfig::GetAbilityAutoStartState(const std::string &key)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (!pref_) {
|
||||
HILOG_ERROR("pref_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string strValue = pref_->GetString(key, "");
|
||||
HILOG_DEBUG(" pref_->GetString() = %{public}s.", strValue.c_str());
|
||||
if (!std::strcmp(strValue.c_str(), "on")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t AccessibilitySettingsConfig::GetConfigState()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
@ -889,6 +889,7 @@ RetError AccessibleAbilityManagerService::InnerDisableAbility(const std::string
|
||||
HILOG_ERROR("RemoveEnabledAbility failed");
|
||||
return ret;
|
||||
}
|
||||
accountData->SetAbilityAutoStartState(name, false);
|
||||
accountData->RemoveConnectingA11yAbility(name);
|
||||
accountData->UpdateAbilities();
|
||||
return RET_OK;
|
||||
@ -1190,6 +1191,7 @@ void AccessibleAbilityManagerService::SwitchedUser(int32_t accountId)
|
||||
HILOG_ERROR("Failed to set brightness discount");
|
||||
}
|
||||
if (accountData->GetInstalledAbilitiesFromBMS()) {
|
||||
accountData->UpdateAutoStartEnabledAbilities();
|
||||
accountData->UpdateImportantEnabledAbilities(importantEnabledAbilities);
|
||||
accountData->UpdateAbilities();
|
||||
UpdateAccessibilityManagerService();
|
||||
@ -1204,6 +1206,7 @@ void AccessibleAbilityManagerService::PackageRemoved(const std::string &bundleNa
|
||||
return;
|
||||
}
|
||||
|
||||
packageAccount->DelAutoStartPrefKeyInRemovePkg(bundleName);
|
||||
if (packageAccount->RemoveAbility(bundleName)) {
|
||||
HILOG_DEBUG("ability%{public}s removed!", bundleName.c_str());
|
||||
UpdateAccessibilityManagerService();
|
||||
@ -1228,6 +1231,7 @@ void AccessibleAbilityManagerService::PackageChanged(const std::string &bundleNa
|
||||
return;
|
||||
}
|
||||
packageAccount->ChangeAbility(bundleName);
|
||||
UpdateAccessibilityManagerService();
|
||||
}
|
||||
|
||||
void AccessibleAbilityManagerService::UpdateAccessibilityWindowStateByEvent(const AccessibilityEventInfo &event)
|
||||
|
@ -235,6 +235,14 @@ std::string Utils::GetUri(const std::string &bundleName, const std::string &abil
|
||||
return bundleName + "/" + abilityName;
|
||||
}
|
||||
|
||||
std::string Utils::GetAbilityAutoStartStateKey(const std::string &bundleName, const std::string &abilityName,
|
||||
int32_t accountId)
|
||||
{
|
||||
HILOG_DEBUG("bundle name(%{public}s) ability name(%{public}s) accountId(%{public}d)",
|
||||
bundleName.c_str(), abilityName.c_str(), accountId);
|
||||
return bundleName + "/" + abilityName + "/" + std::to_string(accountId);
|
||||
}
|
||||
|
||||
void Utils::RecordUnavailableEvent(A11yUnavailableEvent event, A11yError errCode,
|
||||
const std::string &bundleName, const std::string &abilityName)
|
||||
{
|
||||
|
@ -365,6 +365,26 @@ void AccessibilityAccountData::RemoveUITestClient(
|
||||
(void)bundleName;
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::SetAbilityAutoStartState(const std::string &name, const bool state)
|
||||
{
|
||||
(void)name;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::DelAbilityAutoStartStatePrefKey(const std::string &name)
|
||||
{
|
||||
(void)name;
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::DelAutoStartPrefKeyInRemovePkg(const std::string &bundleName)
|
||||
{
|
||||
(void)bundleName;
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::UpdateAutoStartEnabledAbilities()
|
||||
{
|
||||
}
|
||||
|
||||
sptr<AccessibleAbilityConnection> AccessibilityAccountData::AccessibilityAbility::GetAccessibilityAbilityByUri(
|
||||
const std::string& uri)
|
||||
{
|
||||
|
@ -360,6 +360,26 @@ void AccessibilitySettingsConfig::StringToVector(const std::string &stringIn, st
|
||||
HILOG_DEBUG("start.");
|
||||
}
|
||||
|
||||
void AccessibilitySettingsConfig::SetAbilityAutoStartState(const std::string &name, const bool state)
|
||||
{
|
||||
HILOG_DEBUG("start.");
|
||||
(void)name;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
void AccessibilitySettingsConfig::DelAbilityAutoStartStatePrefKey(const std::string &name)
|
||||
{
|
||||
HILOG_DEBUG("start.");
|
||||
(void)name;
|
||||
}
|
||||
|
||||
bool AccessibilitySettingsConfig::GetAbilityAutoStartState(const std::string &key)
|
||||
{
|
||||
HILOG_DEBUG("start.");
|
||||
(void)key;
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::vector<std::string> &AccessibilitySettingsConfig::GetEnabledAbilityInfos()
|
||||
{
|
||||
HILOG_DEBUG("start.");
|
||||
|
Loading…
Reference in New Issue
Block a user