1 /* 2 * Copyright (c) 2024 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 #ifndef I_APP_LAUNCH_SCENE_DB_H 16 #define I_APP_LAUNCH_SCENE_DB_H 17 18 #include <string> 19 20 class IAppLaunchSceneDb { 21 public: 22 const static int INVALID = -1; 23 24 struct InteractionResponse { 25 uint64_t time{0}; 26 std::string domain{""}; 27 std::string eventName{""}; 28 29 int32_t appPid{0}; 30 int32_t versionCode{0}; 31 std::string versionName{""}; 32 std::string bundleName{""}; 33 std::string processName{""}; 34 std::string abilityName{""}; 35 std::string pageUrl{""}; 36 std::string sceneId{""}; 37 std::string sourceType{""}; 38 uint64_t inputTime{0}; 39 uint64_t animationStartTime{0}; 40 uint64_t renderTime{0}; 41 uint64_t responseLatency{0}; 42 std::string note{""}; 43 }; 44 45 struct StartAbility { 46 uint64_t time{0}; 47 std::string domain{""}; 48 std::string eventName{""}; 49 50 std::string bundleName{""}; 51 std::string moduleName{""}; 52 std::string abilityName{""}; 53 }; 54 55 struct AppStartupType { 56 uint64_t time{0}; 57 std::string domain{""}; 58 std::string eventName{""}; 59 60 int32_t appPid{0}; 61 int32_t versionCode{0}; 62 std::string versionName{""}; 63 std::string bundleName{""}; 64 std::string abilityName{""}; 65 int32_t startType{0}; //0-cool,1-hot 66 }; 67 68 struct ProcessStart { 69 uint64_t time{0}; 70 std::string domain{""}; 71 std::string eventName{""}; 72 73 std::string bundleName{""}; 74 uint64_t startupTime{0}; 75 int32_t startupAbilityType{0}; 76 int32_t startupExtensionType{0}; 77 std::string callerBundleName{""}; 78 int32_t callerUid{0}; 79 std::string callerProcessName{""}; 80 }; 81 82 struct AppAttach { 83 uint64_t time{0}; 84 std::string domain{""}; 85 std::string eventName{""}; 86 87 std::string bundleName{""}; 88 int32_t appPid{0}; 89 int32_t versionCode{0}; 90 std::string versionName{""}; 91 std::string processName{""}; 92 }; 93 94 struct AppForeground { 95 uint64_t time{0}; 96 std::string domain{""}; 97 std::string eventName{""}; 98 99 std::string bundleName{""}; 100 int32_t appPid{0}; 101 int32_t versionCode{0}; 102 std::string versionName{""}; 103 std::string processName{""}; 104 int32_t bundleType{0}; 105 std::string callerBundleName{""}; 106 }; 107 108 struct AbilityForeground { 109 uint64_t time{0}; 110 std::string domain{""}; 111 std::string eventName{""}; 112 113 std::string bundleName{""}; 114 std::string moduleName{""}; 115 std::string abilityName{""}; 116 int32_t bundleType{0}; 117 std::string callerBundleName{""}; 118 }; 119 120 struct StartWindow { 121 uint64_t time{0}; 122 std::string domain{""}; 123 std::string eventName{""}; 124 125 std::string bundleName{""}; 126 int32_t appPid{0}; 127 std::string processName{""}; 128 std::string windowName{""}; 129 }; 130 131 struct DrawnCompleted { 132 uint64_t time{0}; 133 std::string domain{""}; 134 std::string eventName{""}; 135 136 int32_t appUid{0}; 137 int32_t appPid{0}; 138 std::string bundleName{""}; 139 std::string moduleName{""}; 140 std::string abilityName{""}; 141 }; 142 143 struct FirstFrameDrawn { 144 uint64_t time{0}; 145 std::string domain{""}; 146 std::string eventName{""}; 147 148 int32_t appPid{0}; 149 }; 150 151 struct InteractionCompleted { 152 uint64_t time{0}; 153 std::string domain{""}; 154 std::string eventName{""}; 155 156 std::string bundleName{""}; 157 int32_t appPid{0}; 158 int32_t versionCode{0}; 159 std::string versionName{""}; 160 std::string abilityName{""}; 161 std::string processName{""}; 162 std::string pageUrl{""}; 163 std::string sceneId{""}; 164 std::string sourceType{""}; 165 uint64_t inputTime{0}; 166 uint64_t animationStartLatency{0}; 167 uint64_t animationEndLatency{0}; 168 uint64_t e2eLatency{0}; 169 std::string note{""}; 170 }; 171 172 struct AppStartRecord { 173 int32_t appPid{0}; 174 std::string bundleName{""}; 175 176 InteractionResponse interactionResponse; 177 StartAbility startAbility; 178 AppStartupType appStartupType; 179 ProcessStart processStart; 180 AppAttach appAttach; 181 AppForeground appForeground; 182 AbilityForeground abilityForeground; 183 StartWindow startWindow; 184 DrawnCompleted drawnCompleted; 185 FirstFrameDrawn firstFrameDrawn; 186 InteractionCompleted interactionCompleted; 187 }; 188 public: 189 virtual void CreateRecord(const std::string& bundleName, const AppStartRecord& record) = 0; 190 virtual void UpdateRecord(const std::string& bundleName, const AppStartRecord& record) = 0; 191 virtual void DeleteRecord(const std::string& bundleName) = 0; 192 virtual AppStartRecord QueryRecord(const std::string& bundleName) = 0; 193 virtual void CreateRecord(const AppStartRecord& record) = 0; 194 virtual void UpdateRecord(const AppStartRecord& record) = 0; 195 virtual ~IAppLaunchSceneDb() = default; 196 }; 197 #endif