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

Commit 565aa509 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Initial UsageStatsDatabase Perf tests"

parents a6b1d730 e717e0cb
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ import android.util.ArraySet;

import java.util.List;

class IntervalStats {
import com.android.internal.annotations.VisibleForTesting;

public class IntervalStats {
    public long beginTime;
    public long endTime;
    public long lastTimeSaved;
@@ -149,7 +151,11 @@ class IntervalStats {
                && eventType != UsageEvents.Event.STANDBY_BUCKET_CHANGED;
    }

    void update(String packageName, long timeStamp, int eventType) {
    /**
     * @hide
     */
    @VisibleForTesting
    public void update(String packageName, long timeStamp, int eventType) {
        UsageStats usageStats = getOrCreateUsageStats(packageName);

        // TODO(adamlesinski): Ensure that we recover from incorrect event sequences
+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import java.util.List;
/**
 * Provides an interface to query for UsageStat data from an XML database.
 */
class UsageStatsDatabase {
public class UsageStatsDatabase {
    private static final int CURRENT_VERSION = 3;

    // Current version of the backup schema
@@ -369,7 +369,7 @@ class UsageStatsDatabase {
    /**
     * Figures out what to extract from the given IntervalStats object.
     */
    interface StatCombiner<T> {
    public interface StatCombiner<T> {

        /**
         * Implementations should extract interesting from <code>stats</code> and add it
+34 −0
Original line number Diff line number Diff line
# Copyright (C) 2018 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.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := tests

LOCAL_SRC_FILES := \
    $(call all-java-files-under, src)

LOCAL_STATIC_JAVA_LIBRARIES := \
    android-support-test \
    apct-perftests-utils \
    services.usage

LOCAL_PACKAGE_NAME := UsageStatsPerfTests
LOCAL_PRIVATE_PLATFORM_APIS := true

# For android.permission.FORCE_STOP_PACKAGES permission
LOCAL_CERTIFICATE := platform

include $(BUILD_PACKAGE)
+29 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.frameworks.perftests.usage">
    <uses-sdk
            android:minSdkVersion="21" />
    <uses-permission android:name="android.permission.DUMP" />
    <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" />

    <application>
        <uses-library android:name="android.test.runner" />
    </application>

    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
                     android:targetPackage="com.android.frameworks.perftests.usage"/>
</manifest>
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 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.
-->
<configuration description="Runs UsageStats Performance Tests">
    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
        <option name="test-file-name" value="UsageStatsPerfTests.apk"/>
        <option name="cleanup-apks" value="true"/>
    </target_preparer>

    <option name="test-suite-tag" value="apct"/>
    <option name="test-tag" value="UsageStatsPerfTests"/>
    <test class="com.android.tradefed.testtype.AndroidJUnitTest">
        <option name="package" value="com.android.frameworks.perftests.usage"/>
        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner"/>
    </test>
</configuration>
 No newline at end of file
Loading