Merge "Clear up ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED logic" am: aac94b26a7 am: f8f8a40658 am: fa8156441d am: 206fc30a50
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1569861 Change-Id: I2e346543e4e71be32c716e286615934b54cf6db7
This commit is contained in:
@@ -190,20 +190,6 @@ public class PhoneStateListener {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static final int LISTEN_SIGNAL_STRENGTHS = 0x00000100;
|
public static final int LISTEN_SIGNAL_STRENGTHS = 0x00000100;
|
||||||
|
|
||||||
/**
|
|
||||||
* Listen for changes of the network signal strengths (cellular) always reported from modem,
|
|
||||||
* even in some situations such as the screen of the device is off.
|
|
||||||
*
|
|
||||||
* @see #onSignalStrengthsChanged
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
* @deprecated Use TelephonyManager#setSignalStrengthUpdateRequest
|
|
||||||
* instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@RequiresPermission(android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)
|
|
||||||
public static final int LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH = 0x00000200;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen for changes to observed cell info.
|
* Listen for changes to observed cell info.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1041,10 +1041,6 @@ public class TelephonyRegistryManager {
|
|||||||
eventList.add(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED);
|
eventList.add(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((eventMask & PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH) != 0) {
|
|
||||||
eventList.add(TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((eventMask & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
|
if ((eventMask & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
|
||||||
eventList.add(TelephonyCallback.EVENT_CELL_INFO_CHANGED);
|
eventList.add(TelephonyCallback.EVENT_CELL_INFO_CHANGED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2400,7 +2400,7 @@
|
|||||||
<permission android:name="android.permission.READ_ACTIVE_EMERGENCY_SESSION"
|
<permission android:name="android.permission.READ_ACTIVE_EMERGENCY_SESSION"
|
||||||
android:protectionLevel="signature" />
|
android:protectionLevel="signature" />
|
||||||
|
|
||||||
<!-- Allows listen permission to always reported signal strength.
|
<!-- Allows listen permission to always reported system signal strength.
|
||||||
@hide Used internally. -->
|
@hide Used internally. -->
|
||||||
<permission android:name="android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH"
|
<permission android:name="android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH"
|
||||||
android:protectionLevel="signature" />
|
android:protectionLevel="signature" />
|
||||||
|
|||||||
@@ -1164,17 +1164,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
remove(r.binder);
|
remove(r.binder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (events.contains(
|
|
||||||
TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED)) {
|
|
||||||
updateReportSignalStrengthDecision(r.subId);
|
|
||||||
try {
|
|
||||||
if (mSignalStrength[r.phoneId] != null) {
|
|
||||||
r.callback.onSignalStrengthsChanged(mSignalStrength[r.phoneId]);
|
|
||||||
}
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
remove(r.binder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (validateEventAndUserLocked(
|
if (validateEventAndUserLocked(
|
||||||
r, TelephonyCallback.EVENT_CELL_INFO_CHANGED)) {
|
r, TelephonyCallback.EVENT_CELL_INFO_CHANGED)) {
|
||||||
try {
|
try {
|
||||||
@@ -1353,27 +1342,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateReportSignalStrengthDecision(int subscriptionId) {
|
|
||||||
synchronized (mRecords) {
|
|
||||||
TelephonyManager telephonyManager = (TelephonyManager) mContext
|
|
||||||
.getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
for (Record r : mRecords) {
|
|
||||||
// If any of the system clients wants to always listen to signal strength,
|
|
||||||
// we need to set it on.
|
|
||||||
if (r.matchTelephonyCallbackEvent(
|
|
||||||
TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED)) {
|
|
||||||
telephonyManager.createForSubscriptionId(subscriptionId)
|
|
||||||
.setAlwaysReportSignalStrength(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If none of the system clients wants to always listen to signal strength,
|
|
||||||
// we need to set it off.
|
|
||||||
telephonyManager.createForSubscriptionId(subscriptionId)
|
|
||||||
.setAlwaysReportSignalStrength(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getCallIncomingNumber(Record record, int phoneId) {
|
private String getCallIncomingNumber(Record record, int phoneId) {
|
||||||
// Only reveal the incoming number if the record has read call log permission.
|
// Only reveal the incoming number if the record has read call log permission.
|
||||||
return record.canReadCallLog() ? mCallIncomingNumber[phoneId] : "";
|
return record.canReadCallLog() ? mCallIncomingNumber[phoneId] : "";
|
||||||
@@ -1457,14 +1425,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mRecords.remove(i);
|
mRecords.remove(i);
|
||||||
|
|
||||||
// Every time a client that is registrating to always receive the signal
|
|
||||||
// strength is removed from registry records, we need to check if
|
|
||||||
// the signal strength decision needs to update on its slot.
|
|
||||||
if (r.matchTelephonyCallbackEvent(
|
|
||||||
TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED)) {
|
|
||||||
updateReportSignalStrengthDecision(r.subId);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1696,10 +1656,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
log("notifySignalStrengthForPhoneId: r=" + r + " subId=" + subId
|
log("notifySignalStrengthForPhoneId: r=" + r + " subId=" + subId
|
||||||
+ " phoneId=" + phoneId + " ss=" + signalStrength);
|
+ " phoneId=" + phoneId + " ss=" + signalStrength);
|
||||||
}
|
}
|
||||||
if ((r.matchTelephonyCallbackEvent(
|
if (r.matchTelephonyCallbackEvent(
|
||||||
TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED)
|
TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED)
|
||||||
|| r.matchTelephonyCallbackEvent(
|
|
||||||
TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED))
|
|
||||||
&& idMatch(r, subId, phoneId)) {
|
&& idMatch(r, subId, phoneId)) {
|
||||||
try {
|
try {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
@@ -3120,11 +3078,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION, null);
|
android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((events.contains(TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED))) {
|
|
||||||
mContext.enforceCallingOrSelfPermission(
|
|
||||||
android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPrivilegedPhoneStatePermissionRequired(events)) {
|
if (isPrivilegedPhoneStatePermissionRequired(events)) {
|
||||||
mContext.enforceCallingOrSelfPermission(
|
mContext.enforceCallingOrSelfPermission(
|
||||||
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
|
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
|
||||||
@@ -3285,9 +3238,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events.contains(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED)
|
if (events.contains(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED)) {
|
||||||
|| events.contains(
|
|
||||||
TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED)) {
|
|
||||||
try {
|
try {
|
||||||
if (mSignalStrength[phoneId] != null) {
|
if (mSignalStrength[phoneId] != null) {
|
||||||
SignalStrength signalStrength = mSignalStrength[phoneId];
|
SignalStrength signalStrength = mSignalStrength[phoneId];
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package android.telephony;
|
package android.telephony;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.RequiresPermission;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@@ -66,10 +68,15 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
|||||||
private final IBinder mLiveToken;
|
private final IBinder mLiveToken;
|
||||||
|
|
||||||
private SignalStrengthUpdateRequest(
|
private SignalStrengthUpdateRequest(
|
||||||
@NonNull List<SignalThresholdInfo> signalThresholdInfos,
|
@Nullable List<SignalThresholdInfo> signalThresholdInfos,
|
||||||
boolean isReportingRequestedWhileIdle,
|
boolean isReportingRequestedWhileIdle,
|
||||||
boolean isSystemThresholdReportingRequestedWhileIdle) {
|
boolean isSystemThresholdReportingRequestedWhileIdle) {
|
||||||
|
// System app (like Bluetooth) can specify the request to report system thresholds while
|
||||||
|
// device is idle (with permission protection). In this case, the request doesn't need to
|
||||||
|
// provide a non-empty list of SignalThresholdInfo which is only asked for public apps.
|
||||||
|
if (!isSystemThresholdReportingRequestedWhileIdle) {
|
||||||
validate(signalThresholdInfos);
|
validate(signalThresholdInfos);
|
||||||
|
}
|
||||||
|
|
||||||
mSignalThresholdInfos = signalThresholdInfos;
|
mSignalThresholdInfos = signalThresholdInfos;
|
||||||
mIsReportingRequestedWhileIdle = isReportingRequestedWhileIdle;
|
mIsReportingRequestedWhileIdle = isReportingRequestedWhileIdle;
|
||||||
@@ -128,13 +135,15 @@ public final class SignalStrengthUpdateRequest implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Set the builder object if require reporting on the system thresholds when device is idle.
|
* Set the builder object if require reporting on the system thresholds when device is idle.
|
||||||
*
|
*
|
||||||
* This can only used by the system caller.
|
* <p>This can only used by the system caller. Requires permission
|
||||||
|
* {@link android.Manifest.permission#LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH}.
|
||||||
*
|
*
|
||||||
* @param isSystemThresholdReportingRequestedWhileIdle true if request reporting on the
|
* @param isSystemThresholdReportingRequestedWhileIdle true if request reporting on the
|
||||||
* system thresholds when device is idle
|
* system thresholds when device is idle
|
||||||
* @return the builder to facilitate the chaining
|
* @return the builder to facilitate the chaining
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@RequiresPermission(android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)
|
||||||
public @NonNull Builder setSystemThresholdReportingRequestedWhileIdle(
|
public @NonNull Builder setSystemThresholdReportingRequestedWhileIdle(
|
||||||
boolean isSystemThresholdReportingRequestedWhileIdle) {
|
boolean isSystemThresholdReportingRequestedWhileIdle) {
|
||||||
mIsSystemThresholdReportingRequestedWhileIdle =
|
mIsSystemThresholdReportingRequestedWhileIdle =
|
||||||
|
|||||||
@@ -12521,26 +12521,6 @@ public class TelephonyManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable or disable signal strength changes from radio will always be reported in any
|
|
||||||
* condition (e.g. screen is off). This is only allowed for System caller.
|
|
||||||
*
|
|
||||||
* @param isEnabled {@code true} for enabling; {@code false} for disabling.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
|
||||||
public void setAlwaysReportSignalStrength(boolean isEnabled) {
|
|
||||||
try {
|
|
||||||
ITelephony telephony = getITelephony();
|
|
||||||
if (telephony != null) {
|
|
||||||
telephony.setAlwaysReportSignalStrength(getSubId(), isEnabled);
|
|
||||||
}
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
Log.e(TAG, "setAlwaysReportSignalStrength RemoteException", ex);
|
|
||||||
ex.rethrowAsRuntimeException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the most recently available signal strength information.
|
* Get the most recently available signal strength information.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1001,11 +1001,6 @@ interface ITelephony {
|
|||||||
*/
|
*/
|
||||||
boolean isManualNetworkSelectionAllowed(int subId);
|
boolean isManualNetworkSelectionAllowed(int subId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable or disable always reporting signal strength changes from radio.
|
|
||||||
*/
|
|
||||||
void setAlwaysReportSignalStrength(int subId, boolean isEnable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get P-CSCF address from PCO after data connection is established or modified.
|
* Get P-CSCF address from PCO after data connection is established or modified.
|
||||||
* @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN
|
* @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN
|
||||||
|
|||||||
Reference in New Issue
Block a user