Make setMetered and setOpportunistic public.
Making SubscriptionManager#setMetered and #setOpportunistic public APIs. Adding proper permission checks and descriptions. Bug: 120138251 Test: cts, unittest Change-Id: Id6f074b15a1c03d00ede2665d44595fa7be965e4
This commit is contained in:
@@ -57,6 +57,7 @@ package android {
|
||||
field public static final java.lang.String BROADCAST_SMS = "android.permission.BROADCAST_SMS";
|
||||
field public static final java.lang.String BROADCAST_STICKY = "android.permission.BROADCAST_STICKY";
|
||||
field public static final java.lang.String BROADCAST_WAP_PUSH = "android.permission.BROADCAST_WAP_PUSH";
|
||||
field public static final java.lang.String CALL_COMPANION_APP = "android.permission.CALL_COMPANION_APP";
|
||||
field public static final java.lang.String CALL_PHONE = "android.permission.CALL_PHONE";
|
||||
field public static final java.lang.String CALL_PRIVILEGED = "android.permission.CALL_PRIVILEGED";
|
||||
field public static final java.lang.String CAMERA = "android.permission.CAMERA";
|
||||
@@ -91,7 +92,6 @@ package android {
|
||||
field public static final java.lang.String LOCATION_HARDWARE = "android.permission.LOCATION_HARDWARE";
|
||||
field public static final java.lang.String MANAGE_DOCUMENTS = "android.permission.MANAGE_DOCUMENTS";
|
||||
field public static final java.lang.String MANAGE_OWN_CALLS = "android.permission.MANAGE_OWN_CALLS";
|
||||
field public static final java.lang.String CALL_COMPANION_APP = "android.permission.CALL_COMPANION_APP";
|
||||
field public static final java.lang.String MASTER_CLEAR = "android.permission.MASTER_CLEAR";
|
||||
field public static final java.lang.String MEDIA_CONTENT_CONTROL = "android.permission.MEDIA_CONTENT_CONTROL";
|
||||
field public static final java.lang.String MODIFY_AUDIO_SETTINGS = "android.permission.MODIFY_AUDIO_SETTINGS";
|
||||
@@ -43166,6 +43166,7 @@ package android.telecom {
|
||||
field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.telecom.extra.INCOMING_CALL_EXTRAS";
|
||||
field public static final java.lang.String EXTRA_INCOMING_VIDEO_STATE = "android.telecom.extra.INCOMING_VIDEO_STATE";
|
||||
field public static final java.lang.String EXTRA_IS_DEFAULT_CALL_SCREENING_APP = "android.telecom.extra.IS_DEFAULT_CALL_SCREENING_APP";
|
||||
field public static final java.lang.String EXTRA_IS_ENABLED = "android.telecom.extra.IS_ENABLED";
|
||||
field public static final java.lang.String EXTRA_NOTIFICATION_COUNT = "android.telecom.extra.NOTIFICATION_COUNT";
|
||||
field public static final java.lang.String EXTRA_NOTIFICATION_PHONE_NUMBER = "android.telecom.extra.NOTIFICATION_PHONE_NUMBER";
|
||||
field public static final java.lang.String EXTRA_OUTGOING_CALL_EXTRAS = "android.telecom.extra.OUTGOING_CALL_EXTRAS";
|
||||
@@ -43173,14 +43174,13 @@ package android.telecom {
|
||||
field public static final java.lang.String EXTRA_START_CALL_WITH_RTT = "android.telecom.extra.START_CALL_WITH_RTT";
|
||||
field public static final java.lang.String EXTRA_START_CALL_WITH_SPEAKERPHONE = "android.telecom.extra.START_CALL_WITH_SPEAKERPHONE";
|
||||
field public static final java.lang.String EXTRA_START_CALL_WITH_VIDEO_STATE = "android.telecom.extra.START_CALL_WITH_VIDEO_STATE";
|
||||
field public static final java.lang.String EXTRA_IS_ENABLED = "android.telecom.extra.IS_ENABLED";
|
||||
field public static final java.lang.String GATEWAY_ORIGINAL_ADDRESS = "android.telecom.extra.GATEWAY_ORIGINAL_ADDRESS";
|
||||
field public static final java.lang.String GATEWAY_PROVIDER_PACKAGE = "android.telecom.extra.GATEWAY_PROVIDER_PACKAGE";
|
||||
field public static final java.lang.String METADATA_INCLUDE_EXTERNAL_CALLS = "android.telecom.INCLUDE_EXTERNAL_CALLS";
|
||||
field public static final java.lang.String METADATA_INCLUDE_SELF_MANAGED_CALLS = "android.telecom.INCLUDE_SELF_MANAGED_CALLS";
|
||||
field public static final java.lang.String METADATA_IN_CALL_SERVICE_CAR_MODE_UI = "android.telecom.IN_CALL_SERVICE_CAR_MODE_UI";
|
||||
field public static final java.lang.String METADATA_IN_CALL_SERVICE_RINGING = "android.telecom.IN_CALL_SERVICE_RINGING";
|
||||
field public static final java.lang.String METADATA_IN_CALL_SERVICE_UI = "android.telecom.IN_CALL_SERVICE_UI";
|
||||
field public static final java.lang.String METADATA_IN_CALL_SERVICE_CAR_MODE_UI = "android.telecom.IN_CALL_SERVICE_CAR_MODE_UI";
|
||||
field public static final int PRESENTATION_ALLOWED = 1; // 0x1
|
||||
field public static final int PRESENTATION_PAYPHONE = 4; // 0x4
|
||||
field public static final int PRESENTATION_RESTRICTED = 2; // 0x2
|
||||
@@ -44174,6 +44174,8 @@ package android.telephony {
|
||||
method public void removeOnOpportunisticSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener);
|
||||
method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener);
|
||||
method public boolean removeSubscriptionsFromGroup(int[]);
|
||||
method public boolean setMetered(boolean, int);
|
||||
method public boolean setOpportunistic(boolean, int);
|
||||
method public java.lang.String setSubscriptionGroup(int[]);
|
||||
method public void setSubscriptionOverrideCongested(int, boolean, long);
|
||||
method public void setSubscriptionOverrideUnmetered(int, boolean, long);
|
||||
|
||||
@@ -1996,6 +1996,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
|
||||
}
|
||||
|
||||
if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) {
|
||||
// It can have either READ_PHONE_STATE or READ_PRIVILEGED_PHONE_STATE.
|
||||
TelephonyPermissions.checkReadPhoneState(mContext,
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID, Binder.getCallingPid(),
|
||||
Binder.getCallingUid(), callingPackage, "listen to "
|
||||
+ "LISTEN_PREFERRED_DATA_SUBID_CHANGE");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -572,7 +572,6 @@ public class SubscriptionManager {
|
||||
* TelephonyProvider column name for whether a subscription is opportunistic, that is,
|
||||
* whether the network it connects to is limited in functionality or coverage.
|
||||
* For example, CBRS.
|
||||
* IS_EMBEDDED should always be true.
|
||||
* <p>Type: INTEGER (int), 1 for opportunistic or 0 for non-opportunistic.
|
||||
* @hide
|
||||
*/
|
||||
@@ -2379,18 +2378,32 @@ public class SubscriptionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set opportunistic by simInfo index
|
||||
* Set whether a subscription is opportunistic, that is, whether the network it connects
|
||||
* to has limited coverage. For example, CBRS. Setting a subscription opportunistic has
|
||||
* following impacts:
|
||||
* 1) Even if it's active, it will be dormant most of the time. The modem will not try
|
||||
* to scan or camp until it knows an available network is nearby to save power.
|
||||
* 2) Telephony relies on system app or carrier input to notify nearby available networks.
|
||||
* See {@link TelephonyManager#updateAvailableNetworks(List)} for more information.
|
||||
* 3) In multi-SIM devices, when the network is nearby and camped, system may automatically
|
||||
* switch internet data between it and default data subscription, based on carrier
|
||||
* recommendation and its signal strength and metered-ness, etc.
|
||||
*
|
||||
*
|
||||
* Caller will either have {@link android.Manifest.permission#MODIFY_PHONE_STATE} or carrier
|
||||
* privilege permission of the subscription.
|
||||
*
|
||||
* @param opportunistic whether it’s opportunistic subscription.
|
||||
* @param subId the unique SubscriptionInfo index in database
|
||||
* @return the number of records updated
|
||||
* @hide
|
||||
* @return {@code true} if the operation is succeed, {@code false} otherwise.
|
||||
*/
|
||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public int setOpportunistic(boolean opportunistic, int subId) {
|
||||
public boolean setOpportunistic(boolean opportunistic, int subId) {
|
||||
if (VDBG) logd("[setOpportunistic]+ opportunistic:" + opportunistic + " subId:" + subId);
|
||||
return setSubscriptionPropertyHelper(subId, "setOpportunistic",
|
||||
(iSub)-> iSub.setOpportunistic(opportunistic, subId));
|
||||
(iSub)-> iSub.setOpportunistic(
|
||||
opportunistic, subId, mContext.getOpPackageName())) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2510,18 +2523,26 @@ public class SubscriptionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set metered by simInfo index
|
||||
* Set if a subscription is metered or not. Similar to Wi-Fi, metered means
|
||||
* user may be charged more if more data is used.
|
||||
*
|
||||
* By default all Cellular networks are considered metered. System or carrier privileged apps
|
||||
* can set a subscription un-metered which will be considered when system switches data between
|
||||
* primary subscription and opportunistic subscription.
|
||||
*
|
||||
* Caller will either have {@link android.Manifest.permission#MODIFY_PHONE_STATE} or carrier
|
||||
* privilege permission of the subscription.
|
||||
*
|
||||
* @param isMetered whether it’s a metered subscription.
|
||||
* @param subId the unique SubscriptionInfo index in database
|
||||
* @return the number of records updated
|
||||
* @hide
|
||||
* @return {@code true} if the operation is succeed, {@code false} otherwise.
|
||||
*/
|
||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public int setMetered(boolean isMetered, int subId) {
|
||||
public boolean setMetered(boolean isMetered, int subId) {
|
||||
if (VDBG) logd("[setIsMetered]+ isMetered:" + isMetered + " subId:" + subId);
|
||||
return setSubscriptionPropertyHelper(subId, "setIsMetered",
|
||||
(iSub)-> iSub.setMetered(isMetered, subId));
|
||||
(iSub)-> iSub.setMetered(isMetered, subId, mContext.getOpPackageName())) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6630,8 +6630,8 @@ public class TelephonyManager {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.getCarrierPrivilegeStatus(subId) ==
|
||||
CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
|
||||
return telephony.getCarrierPrivilegeStatus(subId)
|
||||
== CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
Rlog.e(TAG, "hasCarrierPrivileges RemoteException", ex);
|
||||
|
||||
@@ -162,7 +162,7 @@ interface ISub {
|
||||
* @param subId the unique SubscriptionInfo index in database
|
||||
* @return the number of records updated
|
||||
*/
|
||||
int setOpportunistic(boolean opportunistic, int subId);
|
||||
int setOpportunistic(boolean opportunistic, int subId, String callingPackage);
|
||||
|
||||
/**
|
||||
* Inform SubscriptionManager that subscriptions in the list are bundled
|
||||
@@ -190,7 +190,7 @@ interface ISub {
|
||||
* @param subId the unique SubscriptionInfo index in database
|
||||
* @return the number of records updated
|
||||
*/
|
||||
int setMetered(boolean isMetered, int subId);
|
||||
int setMetered(boolean isMetered, int subId, String callingPackage);
|
||||
|
||||
/**
|
||||
* Set which subscription is preferred for cellular data. It's
|
||||
|
||||
Reference in New Issue
Block a user