1#!/usr/bin/env python3 2#-*- coding: utf-8 -*- 3 4# Copyright (c) 2025 Huawei Device Co., Ltd. 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import os 18import sys 19 20current_dir = os.path.abspath(os.path.dirname(__file__)) 21rootPath = os.path.split(current_dir)[0] 22awPath = os.path.split(rootPath)[0] 23sys.path.append(rootPath) 24sys.path.append(os.path.join(awPath, "aw")) 25 26import time 27from devicetest.core.test_case import TestCase, CheckPoint, get_report_dir 28from hypium import UiDriver 29from hypium.action.os_hypium.device_logger import DeviceLogger 30from get_source_path import get_source_path 31from push_remove_source import push_source, remove_source 32 33 34class case21_add001(TestCase): 35 36 def __init__(self, configs): 37 self.TAG = self.__class__.__name__ 38 TestCase.__init__(self, self.TAG, configs) 39 self.tests = [ 40 "test_step" 41 ] 42 self.driver = UiDriver(self.device1) 43 self.sn = self.device1.device_sn 44 self.source_path = {} 45 46 def setup(self): 47 self.log.info("case21_add001 start") 48 need_source = {"cfg": True, "listen_test": False, "audio_ability": False, "ondemand": False, 49 "proxy": False, "para": False} 50 self.source_path = get_source_path(need_source=need_source, casename="level0/case21_add001") 51 push_source(source_path=self.source_path, driver=self.driver, sn=self.sn) 52 53 def test_step(self): 54 driver = self.driver 55 driver.Screen.close() 56 time.sleep(20) 57 result = driver.System.execute_command("hidumper -ls") 58 max_wait_time = 5 59 wait_time = 0 60 while ("1494" in result and wait_time <= max_wait_time): 61 wait_time += 1 62 time.sleep(1) 63 result = driver.System.execute_command("hidumper -ls") 64 CheckPoint("Initially, 1494 was not loaded") 65 assert "1494" not in result 66 67 device_logger = DeviceLogger(driver).set_filter_string("01800") 68 device_logger.start_log(get_report_dir() + "//case21_add001.txt") 69 driver.System.execute_command("./system/bin/sa_main /system/profile/listen_test.json") 70 device_logger.stop_log() 71 device_logger.check_log("AddSystemProcessInner PERMISSION DENIED!", EXCEPTION=True) 72 73 result = driver.System.execute_command("hidumper -ls") 74 max_wait_time = 5 75 wait_time = 0 76 while ("1494" in result and wait_time <= max_wait_time): 77 wait_time += 1 78 time.sleep(1) 79 result = driver.System.execute_command("hidumper -ls") 80 CheckPoint("Non native process add intercepted, 1494 not loaded") 81 assert "1494" not in result 82 83 def teardown(self): 84 self.driver.Screen.close() 85 remove_source(source_path=self.source_path, driver=self.driver, sn=self.sn) 86 self.log.info("case21_add001 down") 87