1、追加OnAbilityDisconnected接口 2、更改UpdateAbilities()触发时机

Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
Mupceet 2022-03-07 20:09:48 +08:00
parent 2470c4f02c
commit 1c97ef508b
9 changed files with 12 additions and 164 deletions

View File

@ -134,6 +134,7 @@ void AccessibleAbilityClientStubImpl::Disconnect(const int channelId)
}
} else {
AccessibilityUITestAbility::GetInstance()->SetChannelId(channelId_);
uiTestListener_->OnAbilityDisconnected();
uiTestListener_ = nullptr;
}
}

View File

@ -316,9 +316,8 @@ napi_value NAccessibilityClient::UnsubscribeState(napi_env env, napi_callback_in
bool result = false;
for (auto observer : NAccessibilityClient::listeners_) {
if (observer->GetEnv() == env && !strcmp(observer->GetEventType().c_str(), eventType.c_str())) {
AccessibilitySystemAbilityClient::GetInstance()->UnsubscribeStateObserver(observer, type);
result = AccessibilitySystemAbilityClient::GetInstance()->UnsubscribeStateObserver(observer, type);
NAccessibilityClient::listeners_.erase(NAccessibilityClient::listeners_.begin() + i);
result = true;
break;
}
i++;
@ -1563,7 +1562,7 @@ napi_value NAccessibilityClient::DeregisterCaptionStateCallback(napi_env env, na
if (type == CaptionObserverType::CAPTION_ENABLE) {
napi_get_boolean(env, callbackInfo->result_, &result[PARAM0]); // maby rework
} else {
napi_create_object(env, &result[PARAM0]); // maby rework
napi_create_object(env, &result[PARAM0]); // maby rework
OHOS::Accessibility::CaptionProperty captionProperty {};
captionProperty = AccessibilitySystemAbilityClient::GetInstance()->GetCaptionProperty();
ConvertCaptionPropertyToJS(env, result[PARAM0], captionProperty);

View File

@ -247,7 +247,6 @@ void AccessibilityAccountData::RemoveEnabledAbility(const AppExecFwk::ElementNam
enabledAbilities_.erase(it);
}
RemoveEnabledFromPref(elementName.GetBundleName());
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
}
// For UT
@ -270,13 +269,12 @@ void AccessibilityAccountData::RemoveInstalledAbility(std::string bundleName)
HILOG_DEBUG("start.");
for (auto it = installedAbilities_.begin(); it != installedAbilities_.end();) {
if (it->GetPackageName() == bundleName) {
HILOG_DEBUG("Removed %{public}s from InstalledAbility: ", bundleName.c_str());
installedAbilities_.erase(it);
} else {
++it;
}
}
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
}
void AccessibilityAccountData::ClearInstalledAbility()
@ -822,10 +820,10 @@ bool AccessibilityAccountData::DisableAbilities(std::map<std::string, AppExecFwk
{
HILOG_DEBUG("start.");
for (auto &disableAbility : it) {
HILOG_DEBUG("DisableAbilities URI(%{public}s)", disableAbility.first.c_str());
enabledAbilities_.erase(disableAbility.first);
RemoveEnabledFromPref(disableAbility.second.GetBundleName());
}
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
return true;
}

View File

@ -306,7 +306,7 @@ void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::Element
HILOG_DEBUG("Connect failed!");
accountData_->RemoveEnabledAbility(elementName_);
accountData_->RemoveConnectingA11yAbility(elementName_);
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
// temp deal: Notify setting
return;
}
@ -361,6 +361,7 @@ void AccessibleAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::Elem
sptr<AccessibleAbilityConnection> pointer = this;
accountData_->RemoveConnectedAbility(pointer);
accountData_->RemoveEnabledAbility(element);
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
int32_t currentAccountId = DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->GetCurrentAccountId();
if (accountData_->GetAccountId() == currentAccountId) {
@ -540,6 +541,7 @@ void AccessibleAbilityConnection::AccessibleAbilityConnectionDeathRecipient::OnR
accountData->GetAccessibleAbilityConnection(recipientElementName_.GetURI());
accountData->RemoveConnectedAbility(connection);
accountData->RemoveEnabledAbility(recipientElementName_);
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAccessibilityManagerService();
// temp deal: notify setting
}

View File

@ -542,6 +542,7 @@ void AccessibleAbilityManagerService::PackageRemoved(std::string& bundleName)
}
if (needUpdateAbility) {
UpdateAbilities();
UpdateAccessibilityManagerService();
}
}
@ -983,7 +984,7 @@ void AccessibleAbilityManagerService::RemoveUITestClient(sptr<AccessibleAbilityC
// remove installed ability
currentAccountData->RemoveInstalledAbility("com.example.uitest");
UpdateAbilities();
// remove connected ability
currentAccountData->RemoveUITestConnectedAbility(connection);
connection->OnAbilityDisconnectDone(connection->GetElementName(), 0);

View File

@ -30,7 +30,6 @@ config("module_private_config") {
include_dirs = aams_mock_include_dirs
include_dirs += [
"mock/aafwk/include",
"mock/powermanager/include",
"../aams/test/mock/",
"//third_party/json/include",
"//utils/native/base/include",
@ -55,7 +54,6 @@ config("module_private_config") {
"//utils/native/base/include",
"//foundation/appexecfwk/standard/kits/appkit/native/app/include",
"//base/global/resmgr_standard/interfaces/innerkits/include",
#"//foundation/distributedschedule/samgr/services/samgr/native/include",
#"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include",

View File

@ -16,6 +16,7 @@ AAMS_MOCK_PATH = "//base/accessibility/services/test/mock"
aams_mock_include_dirs = [
"$AAMS_MOCK_PATH/distributeddatamgr/include",
"$AAMS_MOCK_PATH/multimodalinput/include",
"$AAMS_MOCK_PATH/powermanager/include",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_preferences/include",
"//foundation/multimodalinput/input/common/include",
"//foundation/multimodalinput/input/interfaces/native/innerkits/proxy/include",

View File

@ -1,148 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef POWERMGR_POWER_STATE_MACHINE_INFO_H
#define POWERMGR_POWER_STATE_MACHINE_INFO_H
#include <string>
#include <parcel.h>
namespace OHOS {
namespace PowerMgr {
/*
* If already dimmed, extend the dim timeout but do not brighten. This flag is useful for keeping
* the screen on little longer without causing a visible change such as when the power key is pressed.
*/
constexpr uint32_t REFRESH_ACTIVITY_NO_CHANGE_LIGHTS = 1 << 0;
constexpr uint32_t REFRESH_ACTIVITY_NEED_CHANGE_LIGHTS = 0;
/*
* Indicate whether device enter suspend immediately
*/
constexpr uint32_t SUSPEND_DEVICE_IMMEDIATELY = 1 << 0;
// This is use for judge whether the time is valid.
constexpr int DEFAULT_SYSTEM_START_TIME = 0;
// Max datails string length
constexpr int MAX_STRING_LENGTH = 128;
// Throttling interval for user activity calls.
constexpr int64_t MIN_TIME_MS_BETWEEN_USERACTIVITIES = 100; // 100ms
/**
* PowerState of Device.
*/
enum class PowerState : uint32_t {
/**
* Power State: screen on and cpu on.
*/
AWAKE = 0,
/**
* Power State: screen off and cpu on.
*/
INACTIVE,
/**
* Power State: screen off and cpu off.
*/
SLEEP,
/**
* Power State: unknown.
*/
UNKNOWN,
};
/**
* Display State of Device.
*/
enum class DisplayState : uint32_t {
DISPLAY_OFF = 0,
DISPLAY_DIM = 1,
DISPLAY_ON = 2,
DISPLAY_SUSPEND = 3,
};
// UserActivityType list, must sync with A_PMS
enum class UserActivityType : uint32_t {
USER_ACTIVITY_TYPE_OTHER = 0,
USER_ACTIVITY_TYPE_BUTTON = 1,
USER_ACTIVITY_TYPE_TOUCH = 2,
USER_ACTIVITY_TYPE_ACCESSIBILITY = 3,
USER_ACTIVITY_TYPE_ATTENTION = 4,
USER_ACTIVITY_TYPE_SOFTWARE = 5,
USER_ACTIVITY_TYPE_MAX = USER_ACTIVITY_TYPE_SOFTWARE,
};
// WakeupReasonType list
enum class WakeupDeviceType : uint32_t {
WAKEUP_DEVICE_UNKNOWN = 0,
WAKEUP_DEVICE_POWER_BUTTON = 1,
WAKEUP_DEVICE_APPLICATION = 2,
WAKEUP_DEVICE_PLUGGED_IN = 3,
WAKEUP_DEVICE_GESTURE = 4,
WAKEUP_DEVICE_CAMERA_LAUNCH = 5,
WAKEUP_DEVICE_WAKE_KEY = 6,
WAKEUP_DEVICE_WAKE_MOTION = 7,
WAKEUP_DEVICE_HDMI = 8,
WAKEUP_DEVICE_LID = 9,
WAKEUP_DEVICE_DOUBLE_CLICK = 10,
WAKEUP_DEVICE_KEYBOARD = 11,
WAKEUP_DEVICE_MOUSE = 12,
WAKEUP_DEVICE_MAX = WAKEUP_DEVICE_MOUSE,
};
// SuspendDeviceType list
enum class SuspendDeviceType : uint32_t {
SUSPEND_DEVICE_REASON_MIN = 0,
SUSPEND_DEVICE_REASON_APPLICATION = SUSPEND_DEVICE_REASON_MIN,
SUSPEND_DEVICE_REASON_DEVICE_ADMIN = 1,
SUSPEND_DEVICE_REASON_TIMEOUT = 2,
SUSPEND_DEVICE_REASON_LID_SWITCH = 3,
SUSPEND_DEVICE_REASON_POWER_BUTTON = 4,
SUSPEND_DEVICE_REASON_HDMI = 5,
SUSPEND_DEVICE_REASON_SLEEP_BUTTON = 6,
SUSPEND_DEVICE_REASON_ACCESSIBILITY = 7,
SUSPEND_DEVICE_REASON_FORCE_SUSPEND = 8,
SUSPEND_DEVICE_REASON_MAX = SUSPEND_DEVICE_REASON_FORCE_SUSPEND,
};
enum class StateChangeReason : uint32_t {
STATE_CHANGE_REASON_INIT = 0,
STATE_CHANGE_REASON_TIMEOUT = 1,
STATE_CHANGE_REASON_RUNNING_LOCK = 2,
STATE_CHANGE_REASON_BATTERY = 3,
STATE_CHANGE_REASON_THERMAL = 4,
STATE_CHANGE_REASON_WORK = 5,
STATE_CHANGE_REASON_SYSTEM = 6,
STATE_CHANGE_REASON_APPLICATION = 10,
STATE_CHANGE_REASON_SETTINGS = 11,
STATE_CHANGE_REASON_HARD_KEY = 12,
STATE_CHANGE_REASON_TOUCH = 13,
STATE_CHANGE_REASON_CABLE = 14,
STATE_CHANGE_REASON_SENSOR = 15,
STATE_CHANGE_REASON_LID = 16,
STATE_CHANGE_REASON_CAMERA = 17,
STATE_CHANGE_REASON_ACCESSIBILITY = 18,
STATE_CHANGE_REASON_RESET = 19,
STATE_CHANGE_REASON_REMOTE = 100,
STATE_CHANGE_REASON_UNKNOWN = 1000,
};
} // namespace PowerMgr
} // namespace OHOS
#endif // POWERMGR_POWER_STATE_MACHINE_INFO_H

View File

@ -17,14 +17,11 @@
namespace OHOS {
namespace PowerMgr {
PowerMgrClient::PowerMgrClient() {}
PowerMgrClient::~PowerMgrClient()
{}
PowerMgrClient::~PowerMgrClient(){}
ErrCode PowerMgrClient::Connect()
{
return ERR_OK;
}
@ -123,6 +120,5 @@ std::string PowerMgrClient::Dump(const std::vector<std::string>& args)
{
return "ERR_OK";
}
} // namespace PowerMgr
} // namespace OHOS