2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.telephony;
19 import android.os.Bundle;
20 import android.os.RemoteException;
21 import android.os.ServiceManager;
23 import android.telephony.cdma.CdmaCellLocation;
24 import android.telephony.gsm.GsmCellLocation;
25 import com.android.internal.telephony.ITelephony;
26 import com.android.internal.telephony.PhoneConstants;
29 * Abstract class that represents the location of the device. {@more}
31 public abstract class CellLocation {
34 * Request an update of the current location. If the location has changed,
35 * a broadcast will be sent to everyone registered with {@link
36 * PhoneStateListener#LISTEN_CELL_LOCATION}.
38 public static void requestLocationUpdate() {
40 ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
42 phone.updateServiceLocation();
44 } catch (RemoteException ex) {
50 * Create a new CellLocation from a intent notifier Bundle
52 * This method is used by PhoneStateIntentReceiver and maybe by
53 * external applications.
55 * @param bundle Bundle from intent notifier
56 * @return newly created CellLocation
60 public static CellLocation newFromBundle(Bundle bundle) {
61 // TelephonyManager.getDefault().getCurrentPhoneType() handles the case when
62 // ITelephony interface is not up yet.
63 switch(TelephonyManager.getDefault().getCurrentPhoneType()) {
64 case PhoneConstants.PHONE_TYPE_CDMA:
65 return new CdmaCellLocation(bundle);
66 case PhoneConstants.PHONE_TYPE_GSM:
67 return new GsmCellLocation(bundle);
76 public abstract void fillInNotifierBundle(Bundle bundle);
81 public abstract boolean isEmpty();
84 * Return a new CellLocation object representing an unknown
85 * location, or null for unknown/none phone radio types.
88 public static CellLocation getEmpty() {
89 // TelephonyManager.getDefault().getCurrentPhoneType() handles the case when
90 // ITelephony interface is not up yet.
91 switch(TelephonyManager.getDefault().getCurrentPhoneType()) {
92 case PhoneConstants.PHONE_TYPE_CDMA:
93 return new CdmaCellLocation();
94 case PhoneConstants.PHONE_TYPE_GSM:
95 return new GsmCellLocation();