Merge "This cl tries to fix cts tests IncidentdTest" into pi-dev
am: 72a39eb3be
Change-Id: Ia9e3f94b367dffc6482f5f3ba12aeaba2eed6874
This commit is contained in:
@@ -34,7 +34,7 @@ namespace incidentd {
|
|||||||
void PrivacyBuffer::writeFieldOrSkip(uint32_t fieldTag, bool skip) {
|
void PrivacyBuffer::writeFieldOrSkip(uint32_t fieldTag, bool skip) {
|
||||||
uint8_t wireType = read_wire_type(fieldTag);
|
uint8_t wireType = read_wire_type(fieldTag);
|
||||||
size_t bytesToWrite = 0;
|
size_t bytesToWrite = 0;
|
||||||
uint32_t varint = 0;
|
uint64_t varint = 0;
|
||||||
|
|
||||||
switch (wireType) {
|
switch (wireType) {
|
||||||
case WIRE_TYPE_VARINT:
|
case WIRE_TYPE_VARINT:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace android {
|
|||||||
namespace os {
|
namespace os {
|
||||||
namespace incidentd {
|
namespace incidentd {
|
||||||
|
|
||||||
const int64_t REMOTE_CALL_TIMEOUT_MS = 10 * 1000; // 10 seconds
|
const int64_t REMOTE_CALL_TIMEOUT_MS = 30 * 1000; // 30 seconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for sections
|
* Base class for sections
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ message IncidentProto {
|
|||||||
];
|
];
|
||||||
|
|
||||||
optional BatteryTypeProto battery_type = 2006 [
|
optional BatteryTypeProto battery_type = 2006 [
|
||||||
(section).type = SECTION_FILE,
|
(section).type = SECTION_NONE, // disabled since the path is device specific!
|
||||||
(section).args = "/sys/class/power_supply/bms/battery_type"
|
(section).args = "/sys/class/power_supply/bms/battery_type"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ message NotificationRecordProto {
|
|||||||
optional bool can_vibrate = 7;
|
optional bool can_vibrate = 7;
|
||||||
optional bool can_show_light = 8;
|
optional bool can_show_light = 8;
|
||||||
optional string group_key = 9 [ (.android.privacy).dest = DEST_EXPLICIT ];
|
optional string group_key = 9 [ (.android.privacy).dest = DEST_EXPLICIT ];
|
||||||
optional int32 importance = 10;
|
optional sint32 importance = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListenersDisablingEffectsProto {
|
message ListenersDisablingEffectsProto {
|
||||||
@@ -122,11 +122,11 @@ message RankingHelperProto {
|
|||||||
// Default value is UNKNOWN_UID = USER_NULL = -10000.
|
// Default value is UNKNOWN_UID = USER_NULL = -10000.
|
||||||
optional int32 uid = 2;
|
optional int32 uid = 2;
|
||||||
// Default is IMPORTANCE_UNSPECIFIED (-1000).
|
// Default is IMPORTANCE_UNSPECIFIED (-1000).
|
||||||
optional int32 importance = 3;
|
optional sint32 importance = 3;
|
||||||
// Default is PRIORITY_DEFAULT (0).
|
// Default is PRIORITY_DEFAULT (0).
|
||||||
optional int32 priority = 4;
|
optional int32 priority = 4;
|
||||||
// Default is VISIBILITY_NO_OVERRIDE (-1000).
|
// Default is VISIBILITY_NO_OVERRIDE (-1000).
|
||||||
optional int32 visibility = 5;
|
optional sint32 visibility = 5;
|
||||||
// Default is true.
|
// Default is true.
|
||||||
optional bool show_badge = 6;
|
optional bool show_badge = 6;
|
||||||
repeated android.app.NotificationChannelProto channels = 7;
|
repeated android.app.NotificationChannelProto channels = 7;
|
||||||
|
|||||||
@@ -37,3 +37,20 @@ cc_library {
|
|||||||
"liblog",
|
"liblog",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_test {
|
||||||
|
name: "libprotoutil_test",
|
||||||
|
|
||||||
|
srcs: [
|
||||||
|
"tests/EncodedBuffer_test.cpp",
|
||||||
|
],
|
||||||
|
|
||||||
|
shared_libs: [
|
||||||
|
"libcutils",
|
||||||
|
"libprotoutil",
|
||||||
|
],
|
||||||
|
|
||||||
|
static_libs: [
|
||||||
|
"libgmock",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|||||||
26
libs/protoutil/AndroidTest.xml
Normal file
26
libs/protoutil/AndroidTest.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?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="Config for libprotoutil_test">
|
||||||
|
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
|
||||||
|
<option name="cleanup" value="true" />
|
||||||
|
<option name="push" value="libprotoutil_test->/data/nativetest/libprotoutil_test" />
|
||||||
|
</target_preparer>
|
||||||
|
<option name="test-suite-tag" value="apct" />
|
||||||
|
<test class="com.android.tradefed.testtype.GTest" >
|
||||||
|
<option name="native-test-device-path" value="/data/nativetest" />
|
||||||
|
<option name="module-name" value="libprotoutil_test" />
|
||||||
|
</test>
|
||||||
|
</configuration>
|
||||||
@@ -13,11 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#define LOG_TAG "libprotoutil"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <android/util/EncodedBuffer.h>
|
#include <android/util/EncodedBuffer.h>
|
||||||
#include <android/util/protobuf.h>
|
#include <android/util/protobuf.h>
|
||||||
|
#include <cutils/log.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace util {
|
namespace util {
|
||||||
@@ -228,7 +230,7 @@ EncodedBuffer::readRawVarint()
|
|||||||
size_t start = mEp.pos();
|
size_t start = mEp.pos();
|
||||||
while (true) {
|
while (true) {
|
||||||
uint8_t byte = readRawByte();
|
uint8_t byte = readRawByte();
|
||||||
val += (byte & 0x7F) << shift;
|
val |= (UINT64_C(0x7F) & byte) << shift;
|
||||||
if ((byte & 0x80) == 0) break;
|
if ((byte & 0x80) == 0) break;
|
||||||
shift += 7;
|
shift += 7;
|
||||||
}
|
}
|
||||||
@@ -345,7 +347,7 @@ EncodedBuffer::iterator::readRawVarint()
|
|||||||
uint64_t val = 0, shift = 0;
|
uint64_t val = 0, shift = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
uint8_t byte = next();
|
uint8_t byte = next();
|
||||||
val += (byte & 0x7F) << shift;
|
val |= (INT64_C(0x7F) & byte) << shift;
|
||||||
if ((byte & 0x80) == 0) break;
|
if ((byte & 0x80) == 0) break;
|
||||||
shift += 7;
|
shift += 7;
|
||||||
}
|
}
|
||||||
|
|||||||
25
libs/protoutil/tests/EncodedBuffer_test.cpp
Normal file
25
libs/protoutil/tests/EncodedBuffer_test.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// 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.
|
||||||
|
#include <android/util/EncodedBuffer.h>
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
using namespace android::util;
|
||||||
|
|
||||||
|
TEST(EncodedBufferTest, ReadVarint) {
|
||||||
|
EncodedBuffer buffer;
|
||||||
|
uint64_t val = UINT64_C(1522865904593);
|
||||||
|
buffer.writeRawVarint64(val);
|
||||||
|
EXPECT_EQ(val, buffer.begin().readRawVarint());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user