!1457 回退 'Pull Request !1450 : 挑单5.0'

Merge pull request !1457 from oh_ci/revert-merge-1450-OpenHarmony-5.0-Release
This commit is contained in:
oh_ci 2024-09-06 12:57:49 +00:00 committed by Gitee
commit 70c34034da
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 26 additions and 109 deletions

View File

@ -51,7 +51,7 @@ bool InputmethodDump::Dump(int fd, const std::vector<std::string> &args)
if (command == CMD_HELP) {
ShowHelp(fd);
} else if (command == CMD_ALL_DUMP) {
if (dumpAllMethod_ == nullptr) {
if (!dumpAllMethod_) {
return false;
}
dumpAllMethod_(fd);

View File

@ -249,7 +249,7 @@ bool ITypesUtil::Unmarshalling(TextTotalConfig &output, MessageParcel &data)
bool ITypesUtil::Marshalling(const InputClientInfo &input, MessageParcel &data)
{
if (!Marshal(data, input.pid, input.uid, input.userID, input.isShowKeyboard, input.eventFlag, input.config,
input.state, input.isNotifyInputStart, input.needHide)) {
input.state, input.isNotifyInputStart)) {
IMSA_HILOGE("write InputClientInfo to message parcel failed.");
return false;
}
@ -259,7 +259,7 @@ bool ITypesUtil::Marshalling(const InputClientInfo &input, MessageParcel &data)
bool ITypesUtil::Unmarshalling(InputClientInfo &output, MessageParcel &data)
{
if (!Unmarshal(data, output.pid, output.uid, output.userID, output.isShowKeyboard, output.eventFlag, output.config,
output.state, output.isNotifyInputStart, output.needHide)) {
output.state, output.isNotifyInputStart)) {
IMSA_HILOGE("read InputClientInfo from message parcel failed.");
return false;
}

View File

@ -244,13 +244,6 @@ int32_t InputMethodAbility::StartInput(const InputClientInfo &clientInfo, bool i
IMSA_HILOGI("IMA isShowKeyboard: %{public}d, isBindFromClient: %{public}d.", clientInfo.isShowKeyboard,
isBindFromClient);
SetInputDataChannel(clientInfo.channel);
if (clientInfo.needHide) {
IMSA_HILOGD("pwd or normal input pattern changed, need hide panel first.");
auto panel = GetSoftKeyboardPanel();
if (panel != nullptr) {
panel->HidePanel();
}
}
int32_t ret = isBindFromClient ? InvokeStartInputCallback(clientInfo.config, clientInfo.isNotifyInputStart)
: InvokeStartInputCallback(clientInfo.isNotifyInputStart);
if (ret != ErrorCode::NO_ERROR) {

View File

@ -149,10 +149,6 @@ int32_t InputMethodPanel::DestroyPanel()
IMSA_HILOGE("InputMethodPanel, hide panel failed, ret: %{public}d!", ret);
return ret;
}
if (window_ == nullptr) {
IMSA_HILOGE("window_ is nullptr!");
return ErrorCode::ERROR_NULL_POINTER;
}
if (panelType_ == SOFT_KEYBOARD) {
UnregisterKeyboardPanelInfoChangeListener();
}

View File

@ -49,7 +49,6 @@ struct InputClientInfo {
sptr<InputDeathRecipient> deathRecipient{ nullptr }; // death recipient of client
ClientState state{ ClientState::INACTIVE }; // the state of input client
bool isNotifyInputStart{ true };
bool needHide { false }; // panel needs to be hidden first, when input pattern is switched between pwd and normal
uint32_t uiExtensionTokenId{ IMF_INVALID_TOKENID }; // the value is valid only in curClient and only UIExtension
};
} // namespace MiscServices

View File

@ -110,10 +110,7 @@ int32_t ImeSystemCmdChannel::ConnectSystemCmd(const sptr<OnSystemCmdListener> &l
int32_t ImeSystemCmdChannel::RunConnectSystemCmd()
{
if (systemChannelStub_ == nullptr) {
std::lock_guard<decltype(systemChannelMutex_)> lock(systemChannelMutex_);
if (systemChannelStub_ == nullptr) {
systemChannelStub_ = new (std::nothrow) SystemCmdChannelStub();
}
systemChannelStub_ = new (std::nothrow) SystemCmdChannelStub();
if (systemChannelStub_ == nullptr) {
IMSA_HILOGE("channel is nullptr!");
return ErrorCode::ERROR_NULL_POINTER;

View File

@ -42,11 +42,7 @@ using namespace std::chrono;
sptr<InputMethodController> InputMethodController::instance_;
std::shared_ptr<AppExecFwk::EventHandler> InputMethodController::handler_{ nullptr };
std::mutex InputMethodController::instanceLock_;
std::mutex InputMethodController::logLock_;
int InputMethodController::keyEventCountInPeriod_ = 0;
std::chrono::system_clock::time_point InputMethodController::startLogTime_ = system_clock::now();
constexpr int32_t LOOP_COUNT = 5;
constexpr int32_t LOG_MAX_TIME = 20;
constexpr int64_t DELAY_TIME = 100;
constexpr int32_t ACE_DEAL_TIME_OUT = 200;
InputMethodController::InputMethodController()
@ -731,26 +727,8 @@ int32_t InputMethodController::GetTextIndexAtCursor(int32_t &index)
return ErrorCode::NO_ERROR;
}
void InputMethodController::PrintKeyEventLog()
{
std::lock_guard<std::mutex> lock(logLock_);
auto now = system_clock::now();
if (keyEventCountInPeriod_ == 0) {
startLogTime_ = now;
}
keyEventCountInPeriod_++;
if (std::chrono::duration_cast<seconds>(now - startLogTime_).count() >= LOG_MAX_TIME) {
auto start = std::chrono::duration_cast<seconds>(startLogTime_.time_since_epoch()).count();
auto end = std::chrono::duration_cast<seconds>(now.time_since_epoch()).count();
IMSA_HILOGI("KeyEventCountInPeriod: %{public}d, startTime: %{public}lld, endTime: %{public}lld",
keyEventCountInPeriod_, start, end);
keyEventCountInPeriod_ = 0;
}
}
int32_t InputMethodController::DispatchKeyEvent(std::shared_ptr<MMI::KeyEvent> keyEvent, KeyEventCallback callback)
{
PrintKeyEventLog();
KeyEventInfo keyEventInfo = { std::chrono::system_clock::now(), keyEvent };
keyEventQueue_.Push(keyEventInfo);
InputMethodSyncTrace tracer("DispatchKeyEvent trace");

View File

@ -116,7 +116,6 @@ private:
sptr<InputDeathRecipient> agentDeathRecipient_;
std::atomic_bool isSystemCmdConnect_{ false };
std::mutex systemChannelMutex_;
sptr<ISystemCmdChannel> systemChannelStub_;
};
} // namespace MiscServices

View File

@ -17,8 +17,6 @@
#define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_CONTROLLER_H
#include <atomic>
#include <chrono>
#include <ctime>
#include <condition_variable>
#include <mutex>
#include <thread>
@ -802,7 +800,6 @@ private:
void SetAgent(sptr<IRemoteObject> &agentObject);
std::shared_ptr<IInputMethodAgent> GetAgent();
void PrintLogIfAceTimeout(int64_t start);
void PrintKeyEventLog();
std::shared_ptr<ControllerListener> controllerListener_;
std::mutex abilityLock_;
@ -830,10 +827,6 @@ private:
static sptr<InputMethodController> instance_;
static std::shared_ptr<AppExecFwk::EventHandler> handler_;
static std::mutex logLock_;
static int keyEventCountInPeriod_;
static std::chrono::system_clock::time_point startLogTime_;
std::atomic_bool isEditable_{ false };
std::atomic_bool isBound_{ false };
std::atomic_bool bootCompleted_{ false };

View File

@ -43,25 +43,24 @@ struct UserImeConfig : public Serializable {
class SettingsDataUtils : public RefBase {
public:
static sptr<SettingsDataUtils> GetInstance();
std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();
int32_t CreateAndRegisterObserver(const std::string &key, SettingsDataObserver::CallbackFunc func);
int32_t GetStringValue(const std::string &key, std::string &value);
sptr<IRemoteObject> GetToken();
std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();
bool ReleaseDataShareHelper(std::shared_ptr<DataShare::DataShareHelper> &helper);
int32_t CreateAndRegisterObserver(const std::string &key, SettingsDataObserver::CallbackFunc func);
int32_t RegisterObserver(const sptr<SettingsDataObserver> &observer);
int32_t UnregisterObserver(const sptr<SettingsDataObserver> &observer);
Uri GenerateTargetUri(const std::string &key);
private:
SettingsDataUtils() = default;
~SettingsDataUtils();
bool ReleaseDataShareHelper(std::shared_ptr<DataShare::DataShareHelper> &helper);
int32_t RegisterObserver(const sptr<SettingsDataObserver> &observer);
int32_t UnregisterObserver(const sptr<SettingsDataObserver> &observer);
Uri GenerateTargetUri(const std::string &key);
sptr<IRemoteObject> GetToken();
private:
static std::mutex instanceMutex_;
static sptr<SettingsDataUtils> instance_;
std::mutex tokenMutex_;
sptr<IRemoteObject> remoteObj_ = nullptr;
std::mutex observerListMutex_;
std::vector<sptr<SettingsDataObserver>> observerList_;
};
} // namespace MiscServices

View File

@ -82,8 +82,6 @@ int32_t SettingsDataUtils::RegisterObserver(const sptr<SettingsDataObserver> &ob
helper->RegisterObserver(uri, observer);
ReleaseDataShareHelper(helper);
IMSA_HILOGD("succeed to register observer of uri: %{public}s.", uri.ToString().c_str());
std::lock_guard<decltype(observerListMutex_)> lock(observerListMutex_);
observerList_.push_back(observer);
return ErrorCode::NO_ERROR;
}

View File

@ -118,7 +118,6 @@ public:
int32_t RemoveCurrentClient();
std::shared_ptr<ImeData> GetImeData(ImeType type);
BlockQueue<SwitchInfo>& GetSwitchQueue();
bool CheckPwdInputPatternConv(InputClientInfo &clientInfo);
private:
struct ResetManager {

View File

@ -285,9 +285,6 @@ int32_t InputMethodSystemAbility::StartInput(InputClientInfo &inputClientInfo, s
// notify inputStart when caller pid different from both current client and inactive client
inputClientInfo.isNotifyInputStart = true;
}
if (inputClientInfo.isNotifyInputStart) {
inputClientInfo.needHide = session->CheckPwdInputPatternConv(inputClientInfo);
}
if (!session->IsProxyImeEnable()) {
CheckInputTypeOption(userId, inputClientInfo);
}
@ -1287,6 +1284,7 @@ void InputMethodSystemAbility::InitMonitors()
IMSA_HILOGW("Enter security mode.");
enableSecurityMode_ = true;
}
RegisterDataShareObserver();
}
int32_t InputMethodSystemAbility::RegisterDataShareObserver()

View File

@ -536,7 +536,6 @@ int32_t PerUserSession::OnStartInput(const InputClientInfo &inputClientInfo, spt
InputClientInfo infoTemp = *clientInfo;
infoTemp.isShowKeyboard = inputClientInfo.isShowKeyboard;
infoTemp.isNotifyInputStart = inputClientInfo.isNotifyInputStart;
infoTemp.needHide = inputClientInfo.needHide;
auto imeType = IsProxyImeEnable() ? ImeType::PROXY_IME : ImeType::IME;
int32_t ret = BindClientWithIme(std::make_shared<InputClientInfo>(infoTemp), imeType, true);
if (ret != ErrorCode::NO_ERROR) {
@ -1397,24 +1396,5 @@ BlockQueue<SwitchInfo>& PerUserSession::GetSwitchQueue()
{
return switchQueue_;
}
bool PerUserSession::CheckPwdInputPatternConv(InputClientInfo &newClientInfo)
{
auto exClient = GetCurrentClient();
if (exClient == nullptr) {
exClient = GetInactiveClient();
}
auto exClientInfo = exClient != nullptr ? GetClientInfo(exClient->AsObject()) : nullptr;
if (exClientInfo == nullptr) {
IMSA_HILOGE("exClientInfo is nullptr!");
return false;
}
if (newClientInfo.config.inputAttribute.GetSecurityFlag()) {
IMSA_HILOGI("new input pattern is pwd.");
return !exClientInfo->config.inputAttribute.GetSecurityFlag();
}
IMSA_HILOGI("new input pattern is normal.");
return exClientInfo->config.inputAttribute.GetSecurityFlag();
}
} // namespace MiscServices
} // namespace OHOS

View File

@ -13,12 +13,10 @@
* limitations under the License.
*/
#define private public
#include "settings_data_utils.h"
#undef private
#include "settingsdatautils_fuzzer.h"
#include "settings_data_utils.h"
using namespace OHOS::MiscServices;
namespace OHOS {
void FuzzGetToken()

View File

@ -47,11 +47,7 @@ using namespace Rosen;
constexpr int32_t INVALID_USER_ID = -1;
constexpr int32_t MAIN_USER_ID = 100;
constexpr const uint16_t EACH_LINE_LENGTH = 500;
constexpr int32_t PERMISSION_NUM = 4;
constexpr int32_t FIRST_PARAM_INDEX = 0;
constexpr int32_t SECOND_PARAM_INDEX = 1;
constexpr int32_t THIRD_PARAM_INDEX = 2;
constexpr int32_t FOURTH_PARAM_INDEX = 3;
constexpr int32_t PERMISSION_NUM = 3;
constexpr const char *SETTING_COLUMN_KEYWORD = "KEYWORD";
constexpr const char *SETTING_COLUMN_VALUE = "VALUE";
static constexpr int32_t MAX_TIMEOUT_WAIT_FOCUS = 2000;
@ -190,7 +186,6 @@ bool TddUtil::ExecuteCmd(const std::string &cmd, std::string &result)
std::stringstream output;
FILE *ptr = popen(cmd.c_str(), "r");
if (ptr != nullptr) {
IMSA_HILOGI("Execute cmd: %{public}s", cmd.c_str());
while (fgets(buff, sizeof(buff), ptr) != nullptr) {
output << buff;
}
@ -269,10 +264,9 @@ int TddUtil::GetUserIdByBundleName(const std::string &bundleName, const int curr
void TddUtil::GrantNativePermission()
{
const char **perms = new const char *[PERMISSION_NUM];
perms[FIRST_PARAM_INDEX] = "ohos.permission.MANAGE_SECURE_SETTINGS";
perms[SECOND_PARAM_INDEX] = "ohos.permission.CONNECT_IME_ABILITY";
perms[THIRD_PARAM_INDEX] = "ohos.permission.MANAGE_SETTINGS";
perms[FOURTH_PARAM_INDEX] = "ohos.permission.INJECT_INPUT_EVENT";
perms[0] = "ohos.permission.MANAGE_SECURE_SETTINGS";
perms[1] = "ohos.permission.CONNECT_IME_ABILITY";
perms[2] = "ohos.permission.MANAGE_SETTINGS";
TokenInfoParams infoInstance = {
.dcapsNum = 0,
.permsNum = PERMISSION_NUM,

View File

@ -37,7 +37,6 @@ constexpr int32_t RETRY_INTERVAL = 100;
constexpr int32_t RETRY_TIME = 30;
constexpr int32_t WAIT_APP_START_COMPLETE = 1;
constexpr int32_t WAIT_BIND_COMPLETE = 1;
constexpr int32_t WAIT_CLICK_COMPLETE = 100;
constexpr const char *BUNDLENAME = "com.example.editorbox";
class ImeProxyTest : public testing::Test {
public:
@ -103,7 +102,6 @@ public:
std::string result;
auto ret = TddUtil::ExecuteCmd(cmd, result);
EXPECT_TRUE(ret);
usleep(WAIT_CLICK_COMPLETE); // ensure click complete
}
static void StopApp()

View File

@ -948,11 +948,11 @@ HWTEST_F(InputMethodControllerTest, testIMCOnSelectionChange09, TestSize.Level0)
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
InputMethodControllerTest::ResetKeyboardListenerTextConfig();
InputMethodControllerTest::text_ = "test";
std::u16string text = Str8ToStr16("test1");
InputMethodControllerTest::TriggerSelectionChangeCallback(text, 1, 6);
EXPECT_EQ(InputMethodControllerTest::text_, "test1");
EXPECT_EQ(InputMethodControllerTest::newBegin_, 1);
EXPECT_EQ(InputMethodControllerTest::newEnd_, 6);
std::u16string text = Str8ToStr16("");
InputMethodControllerTest::TriggerSelectionChangeCallback(text, 0, 0);
EXPECT_EQ(InputMethodControllerTest::text_, "");
EXPECT_EQ(InputMethodControllerTest::newBegin_, 0);
EXPECT_EQ(InputMethodControllerTest::newEnd_, 0);
}
/**

View File

@ -72,8 +72,8 @@ void InputMethodSwitchTest::SetUpTestCase(void)
TddUtil::GetEnableData(beforeValue);
TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, allEnableIme);
TddUtil::StorageSelfTokenID();
TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, "ohos.inputMethod.test",
{ "ohos.permission.CONNECT_IME_ABILITY", "ohos.permission.INJECT_INPUT_EVENT" }));
TddUtil::SetTestTokenID(
TddUtil::AllocTestTokenID(true, "ohos.inputMethod.test", { "ohos.permission.CONNECT_IME_ABILITY" }));
imc_ = InputMethodController::GetInstance();
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(EVENT_IME_CHANGE_MASK, listener);

View File

@ -15,11 +15,9 @@
#define private public
#define protected public
#include "security_mode_parser.h"
#include "settings_data_utils.h"
#include "input_method_system_ability.h"
#include "input_method_system_ability.h"
#undef private
#include <gtest/gtest.h>