1 /* 2 * Copyright (C) 2008 Esmertec AG. 3 * Copyright (C) 2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mms.util; 19 20 import com.android.mms.LogTag; 21 22 import java.util.HashMap; 23 24 import android.util.Log; 25 26 public class SendingProgressTokenManager { 27 private static final String TAG = LogTag.TAG; 28 private static final boolean DEBUG = false; 29 private static final boolean LOCAL_LOGV = false; 30 private static final HashMap<Object, Long> TOKEN_POOL; 31 32 public static final long NO_TOKEN = -1L; 33 34 static { 35 TOKEN_POOL = new HashMap<Object, Long>(); 36 } 37 38 synchronized public static long get(Object key) { 39 Long token = TOKEN_POOL.get(key); 40 if (LOCAL_LOGV) { 41 Log.v(TAG, "TokenManager.get(" + key + ") -> " + token); 42 } 43 return token != null ? token : NO_TOKEN; 44 } 45 46 synchronized public static void put(Object key, long token) { 47 if (LOCAL_LOGV) { 48 Log.v(TAG, "TokenManager.put(" + key + ", " + token + ")"); 49 } 50 TOKEN_POOL.put(key, token); 51 } 52 53 synchronized public static void remove(Object key) { 54 if (LOCAL_LOGV) { 55 Log.v(TAG, "TokenManager.remove(" + key + ")"); 56 } 57 TOKEN_POOL.remove(key); 58 } 59 } 60