1 /* 2 * Copyright (C) 2016 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 17 package com.android.functional.otatests; 18 19 import java.io.BufferedReader; 20 import java.io.File; 21 import java.io.FileInputStream; 22 import java.io.IOException; 23 import java.io.InputStreamReader; 24 25 public class VersionInfo { 26 private final String mBuildId; 27 private final String mBootloaderVersion; 28 private final String mBasebandVersion; 29 VersionInfo(String buildId, String bootVersion, String radioVersion)30 private VersionInfo(String buildId, String bootVersion, String radioVersion) { 31 mBuildId = buildId; 32 mBootloaderVersion = bootVersion; 33 mBasebandVersion = radioVersion; 34 } 35 getBuildId()36 public String getBuildId() { 37 return mBuildId; 38 } 39 getBootloaderVersion()40 public String getBootloaderVersion() { 41 return mBootloaderVersion; 42 } 43 getBasebandVersion()44 public String getBasebandVersion() { 45 return mBasebandVersion; 46 } 47 parseFromFile(String fileName)48 public static VersionInfo parseFromFile(String fileName) throws IOException { 49 BufferedReader r = new BufferedReader( 50 new InputStreamReader(new FileInputStream(new File(fileName)))); 51 try { 52 return new VersionInfo( 53 denull(r.readLine()), 54 denull(r.readLine()), 55 denull(r.readLine())); 56 } finally { 57 r.close(); 58 } 59 } 60 denull(String s)61 private static String denull(String s) { 62 return s == null || s.equals("null") ? "" : s; 63 } 64 } 65