1 /*
2  * Copyright (C) 2023 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  */
16 package com.android.statsd.shelltools;
17 
18 import com.android.internal.os.ExperimentIdsProto;
19 import com.android.internal.os.UidDataProto;
20 import com.android.os.ActiveConfigProto;
21 import com.android.os.ShellConfig;
22 import com.android.os.adservices.AdservicesExtensionAtoms;
23 import com.android.os.art.ArtExtensionAtoms;
24 import com.android.os.art.BackgroundExtensionDexoptAtoms;
25 import com.android.os.art.OdrefreshExtensionAtoms;
26 import com.android.os.automotive.caruilib.AutomotiveCaruilibAtoms;
27 import com.android.os.bluetooth.BluetoothExtensionAtoms;
28 import com.android.os.devicelogs.DeviceLogsAtoms;
29 import com.android.os.dnd.DndAtoms;
30 import com.android.os.dnd.DndExtensionAtoms;
31 import com.android.os.expresslog.ExpresslogExtensionAtoms;
32 import com.android.os.framework.FrameworkExtensionAtoms;
33 import com.android.os.gps.GpsAtoms;
34 import com.android.os.grammaticalinflection.GrammaticalInflectionExtensionAtoms;
35 import com.android.os.hardware.biometrics.BiometricsAtoms;
36 import com.android.os.healthfitness.api.ApiExtensionAtoms;
37 import com.android.os.healthfitness.ui.UiExtensionAtoms;
38 import com.android.os.hotword.HotwordAtoms;
39 import com.android.os.kernel.KernelAtoms;
40 import com.android.os.locale.LocaleAtoms;
41 import com.android.os.location.LocationAtoms;
42 import com.android.os.location.LocationExtensionAtoms;
43 import com.android.os.media.MediaDrmAtoms;
44 import com.android.os.memorysafety.MemorysafetyExtensionAtoms;
45 import com.android.os.permissioncontroller.PermissioncontrollerExtensionAtoms;
46 import com.android.os.providers.mediaprovider.MediaProviderAtoms;
47 import com.android.os.settings.SettingsExtensionAtoms;
48 import com.android.os.statsd.ShellDataProto;
49 import com.android.os.sysui.SysuiAtoms;
50 import com.android.os.telecom.TelecomExtensionAtom;
51 import com.android.os.telephony.SatelliteExtensionAtoms;
52 import com.android.os.telephony.TelephonyExtensionAtoms;
53 import com.android.os.telephony.qns.QnsExtensionAtoms;
54 import com.android.os.usb.UsbAtoms;
55 import com.android.os.uwb.UwbExtensionAtoms;
56 import com.android.os.view.inputmethod.InputmethodAtoms;
57 import com.android.os.wear.media.WearMediaAtoms;
58 import com.android.os.wear.media.WearMediaExtensionAtoms;
59 import com.android.os.wearpas.WearpasExtensionAtoms;
60 import com.android.os.wearservices.WearservicesAtoms;
61 import com.android.os.wearservices.WearservicesExtensionAtoms;
62 import com.android.os.wearsysui.WearsysuiAtoms;
63 import com.android.os.wifi.WifiExtensionAtoms;
64 import android.os.statsd.media.MediaCodecExtensionAtoms;
65 import com.android.os.credentials.CredentialsExtensionAtoms;
66 import com.android.os.sdksandbox.SdksandboxExtensionAtoms;
67 import com.android.os.apex.ApexExtensionAtoms;
68 
69 import com.google.protobuf.ExtensionRegistry;
70 
71 /**
72  * CustomExtensionRegistry for local use of statsd.
73  */
74 public class ExtensionAtomsRegistry {
75 
76     public static ExtensionRegistry REGISTRY;
77 
78     static {
79         /** In Java, when parsing a message containing extensions, you must provide an
80          * ExtensionRegistry which contains definitions of all of the extensions which you
81          * want the parser to recognize. This is necessary because Java's bytecode loading
82          * semantics do not provide any way for the protocol buffers library to automatically
83          * discover all extensions defined in your binary.
84          *
85          * See http://sites/protocol-buffers/user-docs/miscellaneous-howtos/extensions
86          * #Java_ExtensionRegistry_
87          */
88         REGISTRY = ExtensionRegistry.newInstance();
89         registerAllExtensions(REGISTRY);
90         REGISTRY = REGISTRY.getUnmodifiable();
91     }
92 
93     /**
94      * Registers all proto2 extensions.
95      */
registerAllExtensions(ExtensionRegistry extensionRegistry)96     private static void registerAllExtensions(ExtensionRegistry extensionRegistry) {
97         ExperimentIdsProto.registerAllExtensions(extensionRegistry);
98         UidDataProto.registerAllExtensions(extensionRegistry);
99         ActiveConfigProto.registerAllExtensions(extensionRegistry);
100         ShellConfig.registerAllExtensions(extensionRegistry);
101         AdservicesExtensionAtoms.registerAllExtensions(extensionRegistry);
102         AutomotiveCaruilibAtoms.registerAllExtensions(extensionRegistry);
103         BluetoothExtensionAtoms.registerAllExtensions(extensionRegistry);
104         DeviceLogsAtoms.registerAllExtensions(extensionRegistry);
105         DndAtoms.registerAllExtensions(extensionRegistry);
106         DndExtensionAtoms.registerAllExtensions(extensionRegistry);
107         ExpresslogExtensionAtoms.registerAllExtensions(extensionRegistry);
108         FrameworkExtensionAtoms.registerAllExtensions(extensionRegistry);
109         GpsAtoms.registerAllExtensions(extensionRegistry);
110         GrammaticalInflectionExtensionAtoms.registerAllExtensions(extensionRegistry);
111         BiometricsAtoms.registerAllExtensions(extensionRegistry);
112         ApiExtensionAtoms.registerAllExtensions(extensionRegistry);
113         UiExtensionAtoms.registerAllExtensions(extensionRegistry);
114         HotwordAtoms.registerAllExtensions(extensionRegistry);
115         KernelAtoms.registerAllExtensions(extensionRegistry);
116         LocaleAtoms.registerAllExtensions(extensionRegistry);
117         LocationAtoms.registerAllExtensions(extensionRegistry);
118         LocationExtensionAtoms.registerAllExtensions(extensionRegistry);
119         MediaDrmAtoms.registerAllExtensions(extensionRegistry);
120         MemorysafetyExtensionAtoms.registerAllExtensions(extensionRegistry);
121         PermissioncontrollerExtensionAtoms.registerAllExtensions(extensionRegistry);
122         MediaProviderAtoms.registerAllExtensions(extensionRegistry);
123         SettingsExtensionAtoms.registerAllExtensions(extensionRegistry);
124         ShellDataProto.registerAllExtensions(extensionRegistry);
125         SysuiAtoms.registerAllExtensions(extensionRegistry);
126         TelecomExtensionAtom.registerAllExtensions(extensionRegistry);
127         SatelliteExtensionAtoms.registerAllExtensions(extensionRegistry);
128         TelephonyExtensionAtoms.registerAllExtensions(extensionRegistry);
129         QnsExtensionAtoms.registerAllExtensions(extensionRegistry);
130         UsbAtoms.registerAllExtensions(extensionRegistry);
131         UwbExtensionAtoms.registerAllExtensions(extensionRegistry);
132         InputmethodAtoms.registerAllExtensions(extensionRegistry);
133         WearMediaAtoms.registerAllExtensions(extensionRegistry);
134         WearMediaExtensionAtoms.registerAllExtensions(extensionRegistry);
135         WearpasExtensionAtoms.registerAllExtensions(extensionRegistry);
136         WearservicesAtoms.registerAllExtensions(extensionRegistry);
137         WearservicesExtensionAtoms.registerAllExtensions(extensionRegistry);
138         WearsysuiAtoms.registerAllExtensions(extensionRegistry);
139         WifiExtensionAtoms.registerAllExtensions(extensionRegistry);
140         MediaCodecExtensionAtoms.registerAllExtensions(extensionRegistry);
141         CredentialsExtensionAtoms.registerAllExtensions(extensionRegistry);
142         SdksandboxExtensionAtoms.registerAllExtensions(extensionRegistry);
143         ArtExtensionAtoms.registerAllExtensions(extensionRegistry);
144         ApexExtensionAtoms.registerAllExtensions(extensionRegistry);
145         BackgroundExtensionDexoptAtoms.registerAllExtensions(extensionRegistry);
146         OdrefreshExtensionAtoms.registerAllExtensions(extensionRegistry);
147     }
148 }
149