1 /* 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 package org.webrtc; 12 13 import android.content.Context; 14 15 /** 16 * Class for storing the application context and retrieving it in a static context. Similar to 17 * org.chromium.base.ContextUtils. 18 */ 19 public class ContextUtils { 20 private static final String TAG = "ContextUtils"; 21 private static Context applicationContext; 22 23 /** 24 * Stores the application context that will be returned by getApplicationContext. This is called 25 * by PeerConnectionFactory.initialize. The application context must be set before creating 26 * a PeerConnectionFactory and must not be modified while it is alive. 27 */ initialize(Context applicationContext)28 public static void initialize(Context applicationContext) { 29 if (applicationContext == null) { 30 throw new IllegalArgumentException( 31 "Application context cannot be null for ContextUtils.initialize."); 32 } 33 ContextUtils.applicationContext = applicationContext; 34 } 35 36 /** 37 * Returns the stored application context. 38 * 39 * @deprecated crbug.com/webrtc/8937 40 */ 41 @Deprecated getApplicationContext()42 public static Context getApplicationContext() { 43 return applicationContext; 44 } 45 } 46