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

Commit 9112a5e0 authored by Joe Onorato's avatar Joe Onorato
Browse files

Off-device library for the power model.

This first CL adds a class, PowerProfile that parses the power
profile xml file into a set of individual *Profile classes, one
for each of the hardware "components."

There will be more to come.  This library will be used to compute
the power model from a batterystats or statsd dump, with abstractions
so clients don't need to know all of the nuances of batterystats'
old versions, or statsd's configs.

Test: atest frameworks/base/tools/powermodel --host
Change-Id: I79802f91234b09539072d10f15534cef391fe04a
parent 5af89dfb
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line

java_library_host {
    name: "powermodel",
    srcs: [
        "src/**/*.java",
    ],
    static_libs: [
        "guava",
    ],
}

java_test_host {
    name: "powermodel-test",

    test_suites: ["general-tests"],

    srcs: ["test/**/*.java"],
    java_resource_dirs: ["test-resource"],

    static_libs: [
        "powermodel",
        "junit",
        "mockito",
    ],
}
+8 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "powermodel-test"
    }
  ]
}
+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.
 */

package com.android.powermodel;

/**
 * The hardware components that use power on a device.
 */
public enum Component {
    CPU,
    SCREEN,
    MODEM,
    WIFI,
    BLUETOOTH,
    VIDEO,
    AUDIO,
    FLASHLIGHT,
    CAMERA,
    GPS,
}
+20 −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.
 */

package com.android.powermodel;

public class ComponentProfile {
}
+35 −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.
 */

package com.android.powermodel;

public class ParseException extends Exception {
    public final int line;

    public ParseException(int line, String message, Throwable th) {
        super(message, th);
        this.line = line;
    }

    public ParseException(int line, String message) {
        this(line, message, null);
    }

    public ParseException(String message) {
        this(0, message, null);
    }
}
Loading