1 /* 2 * Copyright (C) 2018 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.game.qualification; 17 18 import com.android.game.qualification.GameCoreConfigurationXmlParser.Field; 19 20 public class CertificationRequirements { 21 private String mName; 22 private float mFrameTime; 23 private float mJankRate; 24 private int mLoadTime; 25 CertificationRequirements(String name, float frameTime, float jankRate, int loadTime)26 public CertificationRequirements(String name, float frameTime, float jankRate, int loadTime) { 27 mName = name; 28 mFrameTime = frameTime; 29 mJankRate = jankRate; 30 mLoadTime = loadTime; 31 checkNotNull(name, Field.NAME.getTag()); 32 } 33 34 /** 35 * Name of the certification requirements. 36 * 37 * Must match a corresponding apk info. 38 */ getName()39 public String getName() { 40 return mName; 41 } 42 43 /** 44 * (Optional) Target frame time (in milliseconds) of the APK. [default: 16.666] 45 */ getFrameTime()46 public float getFrameTime() { 47 return mFrameTime; 48 } 49 50 /** 51 * (Optional) Maximum ratio of frames the APK can miss before failing certification. 52 * [default: 0.0] 53 */ getJankRate()54 public float getJankRate() { 55 return mJankRate; 56 } 57 58 /** 59 * (Optional) Maximum load time in milliseconds. Load time of -1 implies, it is not considered 60 * for certification. [default: -1] 61 */ getLoadTime()62 public int getLoadTime() { 63 return mLoadTime; 64 } 65 checkNotNull(Object value, String fieldName)66 private void checkNotNull(Object value, String fieldName) { 67 if (value == null) { 68 throw new IllegalArgumentException( 69 "Failed to parse certfication requirements. Required field '" + fieldName 70 + "' is missing."); 71 } 72 } 73 } 74