Merge "Support new APIs in TelephonyManager to set/clear signal update request"
This commit is contained in:
@@ -40832,6 +40832,7 @@ package android.telephony {
|
||||
|
||||
public final class SignalStrengthUpdateRequest implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @NonNull public android.os.IBinder getLiveToken();
|
||||
method @NonNull public java.util.Collection<android.telephony.SignalThresholdInfo> getSignalThresholdInfos();
|
||||
method public boolean isReportingRequestedWhileIdle();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
@@ -41209,6 +41210,7 @@ package android.telephony {
|
||||
|
||||
public class TelephonyManager {
|
||||
method public boolean canChangeDtmfToneLength();
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void clearSignalStrengthUpdateRequest(@NonNull android.telephony.SignalStrengthUpdateRequest);
|
||||
method @Nullable public android.telephony.TelephonyManager createForPhoneAccountHandle(android.telecom.PhoneAccountHandle);
|
||||
method public android.telephony.TelephonyManager createForSubscriptionId(int);
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean doesSwitchMultiSimConfigTriggerReboot();
|
||||
@@ -41321,6 +41323,7 @@ package android.telephony {
|
||||
method public boolean setOperatorBrandOverride(String);
|
||||
method public boolean setPreferredNetworkTypeToGlobal();
|
||||
method public void setPreferredOpportunisticDataSubscription(int, boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSignalStrengthUpdateRequest(@NonNull android.telephony.SignalStrengthUpdateRequest);
|
||||
method public void setVisualVoicemailSmsFilterSettings(android.telephony.VisualVoicemailSmsFilterSettings);
|
||||
method public boolean setVoiceMailNumber(String, String);
|
||||
method @Deprecated public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
**
|
||||
** Copyright (C) 2020 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;
|
||||
|
||||
parcelable SignalStrengthUpdateRequest;
|
||||
@@ -17,6 +17,8 @@
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
@@ -56,6 +58,11 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
||||
*/
|
||||
private final boolean mIsSystemThresholdReportingRequestedWhileIdle;
|
||||
|
||||
/**
|
||||
* A IBinder object as a token for server side to check if the request client is still living.
|
||||
*/
|
||||
private final IBinder mLiveToken;
|
||||
|
||||
private SignalStrengthUpdateRequest(
|
||||
@NonNull List<SignalThresholdInfo> signalThresholdInfos,
|
||||
boolean isReportingRequestedWhileIdle,
|
||||
@@ -66,6 +73,7 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
||||
mIsReportingRequestedWhileIdle = isReportingRequestedWhileIdle;
|
||||
mIsSystemThresholdReportingRequestedWhileIdle =
|
||||
isSystemThresholdReportingRequestedWhileIdle;
|
||||
mLiveToken = new Binder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,6 +156,7 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
||||
mSignalThresholdInfos = in.createTypedArrayList(SignalThresholdInfo.CREATOR);
|
||||
mIsReportingRequestedWhileIdle = in.readBoolean();
|
||||
mIsSystemThresholdReportingRequestedWhileIdle = in.readBoolean();
|
||||
mLiveToken = in.readStrongBinder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,6 +187,15 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
||||
return mIsSystemThresholdReportingRequestedWhileIdle;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return the live token of the request
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public @NonNull IBinder getLiveToken() {
|
||||
return mLiveToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
@@ -188,6 +206,7 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
||||
dest.writeTypedList(mSignalThresholdInfos);
|
||||
dest.writeBoolean(mIsReportingRequestedWhileIdle);
|
||||
dest.writeBoolean(mIsSystemThresholdReportingRequestedWhileIdle);
|
||||
dest.writeStrongBinder(mLiveToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,10 +218,10 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
||||
}
|
||||
|
||||
SignalStrengthUpdateRequest request = (SignalStrengthUpdateRequest) other;
|
||||
return request.mSignalThresholdInfos.equals(mSignalThresholdInfos)
|
||||
&& request.mIsReportingRequestedWhileIdle == mIsReportingRequestedWhileIdle
|
||||
&& request.mIsSystemThresholdReportingRequestedWhileIdle
|
||||
== mIsSystemThresholdReportingRequestedWhileIdle;
|
||||
return mSignalThresholdInfos.equals(request.mSignalThresholdInfos)
|
||||
&& mIsReportingRequestedWhileIdle == request.mIsReportingRequestedWhileIdle
|
||||
&& mIsSystemThresholdReportingRequestedWhileIdle
|
||||
== request.mIsSystemThresholdReportingRequestedWhileIdle;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -233,6 +252,8 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
||||
.append(mIsReportingRequestedWhileIdle)
|
||||
.append(" mIsSystemThresholdReportingRequestedWhileIdle=")
|
||||
.append(mIsSystemThresholdReportingRequestedWhileIdle)
|
||||
.append(" mLiveToken")
|
||||
.append(mLiveToken)
|
||||
.append("}").toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -14687,4 +14687,85 @@ public class TelephonyManager {
|
||||
return networkType >= TelephonyManager.NETWORK_TYPE_UNKNOWN &&
|
||||
networkType <= TelephonyManager.NETWORK_TYPE_NR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a {@link SignalStrengthUpdateRequest} to receive notification when signal quality
|
||||
* measurements breach the specified thresholds.
|
||||
*
|
||||
* To be notified, set the signal strength update request and then register
|
||||
* {@link TelephonyManager#listen(PhoneStateListener, int)} with
|
||||
* {@link PhoneStateListener#LISTEN_SIGNAL_STRENGTHS}. The notification will arrive through
|
||||
* {@link PhoneStateListener#onSignalStrengthsChanged(SignalStrength)}.
|
||||
*
|
||||
* To stop receiving the notification over the specified thresholds, pass the same
|
||||
* {@link SignalStrengthUpdateRequest} object to
|
||||
* {@link #clearSignalStrengthUpdateRequest(SignalStrengthUpdateRequest)}.
|
||||
*
|
||||
* System will clean up the {@link SignalStrengthUpdateRequest} if the caller process died
|
||||
* without calling {@link #clearSignalStrengthUpdateRequest(SignalStrengthUpdateRequest)}.
|
||||
*
|
||||
* If this TelephonyManager object has been created with {@link #createForSubscriptionId},
|
||||
* applies to the given subId. Otherwise, applies to
|
||||
* {@link SubscriptionManager#getDefaultSubscriptionId()}. To request for multiple subIds,
|
||||
* pass a request object to each TelephonyManager object created with
|
||||
* {@link #createForSubscriptionId}.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
|
||||
* or that the calling app has carrier privileges (see
|
||||
* {@link TelephonyManager#hasCarrierPrivileges}).
|
||||
*
|
||||
* Note that the thresholds in the request will be used on a best-effort basis; the system may
|
||||
* modify requests to multiplex various request sources or to optimize power consumption. The
|
||||
* caller should not expect to be notified with the exactly the same thresholds.
|
||||
*
|
||||
* @see #clearSignalStrengthUpdateRequest(SignalStrengthUpdateRequest)
|
||||
*
|
||||
* @param request the SignalStrengthUpdateRequest to be set into the System
|
||||
*
|
||||
* @throws IllegalStateException if a new request is set with same subId from the same caller
|
||||
*/
|
||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public void setSignalStrengthUpdateRequest(@NonNull SignalStrengthUpdateRequest request) {
|
||||
Objects.requireNonNull(request, "request must not be null");
|
||||
|
||||
try {
|
||||
ITelephony service = getITelephony();
|
||||
if (service != null) {
|
||||
service.setSignalStrengthUpdateRequest(getSubId(), request, getOpPackageName());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelephony#setSignalStrengthUpdateRequest", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a {@link SignalStrengthUpdateRequest} from the system.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
|
||||
* or that the calling app has carrier privileges (see
|
||||
* {@link TelephonyManager#hasCarrierPrivileges}).
|
||||
*
|
||||
* <p>If the given request was not set before, this operation is a no-op.
|
||||
*
|
||||
* @see #setSignalStrengthUpdateRequest(SignalStrengthUpdateRequest)
|
||||
*
|
||||
* @param request the SignalStrengthUpdateRequest to be cleared from the System
|
||||
*/
|
||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public void clearSignalStrengthUpdateRequest(@NonNull SignalStrengthUpdateRequest request) {
|
||||
Objects.requireNonNull(request, "request must not be null");
|
||||
|
||||
try {
|
||||
ITelephony service = getITelephony();
|
||||
if (service != null) {
|
||||
service.clearSignalStrengthUpdateRequest(getSubId(), request, getOpPackageName());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelephony#clearSignalStrengthUpdateRequest", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import android.telephony.RadioAccessFamily;
|
||||
import android.telephony.RadioAccessSpecifier;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.telephony.SignalStrengthUpdateRequest;
|
||||
import android.telephony.TelephonyHistogram;
|
||||
import android.telephony.VisualVoicemailSmsFilterSettings;
|
||||
import android.telephony.emergency.EmergencyNumber;
|
||||
@@ -2367,4 +2368,17 @@ interface ITelephony {
|
||||
* their mobile plan.
|
||||
*/
|
||||
String getMobileProvisioningUrl();
|
||||
|
||||
/**
|
||||
* Set a SignalStrengthUpdateRequest to receive notification when Signal Strength breach the
|
||||
* specified thresholds.
|
||||
*/
|
||||
void setSignalStrengthUpdateRequest(int subId, in SignalStrengthUpdateRequest request,
|
||||
String callingPackage);
|
||||
|
||||
/**
|
||||
* Clear a SignalStrengthUpdateRequest from system.
|
||||
*/
|
||||
void clearSignalStrengthUpdateRequest(int subId, in SignalStrengthUpdateRequest request,
|
||||
String callingPackage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user