/** * 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. */ #include "ActsPMSTest.h" #include using namespace std; using namespace testing::ext; static PmsInnerApi *g_interface; static PermissionTrans g_systemPers[] = { { "ohos.permission.CAMERA", "for CAMERA use", INUSE, }, { "ohos.permission.RECORD_AUDIO", "for RECORD_AUDIO use", ALWAYS, }, { "ohos.permission.READ_MEDIA_AUDIO", "for READ_MEDIA_AUDIO use", INUSE, }, { "ohos.permission.READ_MEDIA_IMAGES", "for READ_MEDIA_IMAGES use", ALWAYS, }, { "ohos.permission.READ_MEDIA_VIDEO", "for READ_MEDIA_VIDEO use", INUSE, }, { "ohos.permission.WRITE_MEDIA_AUDIO", "for WRITE_MEDIA_AUDIO use", ALWAYS, }, { "ohos.permission.WRITE_MEDIA_IMAGES", "for WRITE_MEDIA_IMAGES use", INUSE, }, { "ohos.permission.WRITE_MEDIA_VIDEO", "for WRITE_MEDIA_VIDEO use", ALWAYS, }, { "ohos.permission.MODIFY_AUDIO_SETTINGS", "for MODIFY_AUDIO_SETTINGS use", INUSE, }, }; class ActsPMSUpdatePermissionTest:public testing::Test{ protected: static void SetUpTestCase(void) { CreateAppDir(); IUnknown *iUnknown = SAMGR_GetInstance()->GetFeatureApi(PERMISSION_SERVICE, PERM_INNER); iUnknown->QueryInterface(iUnknown, DEFAULT_VERSION, (void **) &g_interface); setuid(0); } static void TearDownTestCase(void) {} virtual void SetUp() {} virtual void TearDown() { DeletePermissions(TEST_APP_ID); DeletePermissions(TEST_APP_ID2); DeletePermissions(SUBTEST_APP_ID); UnLoadPermissions(TEST_TASKID); UnLoadPermissions(SUBTEST_TASKID); } }; long GetCurrentTimeMillis() { struct timeval current; gettimeofday(¤t,NULL); return current.tv_sec*MILLISECOND+current.tv_usec/MILLISECOND; } /** * @tc.number Security_AppSecurity_PermissionManager_L1_UpdatePermissionFlags_001 * @tc.name Update permission flags * @tc.desc [C- SECURITY -1000] */ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_001, Function | MediumTest | Level2) { SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); PermissionSaved *permissions=NULL; int permNum=0; int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<