CellLocation.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
1/* 2 * Copyright (C) 2006 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 17package android.telephony; 18 19import android.os.Bundle; 20import android.os.RemoteException; 21import android.os.ServiceManager; 22import android.telephony.gsm.GsmCellLocation; 23import com.android.internal.telephony.ITelephony; 24 25/** 26 * Abstract class that represents the location of the device. Currently the only 27 * subclass is {@link android.telephony.gsm.GsmCellLocation}. {@more} 28 */ 29public abstract class CellLocation { 30 31 /** 32 * Request an update of the current location. If the location has changed, 33 * a broadcast will be sent to everyone registered with {@link 34 * PhoneStateListener#LISTEN_CELL_LOCATION}. 35 */ 36 public static void requestLocationUpdate() { 37 try { 38 ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.getService("phone")); 39 if (phone != null) { 40 phone.updateServiceLocation(); 41 } 42 } catch (RemoteException ex) { 43 // ignore it 44 } 45 } 46 47 /** 48 * Create a new CellLocation from a intent notifier Bundle 49 * 50 * This method is used by PhoneStateIntentReceiver and maybe by 51 * external applications. 52 * 53 * @param bundle Bundle from intent notifier 54 * @return newly created CellLocation 55 * 56 * @hide 57 */ 58 public static CellLocation newFromBundle(Bundle bundle) { 59 return new GsmCellLocation(bundle); 60 } 61 62 /** 63 * @hide 64 */ 65 public abstract void fillInNotifierBundle(Bundle bundle); 66 67 /** 68 * Return a new CellLocation object representing an unknown location. 69 */ 70 public static CellLocation getEmpty() { 71 return new GsmCellLocation(); 72 } 73} 74