• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import {PersistentStoreProxy} from 'common/persistent_store_proxy';
17import {Trace} from 'trace/trace';
18import {Traces} from 'trace/traces';
19import {HierarchyTreeNode} from 'trace/tree_node/hierarchy_tree_node';
20import {NotifyHierarchyViewCallbackType} from 'viewers/common/abstract_hierarchy_viewer_presenter';
21import {AbstractPresenterInputMethod} from 'viewers/common/abstract_presenter_input_method';
22import {VISIBLE_CHIP} from 'viewers/common/chip';
23import {HierarchyPresenter} from 'viewers/common/hierarchy_presenter';
24import {TableProperties} from 'viewers/common/table_properties';
25import {UserOptions} from 'viewers/common/user_options';
26import {UpdateDisplayNames} from './operations/update_display_names';
27
28export class PresenterInputMethodClients extends AbstractPresenterInputMethod {
29  protected override hierarchyPresenter = new HierarchyPresenter(
30    PersistentStoreProxy.new<UserOptions>(
31      'ImeHierarchyOptions',
32      {
33        simplifyNames: {
34          name: 'Simplify names',
35          enabled: true,
36        },
37        showOnlyVisible: {
38          name: 'Show only',
39          chip: VISIBLE_CHIP,
40          enabled: false,
41        },
42        flat: {
43          name: 'Flat',
44          enabled: false,
45        },
46      },
47      this.storage,
48    ),
49    [],
50    true,
51    false,
52    this.getHierarchyTreeNameStrategy,
53    [new UpdateDisplayNames()],
54  );
55  constructor(
56    trace: Trace<HierarchyTreeNode>,
57    traces: Traces,
58    storage: Storage,
59    notifyViewCallback: NotifyHierarchyViewCallbackType,
60  ) {
61    super(trace, traces, storage, notifyViewCallback);
62  }
63
64  protected override getHierarchyTableProperties(): TableProperties {
65    const client = this.hierarchyPresenter
66      .getCurrentHierarchyTreesForTrace(this.imeTrace)
67      ?.at(0)
68      ?.getChildByName('client');
69    const curId = client
70      ?.getEagerPropertyByName('inputMethodManager')
71      ?.getChildByName('curId')
72      ?.formattedValue();
73    const packageName = client
74      ?.getEagerPropertyByName('editorInfo')
75      ?.getChildByName('packageName')
76      ?.formattedValue();
77    return {
78      ...new ImClientsTableProperties(curId, packageName),
79    };
80  }
81}
82
83class ImClientsTableProperties {
84  constructor(
85    public inputMethodId: string | undefined,
86    public packageName: string | undefined,
87  ) {}
88}
89