1 /* 2 * Copyright (C) 2020 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 android.telephony.gba.cts; 18 19 final class TestGbaConfig { 20 21 static final int STATE_UNKNOWN = 0; 22 static final int STATE_CREATED = 1; 23 static final int STATE_BOUND = 2; 24 static final int STATE_UNBOUND = 3; 25 static final int STATE_REMOVED = 4; 26 27 private boolean mIsAuthSuccess; 28 private byte[] mGbaKey; 29 private String mBTid; 30 private int mFailReason; 31 private int mServiceState; 32 33 private static TestGbaConfig sInstance; 34 TestGbaConfig()35 private TestGbaConfig() { 36 } 37 getInstance()38 static TestGbaConfig getInstance() { 39 if (sInstance == null) { 40 sInstance = new TestGbaConfig(); 41 } 42 return sInstance; 43 } 44 setConfig(boolean success, byte[] key, String id, int reason)45 void setConfig(boolean success, byte[] key, String id, int reason) { 46 synchronized (this) { 47 mIsAuthSuccess = success; 48 mGbaKey = key; 49 mBTid = id; 50 mFailReason = reason; 51 } 52 } 53 isAuthSuccess()54 boolean isAuthSuccess() { 55 synchronized (this) { 56 return mIsAuthSuccess; 57 } 58 } 59 getGbaKey()60 byte[] getGbaKey() { 61 synchronized (this) { 62 return mGbaKey; 63 } 64 } 65 getBTid()66 String getBTid() { 67 synchronized (this) { 68 return mBTid; 69 } 70 } 71 getFailReason()72 int getFailReason() { 73 synchronized (this) { 74 return mFailReason; 75 } 76 } 77 setServiceState(int state)78 void setServiceState(int state) { 79 synchronized (this) { 80 mServiceState = state; 81 this.notify(); 82 } 83 } 84 getServiceState()85 int getServiceState() { 86 synchronized (this) { 87 return mServiceState; 88 } 89 } 90 } 91