• 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 
37         // Group Foo
38         store.startGroup("foo");
39         store.addResult("foo_boolean", Boolean.TRUE);
40 
41         // Group Bar
42         store.startGroup("bar");
43         store.addListResult("bar_string", Arrays.asList(new String[] {
44                 "bar-string-1",
45                 "bar-string-2",
46                 "bar-string-3"}));
47 
48         store.addArrayResult("bar_boolean", booleans);
49         store.addArrayResult("bar_double", doubles);
50         store.addArrayResult("bar_int", ints);
51         store.addArrayResult("bar_long", longs);
52         store.endGroup(); // bar
53 
54         store.addResult("foo_double", Double.MAX_VALUE);
55         store.addResult("foo_int", Integer.MAX_VALUE);
56         store.addResult("foo_long", Long.MAX_VALUE);
57         store.addResult("foo_string", "foo-string");
58         store.endGroup(); // foo
59     }
60 }
61