Merge "Add Support for Async requestCellInfoUpdate()" am: 992aafb2bd

am: f3d183108b

Change-Id: Iee76a8ee4cd04cf5847ab33320635f7dab29d9e2
This commit is contained in:
Nathan Harold
2018-11-16 12:58:31 -08:00
committed by android-build-merger
6 changed files with 171 additions and 27 deletions

View File

@@ -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",

View File

@@ -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);

View File

@@ -5328,6 +5328,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);

View File

@@ -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);
}

View File

@@ -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.
* methods may return true, indicating that the cell is being used or would be used for
* signaling communication if necessary.
*
* <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>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>
* This method is preferred over using {@link
* <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) {
}
}

View File

@@ -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,10 +509,25 @@ 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
*/