Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10012754 authored by Baligh Uddin's avatar Baligh Uddin
Browse files

Migrate to packages/modules/StatsD/lib/*

BUG: 167962588
Test: TH
Merged-In: I536a324182f70725a5fda0c36f7f9d4676fd49b9
Change-Id: I8b4ceadcdd0777468b6aaa3b8a57e765f19fb781
Exempt-From-Owner-Approval: Code Migration / Cleanup
parent 995db46b
Loading
Loading
Loading
Loading

libstats/pull/Android.bp

deleted100644 → 0
+0 −111
Original line number Diff line number Diff line
//
// 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.
//

// ==========================================================
// Native library to register a pull atom callback with statsd
// ==========================================================
cc_defaults {
    name: "libstatspull_defaults",
    srcs: [
        "stats_pull_atom_callback.cpp",
    ],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    export_include_dirs: ["include"],
    shared_libs: [
        "libbinder_ndk",
        "liblog",
        "libstatssocket",
    ],
    static_libs: [
        "libutils",
        "statsd-aidl-ndk_platform",
    ],
}
cc_library_shared {
    name: "libstatspull",
    defaults: [
        "libstatspull_defaults"
    ],
    // enumerate stable entry points for APEX use
    stubs: {
        symbol_file: "libstatspull.map.txt",
        versions: [
            "30",
        ],
    },
    apex_available: [
        "com.android.os.statsd",
        "test_com.android.os.statsd",
    ],

    stl: "libc++_static",

    // TODO(b/151102177): Enable it when the build error is fixed.
    header_abi_checker: {
        enabled: false,
    },
}

// ONLY USE IN TESTS.
cc_library_static {
    name: "libstatspull_private",
    defaults: [
        "libstatspull_defaults",
    ],
    visibility: [
        "//frameworks/base/apex/statsd/tests/libstatspull",
        "//packages/modules/StatsD/apex/tests/libstatspull",
    ],
}

// Note: These unit tests only test PullAtomMetadata.
// For full E2E tests of libstatspull, use LibStatsPullTests
cc_test {
    name: "libstatspull_test",
    srcs: [
        "tests/pull_atom_metadata_test.cpp",
    ],
    shared_libs: [
        "libstatspull",
        "libstatssocket",
    ],
    test_suites: ["general-tests", "mts"],
    test_config: "libstatspull_test.xml",

    //TODO(b/153588990): Remove when the build system properly separates 
    //32bit and 64bit architectures.
    compile_multilib: "both",
    multilib: {
        lib64: {
            suffix: "64",
        },
        lib32: {
            suffix: "32",
        },
    },
    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-missing-field-initializers",
        "-Wno-unused-variable",
        "-Wno-unused-function",
        "-Wno-unused-parameter",
    ],
    require_root: true,
}

libstats/pull/OWNERS

deleted100644 → 0
+0 −7
Original line number Diff line number Diff line
joeo@google.com
muhammadq@google.com
ruchirr@google.com
singhtejinder@google.com
tsaichristine@google.com
yaochen@google.com
yro@google.com

libstats/pull/TEST_MAPPING

deleted100644 → 0
+0 −7
Original line number Diff line number Diff line
{
  "presubmit" : [
    {
      "name" : "libstatspull_test"
    }
  ]
}
 No newline at end of file
+0 −170
Original line number Diff line number Diff line
/*
 * 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 <stats_event.h>

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Opaque struct representing the metadata for registering an AStatsManager_PullAtomCallback.
 */
struct AStatsManager_PullAtomMetadata;
typedef struct AStatsManager_PullAtomMetadata AStatsManager_PullAtomMetadata;

/**
 * Allocate and initialize new PullAtomMetadata.
 *
 * Must call AStatsManager_PullAtomMetadata_release to free the memory.
 */
AStatsManager_PullAtomMetadata* AStatsManager_PullAtomMetadata_obtain();

/**
 * Frees the memory held by this PullAtomMetadata
 *
 * After calling this, the PullAtomMetadata must not be used or modified in any way.
 */
void AStatsManager_PullAtomMetadata_release(AStatsManager_PullAtomMetadata* metadata);

/**
 * Set the cool down time of the pull in milliseconds. If two successive pulls are issued
 * within the cool down, a cached version of the first will be used for the second. The minimum
 * allowed cool down is one second.
 */
void AStatsManager_PullAtomMetadata_setCoolDownMillis(AStatsManager_PullAtomMetadata* metadata,
                                                      int64_t cool_down_millis);

/**
 * Get the cool down time of the pull in milliseconds.
 */
int64_t AStatsManager_PullAtomMetadata_getCoolDownMillis(AStatsManager_PullAtomMetadata* metadata);

/**
 * Set the maximum time the pull can take in milliseconds.
 * The maximum allowed timeout is 10 seconds.
 */
void AStatsManager_PullAtomMetadata_setTimeoutMillis(AStatsManager_PullAtomMetadata* metadata,
                                                     int64_t timeout_millis);

/**
 * Get the maximum time the pull can take in milliseconds.
 */
int64_t AStatsManager_PullAtomMetadata_getTimeoutMillis(AStatsManager_PullAtomMetadata* metadata);

/**
 * Set the additive fields of this pulled atom.
 *
 * This is only applicable for atoms which have a uid field. When tasks are run in
 * isolated processes, the data will be attributed to the host uid. Additive fields
 * will be combined when the non-additive fields are the same.
 */
void AStatsManager_PullAtomMetadata_setAdditiveFields(AStatsManager_PullAtomMetadata* metadata,
                                                      int32_t* additive_fields, int32_t num_fields);

/**
 * Get the number of additive fields for this pulled atom. This is intended to be called before
 * AStatsManager_PullAtomMetadata_getAdditiveFields to determine the size of the array.
 */
int32_t AStatsManager_PullAtomMetadata_getNumAdditiveFields(
        AStatsManager_PullAtomMetadata* metadata);

/**
 * Get the additive fields of this pulled atom.
 *
 * \param fields an output parameter containing the additive fields for this PullAtomMetadata.
 *               Fields is an array and it is assumed that it is at least as large as the number of
 *               additive fields, which can be obtained by calling
 *               AStatsManager_PullAtomMetadata_getNumAdditiveFields.
 */
void AStatsManager_PullAtomMetadata_getAdditiveFields(AStatsManager_PullAtomMetadata* metadata,
                                                      int32_t* fields);

/**
 * Return codes for the result of a pull.
 */
typedef int32_t AStatsManager_PullAtomCallbackReturn;
enum {
    // Value indicating that this pull was successful and that the result should be used.
    AStatsManager_PULL_SUCCESS = 0,
    // Value indicating that this pull was unsuccessful and that the result should not be used.
    AStatsManager_PULL_SKIP = 1,
};

/**
 * Opaque struct representing a list of AStatsEvent objects.
 */
struct AStatsEventList;
typedef struct AStatsEventList AStatsEventList;

/**
 * Appends and returns an AStatsEvent to the end of the AStatsEventList.
 *
 * If an AStatsEvent is obtained in this manner, the memory is internally managed and
 * AStatsEvent_release does not need to be called. The lifetime of the AStatsEvent is that of the
 * AStatsEventList.
 *
 * The AStatsEvent does still need to be built by calling AStatsEvent_build.
 */
AStatsEvent* AStatsEventList_addStatsEvent(AStatsEventList* pull_data);

/**
 * Callback interface for pulling atoms requested by the stats service.
 *
 * \param atom_tag the tag of the atom to pull.
 * \param data an output parameter in which the caller should fill the results of the pull. This
 *             param cannot be NULL and it's lifetime is as long as the execution of the callback.
 *             It must not be accessed or modified after returning from the callback.
 * \param cookie the opaque pointer passed in AStatsManager_registerPullAtomCallback.
 * \return AStatsManager_PULL_SUCCESS if the pull was successful, or AStatsManager_PULL_SKIP if not.
 */
typedef AStatsManager_PullAtomCallbackReturn (*AStatsManager_PullAtomCallback)(
        int32_t atom_tag, AStatsEventList* data, void* cookie);
/**
 * Sets a callback for an atom when that atom is to be pulled. The stats service will
 * invoke the callback when the stats service determines that this atom needs to be
 * pulled.
 *
 * Requires the REGISTER_STATS_PULL_ATOM permission.
 *
 * \param atom_tag          The tag of the atom for this pull atom callback.
 * \param metadata          Optional metadata specifying the timeout, cool down time, and
 *                          additive fields for mapping isolated to host uids.
 *                          This param is nullable, in which case defaults will be used.
 * \param callback          The callback to be invoked when the stats service pulls the atom.
 * \param cookie            A pointer that will be passed back to the callback.
 *                          It has no meaning to statsd.
 */
void AStatsManager_setPullAtomCallback(int32_t atom_tag, AStatsManager_PullAtomMetadata* metadata,
                                       AStatsManager_PullAtomCallback callback, void* cookie);

/**
 * Clears a callback for an atom when that atom is to be pulled. Note that any ongoing
 * pulls will still occur.
 *
 * Requires the REGISTER_STATS_PULL_ATOM permission.
 *
 * \param atomTag           The tag of the atom of which to unregister
 */
void AStatsManager_clearPullAtomCallback(int32_t atom_tag);

#ifdef __cplusplus
}
#endif
+0 −17
Original line number Diff line number Diff line
LIBSTATSPULL {
    global:
        AStatsManager_PullAtomMetadata_obtain; # apex # introduced=30
        AStatsManager_PullAtomMetadata_release; # apex # introduced=30
        AStatsManager_PullAtomMetadata_setCoolDownMillis; # apex # introduced=30
        AStatsManager_PullAtomMetadata_getCoolDownMillis; # apex # introduced=30
        AStatsManager_PullAtomMetadata_setTimeoutMillis; # apex # introduced=30
        AStatsManager_PullAtomMetadata_getTimeoutMillis; # apex # introduced=30
        AStatsManager_PullAtomMetadata_setAdditiveFields; # apex # introduced=30
        AStatsManager_PullAtomMetadata_getNumAdditiveFields; # apex # introduced=30
        AStatsManager_PullAtomMetadata_getAdditiveFields; # apex # introduced=30
        AStatsEventList_addStatsEvent; # apex # introduced=30
        AStatsManager_setPullAtomCallback; # apex # introduced=30
        AStatsManager_clearPullAtomCallback; # apex # introduced=30
    local:
        *;
};
Loading