• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  *      http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 
15 package com.google.deviceinfotest;
16 
17 import android.os.Bundle;
18 import android.app.Activity;
19 import android.view.View;
20 import android.widget.Button;
21 import android.widget.TextView;
22 import android.os.Build;
23 
24 import com.google.androidgamesdk.DeviceInfoProto;
25 import com.google.androidgamesdk.DeviceInfoJni;
26 
27 public class MainActivity extends Activity {
28   @Override
onCreate(Bundle savedInstanceState)29   protected void onCreate(Bundle savedInstanceState) {
30     super.onCreate(savedInstanceState);
31     setContentView(R.layout.activity_main);
32 
33     Button sample_button = (Button) findViewById(R.id.sample_button);
34     sample_button.setOnClickListener(new View.OnClickListener() {
35       @Override
36       public void onClick(View view) {
37         TextView tv = (TextView) findViewById(R.id.sample_text);
38         String msg = "Fingerprint(JAVA):\n" + Build.FINGERPRINT;
39         try{
40           DeviceInfoProto.InfoWithErrors proto;
41           byte[] nativeBytes = DeviceInfoJni.getProtoSerialized();
42           proto = DeviceInfoProto.InfoWithErrors.parseFrom(nativeBytes);
43 
44           DeviceInfoProto.Info info = proto.getInfo();
45           msg += "\nFingerprint(ro.build.fingerprint):\n" + info.getRoBuildFingerprint();
46           msg += "\nro_chipname:\n" + info.getRoChipname();
47           msg += "\nro_board_platform:\n" + info.getRoBoardPlatform();
48           msg += "\nro_product_board:\n" + info.getRoProductBoard();
49           msg += "\nro_mediatek_platform:\n" + info.getRoMediatekPlatform();
50           msg += "\nro_arch:\n" + info.getRoArch();
51           msg += "\nro_build_version_sdk:\n" + info.getRoBuildVersionSdk();
52         }catch(Exception e){
53           android.util.Log.e("device_info", "could not create proto.", e);
54         }
55         tv.setText(msg);
56       }
57     });
58   }
59 }
60