summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Harold <nharold@google.com>2018-11-16 19:13:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-11-16 19:13:36 +0000
commit992aafb2bd20fb8c051ba110f496f100266a28aa (patch)
tree558eec899a82395f8a24abf98fde7494bea5a21a
parent8aeeea135ab5609b4eab19c9ffea33eca4e185b8 (diff)
parent2aa2cc1b757b86ae6cef53f67dc54662f4f18a4a (diff)
Merge "Add Support for Async requestCellInfoUpdate()"
-rw-r--r--Android.bp1
-rwxr-xr-xapi/current.txt6
-rw-r--r--api/system-current.txt1
-rw-r--r--telephony/java/android/telephony/ICellInfoCallback.aidl30
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java145
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl19
6 files changed, 173 insertions, 29 deletions
diff --git a/Android.bp b/Android.bp
index d9330f70aae6..8b607459a98d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -512,6 +512,7 @@ java_defaults {
"telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl",
"telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl",
"telephony/java/android/telephony/mbms/vendor/IMbmsGroupCallService.aidl",
+ "telephony/java/android/telephony/ICellInfoCallback.aidl",
"telephony/java/android/telephony/INetworkService.aidl",
"telephony/java/android/telephony/INetworkServiceCallback.aidl",
"telephony/java/com/android/ims/internal/IImsCallSession.aidl",
diff --git a/api/current.txt b/api/current.txt
index ff4e00fa6f26..3c014cbd6ee7 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -42978,6 +42978,7 @@ package android.telephony {
method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle);
method public boolean isWorldPhone();
method public void listen(android.telephony.PhoneStateListener, int);
+ method public void requestCellInfoUpdate(java.util.concurrent.Executor, android.telephony.TelephonyManager.CellInfoCallback);
method public android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, java.util.concurrent.Executor, android.telephony.TelephonyScanManager.NetworkScanCallback);
method public void sendDialerSpecialCode(java.lang.String);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
@@ -43078,6 +43079,11 @@ package android.telephony {
field public static final java.lang.String VVM_TYPE_OMTP = "vvm_type_omtp";
}
+ public static abstract class TelephonyManager.CellInfoCallback {
+ ctor public TelephonyManager.CellInfoCallback();
+ method public abstract void onCellInfo(java.util.List<android.telephony.CellInfo>);
+ }
+
public static abstract class TelephonyManager.UssdResponseCallback {
ctor public TelephonyManager.UssdResponseCallback();
method public void onReceiveUssdResponse(android.telephony.TelephonyManager, java.lang.String, java.lang.CharSequence);
diff --git a/api/system-current.txt b/api/system-current.txt
index b81d59d00039..aac8ebd29052 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5329,6 +5329,7 @@ package android.telephony {
method public deprecated boolean isVisualVoicemailEnabled(android.telecom.PhoneAccountHandle);
method public boolean needsOtaServiceProvisioning();
method public boolean rebootRadio();
+ method public void requestCellInfoUpdate(android.os.WorkSource, java.util.concurrent.Executor, android.telephony.TelephonyManager.CellInfoCallback);
method public boolean resetRadioConfig();
method public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
method public void setCarrierDataEnabled(boolean);
diff --git a/telephony/java/android/telephony/ICellInfoCallback.aidl b/telephony/java/android/telephony/ICellInfoCallback.aidl
new file mode 100644
index 000000000000..7fb62682703a
--- /dev/null
+++ b/telephony/java/android/telephony/ICellInfoCallback.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+import android.telephony.CellInfo;
+
+import java.util.List;
+
+/**
+ * Callback to provide asynchronous CellInfo.
+ * @hide
+ */
+oneway interface ICellInfoCallback
+{
+ void onCellInfo(in List<CellInfo> state);
+}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 80e82ef7fde6..22f63a707bc0 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -21,6 +21,7 @@ import static android.content.Context.TELECOM_SERVICE;
import static com.android.internal.util.Preconditions.checkNotNull;
import android.Manifest;
+import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -43,6 +44,7 @@ import android.net.NetworkStats;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.BatteryStats;
+import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -52,6 +54,7 @@ import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.os.WorkSource;
import android.provider.Settings.SettingNotFoundException;
import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
@@ -4728,37 +4731,42 @@ public class TelephonyManager {
}
/**
- * Returns all observed cell information from all radios on the
- * device including the primary and neighboring cells. Calling this method does
- * not trigger a call to {@link android.telephony.PhoneStateListener#onCellInfoChanged
- * onCellInfoChanged()}, or change the rate at which
- * {@link android.telephony.PhoneStateListener#onCellInfoChanged
- * onCellInfoChanged()} is called.
+ * Requests all available cell information from all radios on the device including the
+ * camped/registered, serving, and neighboring cells.
*
- *<p>
- * The list can include one or more {@link android.telephony.CellInfoGsm CellInfoGsm},
+ * <p>The response can include one or more {@link android.telephony.CellInfoGsm CellInfoGsm},
* {@link android.telephony.CellInfoCdma CellInfoCdma},
+ * {@link android.telephony.CellInfoTdscdma CellInfoTdscdma},
* {@link android.telephony.CellInfoLte CellInfoLte}, and
* {@link android.telephony.CellInfoWcdma CellInfoWcdma} objects, in any combination.
- * On devices with multiple radios it is typical to see instances of
- * one or more of any these in the list. In addition, zero, one, or more
- * of the returned objects may be considered registered; that is, their
+ * It is typical to see instances of one or more of any these in the list. In addition, zero
+ * or more of the returned objects may be considered registered; that is, their
* {@link android.telephony.CellInfo#isRegistered CellInfo.isRegistered()}
- * methods may return true.
- *
- * <p>This method returns valid data for registered cells on devices with
- * {@link android.content.pm.PackageManager#FEATURE_TELEPHONY}. In cases where only
- * partial information is available for a particular CellInfo entry, unavailable fields
- * will be reported as Integer.MAX_VALUE. All reported cells will include at least a
- * valid set of technology-specific identification info and a power level measurement.
- *
- *<p>
- * This method is preferred over using {@link
+ * methods may return true, indicating that the cell is being used or would be used for
+ * signaling communication if necessary.
+ *
+ * <p>Beginning with {@link android.os.Build.VERSION_CODES#Q Android Q},
+ * if this API results in a change of the cached CellInfo, that change will be reported via
+ * {@link android.telephony.PhoneStateListener#onCellInfoChanged onCellInfoChanged()}.
+ *
+ * <p>Apps targeting {@link android.os.Build.VERSION_CODES#Q Android Q} or higher will no
+ * longer trigger a refresh of the cached CellInfo by invoking this API. Instead, those apps
+ * will receive the latest cached results. Apps targeting
+ * {@link android.os.Build.VERSION_CODES#Q Android Q} or higher that wish to request updated
+ * CellInfo should call
+ * {android.telephony.TelephonyManager#requestCellInfoUpdate requestCellInfoUpdate()} and
+ * listen for responses via {@link android.telephony.PhoneStateListener#onCellInfoChanged
+ * onCellInfoChanged()}.
+ *
+ * <p>This method returns valid data for devices with
+ * {@link android.content.pm.PackageManager#FEATURE_TELEPHONY FEATURE_TELEPHONY}. In cases
+ * where only partial information is available for a particular CellInfo entry, unavailable
+ * fields will be reported as {@link android.telephony.CellInfo#UNAVAILABLE}. All reported
+ * cells will include at least a valid set of technology-specific identification info and a
+ * power level measurement.
+ *
+ * <p>This method is preferred over using {@link
* android.telephony.TelephonyManager#getCellLocation getCellLocation()}.
- * However, for older devices, <code>getAllCellInfo()</code> may return
- * null. In these cases, you should call {@link
- * android.telephony.TelephonyManager#getCellLocation getCellLocation()}
- * instead.
*
* @return List of {@link android.telephony.CellInfo}; null if cell
* information is unavailable.
@@ -4769,11 +4777,92 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony == null)
return null;
- return telephony.getAllCellInfo(getOpPackageName());
+ return telephony.getAllCellInfo(
+ getOpPackageName());
} catch (RemoteException ex) {
- return null;
} catch (NullPointerException ex) {
- return null;
+ }
+ return null;
+ }
+
+ /** Callback for providing asynchronous {@link CellInfo} on request */
+ public abstract static class CellInfoCallback {
+ /**
+ * Response to
+ * {@link android.telephony.TelephonyManager#requestCellInfoUpdate requestCellInfoUpdate()}.
+ *
+ * <p>Invoked when there is a response to
+ * {@link android.telephony.TelephonyManager#requestCellInfoUpdate requestCellInfoUpdate()}
+ * to provide a list of {@link CellInfo}. If no {@link CellInfo} is available then an empty
+ * list will be provided. If an error occurs, null will be provided.
+ *
+ * @param cellInfo a list of {@link CellInfo}, an empty list, or null.
+ *
+ * {@see android.telephony.TelephonyManager#getAllCellInfo getAllCellInfo()}
+ */
+ public abstract void onCellInfo(List<CellInfo> cellInfo);
+ };
+
+ /**
+ * Requests all available cell information from the current subscription for observed
+ * camped/registered, serving, and neighboring cells.
+ *
+ * <p>Any available results from this request will be provided by calls to
+ * {@link android.telephony.PhoneStateListener#onCellInfoChanged onCellInfoChanged()}
+ * for each active subscription.
+ *
+ * @param executor the executor on which callback will be invoked.
+ * @param callback a callback to receive CellInfo.
+ */
+ @RequiresPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION)
+ public void requestCellInfoUpdate(
+ @NonNull Executor executor, @NonNull CellInfoCallback callback) {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony == null) return;
+ telephony.requestCellInfoUpdate(
+ getSubId(),
+ new ICellInfoCallback.Stub() {
+ public void onCellInfo(List<CellInfo> cellInfo) {
+ Binder.withCleanCallingIdentity(() ->
+ executor.execute(() -> callback.onCellInfo(cellInfo)));
+ }
+ }, getOpPackageName());
+
+ } catch (RemoteException ex) {
+ }
+ }
+
+ /**
+ * Requests all available cell information from the current subscription for observed
+ * camped/registered, serving, and neighboring cells.
+ *
+ * <p>Any available results from this request will be provided by calls to
+ * {@link android.telephony.PhoneStateListener#onCellInfoChanged onCellInfoChanged()}
+ * for each active subscription.
+ *
+ * @param workSource the requestor to whom the power consumption for this should be attributed.
+ * @param executor the executor on which callback will be invoked.
+ * @param callback a callback to receive CellInfo.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(allOf = {android.Manifest.permission.ACCESS_COARSE_LOCATION,
+ android.Manifest.permission.MODIFY_PHONE_STATE})
+ public void requestCellInfoUpdate(@NonNull WorkSource workSource,
+ @NonNull @CallbackExecutor Executor executor, @NonNull CellInfoCallback callback) {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony == null) return;
+ telephony.requestCellInfoUpdateWithWorkSource(
+ getSubId(),
+ new ICellInfoCallback.Stub() {
+ public void onCellInfo(List<CellInfo> cellInfo) {
+ Binder.withCleanCallingIdentity(() ->
+ executor.execute(() -> callback.onCellInfo(cellInfo)));
+ }
+ }, getOpPackageName(), workSource);
+ } catch (RemoteException ex) {
}
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index ddcd78070a47..20fde39655f9 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -22,6 +22,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.Messenger;
import android.os.ResultReceiver;
+import android.os.WorkSource;
import android.net.NetworkStats;
import android.net.Uri;
import android.service.carrier.CarrierIdentifier;
@@ -30,6 +31,7 @@ import android.telecom.PhoneAccountHandle;
import android.telephony.CellInfo;
import android.telephony.ClientRequestStats;
import android.telephony.IccOpenLogicalChannelResponse;
+import android.telephony.ICellInfoCallback;
import android.telephony.ModemActivityInfo;
import android.telephony.NeighboringCellInfo;
import android.telephony.NetworkScanRequest;
@@ -507,11 +509,26 @@ interface ITelephony {
int getLteOnCdmaModeForSubscriber(int subId, String callingPackage);
/**
- * Returns the all observed cell information of the device.
+ * Returns all observed cell information of the device.
*/
List<CellInfo> getAllCellInfo(String callingPkg);
/**
+ * Request a cell information update for the specified subscription,
+ * reported via the CellInfoCallback.
+ */
+ void requestCellInfoUpdate(int subId, in ICellInfoCallback cb, String callingPkg);
+
+ /**
+ * Request a cell information update for the specified subscription,
+ * reported via the CellInfoCallback.
+ *
+ * @param workSource the requestor to whom the power consumption for this should be attributed.
+ */
+ void requestCellInfoUpdateWithWorkSource(
+ int subId, in ICellInfoCallback cb, in String callingPkg, in WorkSource ws);
+
+ /**
* Sets minimum time in milli-seconds between onCellInfoChanged
*/
void setCellInfoListRate(int rateInMillis);