1 /*
2 * Copyright (c) 2020 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "samgr_maintenance.h"
17 #include <stdio.h>
18 #include "service_impl.h"
19 #include "samgr_lite_inner.h"
20
SAMGR_PrintServices(void)21 void SAMGR_PrintServices(void)
22 {
23 SamgrLiteImpl *samgr = GET_OBJECT(SAMGR_GetInstance(), SamgrLiteImpl, vtbl);
24 int16 num = VECTOR_Num(&samgr->services);
25 printf("[hctest][Maintenance]Print Services(%d) Information:\n", num);
26 if (num == 0) {
27 return;
28 }
29
30 MUTEX_Lock(samgr->mutex);
31 int16 size = VECTOR_Size(&(samgr->services));
32 int i;
33 for (i = 0; i < size; ++i) {
34 ServiceImpl *impl = VECTOR_At(&(samgr->services), i);
35 if (impl == NULL) {
36 continue;
37 }
38
39 MUTEX_Unlock(samgr->mutex);
40 const char *name = impl->service->GetName(impl->service);
41 printf("[hctest][Service:%d]<status:%d, name:%s, default:%p, features:%d, task:%p>\n",
42 impl->serviceId, impl->inited, name, impl->defaultApi, VECTOR_Num(&impl->features), impl->taskPool);
43
44 TaskPool *pool = impl->taskPool;
45 if (pool != NULL) {
46 printf("[hctest][TaskPool:%p]<tid:%p, qid:%p, ref:%d, pri:%d, stack:0x%x>\n",
47 pool, pool->tasks[0], pool->queueId, pool->ref, pool->priority, pool->stackSize);
48 }
49
50 int16 featureSize = VECTOR_Size(&impl->features);
51 int j;
52 for (j = 0; j < featureSize; ++j) {
53 FeatureImpl *feature = VECTOR_At(&impl->features, j);
54 if (feature == NULL) {
55 continue;
56 }
57 name = feature->feature->GetName(feature->feature);
58 printf("[hctest][Feature:%d]<name:%s, api:%p>\n", j, name, feature->iUnknown);
59 }
60 MUTEX_Lock(samgr->mutex);
61 }
62 MUTEX_Unlock(samgr->mutex);
63 }