Remove permission check for LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE

Bug: 140020981
Test: sanity
Change-Id: I060511af068bfbbc9fea5c5d27a5d04eb2924fda
This commit is contained in:
Malcolm Chen
2019-09-04 16:10:34 -07:00
parent 2ff45bfae8
commit f028c3bb68
2 changed files with 6 additions and 27 deletions

View File

@@ -79,7 +79,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
/**
* Since phone process can be restarted, this class provides a centralized place
@@ -849,10 +848,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
if ((events & PhoneStateListener
.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE) != 0
&& TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(
r.context, r.callerPid, r.callerUid, r.callingPackage,
"listen_active_data_subid_change")) {
.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE) != 0) {
try {
r.callback.onActiveDataSubIdChanged(mActiveDataSubId);
} catch (RemoteException ex) {
@@ -1829,23 +1825,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId);
}
// Create a copy to prevent the IPC call while checking carrier privilege under the lock.
List<Record> copiedRecords;
synchronized (mRecords) {
copiedRecords = new ArrayList<>(mRecords);
}
mActiveDataSubId = activeDataSubId;
// Filter the record that does not listen to this change or does not have the permission.
copiedRecords = copiedRecords.stream().filter(r -> r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE)
&& TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(
mContext, r.callerPid, r.callerUid, r.callingPackage,
"notifyActiveDataSubIdChanged")).collect(Collectors.toCollection(ArrayList::new));
synchronized (mRecords) {
for (Record r : copiedRecords) {
if (mRecords.contains(r)) {
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE)) {
try {
r.callback.onActiveDataSubIdChanged(activeDataSubId);
} catch (RemoteException ex) {

View File

@@ -33,13 +33,13 @@ import android.telephony.ims.ImsReasonInfo;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.IPhoneStateListener;
import dalvik.system.VMRuntime;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import dalvik.system.VMRuntime;
/**
* A listener class for monitoring changes in specific telephony states
* on the device, including service state, signal strength, message
@@ -301,11 +301,6 @@ public class PhoneStateListener {
* it could be the current active opportunistic subscription in use, or the
* subscription user selected as default data subscription in DSDS mode.
*
* Requires Permission: No permission is required to listen, but notification requires
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} or the calling
* app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges})
* on any active subscription.
*
* @see #onActiveDataSubscriptionIdChanged
*/
public static final int LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE = 0x00400000;