- add sources.
[platform/framework/web/crosswalk.git] / src / content / public / android / java / src / org / chromium / content / common / DeviceTelephonyInfo.java
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.content.common;
6
7 import android.content.Context;
8 import android.telephony.TelephonyManager;
9
10 import org.chromium.base.CalledByNative;
11
12 /**
13  * This class facilitates access to the current telephony region,
14  * typically only available using the Java SDK.
15  */
16 public class DeviceTelephonyInfo {
17
18   private TelephonyManager mTelManager;
19
20   private DeviceTelephonyInfo(Context context) {
21       Context appContext = context.getApplicationContext();
22       mTelManager = (TelephonyManager) appContext.getSystemService(Context.TELEPHONY_SERVICE);
23   }
24
25   /**
26    * @return The ISO country code equivalent of the current MCC.
27    */
28   @CalledByNative
29   public String getNetworkCountryIso() {
30       return mTelManager.getNetworkCountryIso();
31   }
32
33   /**
34    * Creates DeviceTelephonyInfo for a given Context.
35    * @param context A context to use.
36    * @return DeviceTelephonyInfo associated with a given Context.
37    */
38   @CalledByNative
39   public static DeviceTelephonyInfo create(Context context) {
40       return new DeviceTelephonyInfo(context);
41   }
42 }