Muhammad Qureshi 9effe48706 Use StatsEvent in Java autogenerated code
The change is guarded by STATS_SCHEMA_LEGACY flag in the autogenerator
Android.bp.

The flag can only be removed once rest of statsd switches over to the
new socket schema.

The new autogeneration uses StatsEvent for both Mainline module
clients and the default platform client. For Mainline modules, the
autogenerated code uses a runtime dessert version check to use new
socket schema on R+ platforms and the legacy schema on the older
platforms.

The legacy schema is encapsulated in a separate autogenerated inner
class called QLogger.

generated DocumentsStatsLog.java: https://paste.googleplex.com/4665805503463424
generated StatsLogInternal.java: https://paste.googleplex.com/5955095055302656
generated android_util_StatsLogInternal.cpp:
    https://paste.googleplex.com/6737331711115264

Bug: 142811546
Test: m -j && m -j DocumentsUIGoogle
Test: Flashes successfully and events are logged to statsd
Change-Id: I4c804eaf4d5ae78001146c89ebe46dfb0a453853
2019-11-25 12:50:49 -08:00

76 lines
2.3 KiB
C++

/*
* Copyright (C) 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "Collation.h"
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <string.h>
namespace android {
namespace stats_log_api_gen {
using namespace std;
const string DEFAULT_MODULE_NAME = "DEFAULT";
const string DEFAULT_CPP_NAMESPACE = "android,util";
const string DEFAULT_CPP_HEADER_IMPORT = "statslog.h";
const string DEFAULT_JAVA_PACKAGE = "android.util";
const string DEFAULT_JAVA_CLASS = "StatsLogInternal";
const int JAVA_MODULE_REQUIRES_FLOAT = 0x01;
const int JAVA_MODULE_REQUIRES_ATTRIBUTION = 0x02;
string make_constant_name(const string& str);
const char* cpp_type_name(java_type_t type);
const char* java_type_name(java_type_t type);
bool atom_needed_for_module(const AtomDecl& atomDecl, const string& moduleName);
bool signature_needed_for_module(const set<string>& modules, const string& moduleName);
void build_non_chained_decl_map(const Atoms& atoms,
std::map<int, set<AtomDecl>::const_iterator>* decl_map);
// Common Java helpers.
void write_java_atom_codes(FILE* out, const Atoms& atoms, const string& moduleName);
void write_java_enum_values(FILE* out, const Atoms& atoms, const string& moduleName);
void write_java_usage(FILE* out, const string& method_name, const string& atom_code_name,
const AtomDecl& atom);
int write_java_non_chained_methods(FILE* out, const map<vector<java_type_t>,
set<string>>& signatures_to_modules,
const string& moduleName
);
int write_java_work_source_methods(
FILE* out,
const map<vector<java_type_t>, set<string>>& signatures_to_modules,
const string& moduleName
);
} // namespace stats_log_api_gen
} // namespace android