• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.cts.deviceinfo;
17 
18 import android.os.Bundle;
19 
20 import com.android.compatibility.common.deviceinfo.DeviceInfo;
21 import com.android.compatibility.common.util.DeviceInfoStore;
22 
23 import java.util.Arrays;
24 
25 /**
26  * Sample device info collector.
27  */
28 public class SampleDeviceInfo extends DeviceInfo {
29 
30     @Override
collectDeviceInfo(DeviceInfoStore store)31     protected void collectDeviceInfo(DeviceInfoStore store) throws Exception {
32         boolean[] booleans = {Boolean.TRUE, Boolean.FALSE};
33         double[] doubles = {Double.MAX_VALUE, Double.MIN_VALUE};
34         int[] ints = {Integer.MAX_VALUE, Integer.MIN_VALUE};
35         long[] longs = {Long.MAX_VALUE, Long.MIN_VALUE};
36         float[] floats = {Float.MAX_VALUE, Float.MIN_VALUE, Float.NaN};
37 
38         // Group Foo
39         store.startGroup("foo");
40         store.addResult("foo_boolean", Boolean.TRUE);
41 
42         // Group Bar
43         store.startGroup("bar");
44         store.addListResult("bar_string", Arrays.asList(new String[] {
45                 "bar-string-1",
46                 "bar-string-2",
47                 "bar-string-3"}));
48 
49         store.addArrayResult("bar_boolean", booleans);
50         store.addArrayResult("bar_double", doubles);
51         store.addArrayResult("bar_int", ints);
52         store.addArrayResult("bar_long", longs);
53         store.addArrayResult("bar_float", floats);
54         store.endGroup(); // bar
55 
56         store.addResult("foo_double", Double.MAX_VALUE);
57         store.addResult("foo_int", Integer.MAX_VALUE);
58         store.addResult("foo_long", Long.MAX_VALUE);
59         store.addResult("foo_string", "foo-string");
60         store.addResult("foo_float_nan", Float.NaN);
61         store.addResult("foo_float_max", Float.MAX_VALUE + 1);
62         store.addResult("foo_float_min", Float.MIN_VALUE - 1);
63         store.endGroup(); // foo
64     }
65 }
66