diff options
19 files changed, 1054 insertions, 97 deletions
diff --git a/api/current.txt b/api/current.txt index bb400567fa6e..27f3b4c56e8d 100755 --- a/api/current.txt +++ b/api/current.txt @@ -6450,6 +6450,7 @@ package android.app.admin { method @Nullable public String[] getAccountTypesWithManagementDisabled(); method @Nullable public java.util.List<android.content.ComponentName> getActiveAdmins(); method @NonNull public java.util.Set<java.lang.String> getAffiliationIds(@NonNull android.content.ComponentName); + method @Nullable public java.util.List<java.lang.String> getAlwaysOnVpnLockdownWhitelist(@NonNull android.content.ComponentName); method @Nullable public String getAlwaysOnVpnPackage(@NonNull android.content.ComponentName); method @WorkerThread @NonNull public android.os.Bundle getApplicationRestrictions(@Nullable android.content.ComponentName, String); method @Deprecated @Nullable public String getApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName); @@ -6519,6 +6520,7 @@ package android.app.admin { method public boolean isActivePasswordSufficient(); method public boolean isAdminActive(@NonNull android.content.ComponentName); method public boolean isAffiliatedUser(); + method public boolean isAlwaysOnVpnLockdownEnabled(@NonNull android.content.ComponentName); method public boolean isApplicationHidden(@NonNull android.content.ComponentName, String); method public boolean isBackupServiceEnabled(@NonNull android.content.ComponentName); method @Deprecated public boolean isCallerApplicationRestrictionsManagingPackage(); @@ -6555,7 +6557,8 @@ package android.app.admin { method @Nullable public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrieveSecurityLogs(@NonNull android.content.ComponentName); method public void setAccountManagementDisabled(@NonNull android.content.ComponentName, String, boolean); method public void setAffiliationIds(@NonNull android.content.ComponentName, @NonNull java.util.Set<java.lang.String>); - method public void setAlwaysOnVpnPackage(@NonNull android.content.ComponentName, @Nullable String, boolean) throws android.content.pm.PackageManager.NameNotFoundException, java.lang.UnsupportedOperationException; + method public void setAlwaysOnVpnPackage(@NonNull android.content.ComponentName, @Nullable String, boolean) throws android.content.pm.PackageManager.NameNotFoundException; + method public void setAlwaysOnVpnPackage(@NonNull android.content.ComponentName, @Nullable String, boolean, @Nullable java.util.List<java.lang.String>) throws android.content.pm.PackageManager.NameNotFoundException; method public boolean setApplicationHidden(@NonNull android.content.ComponentName, String, boolean); method @WorkerThread public void setApplicationRestrictions(@Nullable android.content.ComponentName, String, android.os.Bundle); method @Deprecated public void setApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName, @Nullable String) throws android.content.pm.PackageManager.NameNotFoundException; @@ -41956,8 +41959,8 @@ package android.telecom { } public static final class VideoProfile.CameraCapabilities implements android.os.Parcelable { - ctor public VideoProfile.CameraCapabilities(int, int); - ctor public VideoProfile.CameraCapabilities(int, int, boolean, float); + ctor public VideoProfile.CameraCapabilities(@IntRange(from=0) int, @IntRange(from=0) int); + ctor public VideoProfile.CameraCapabilities(@IntRange(from=0) int, @IntRange(from=0) int, boolean, @FloatRange(from=1.0f) float); method public int describeContents(); method public int getHeight(); method public float getMaxZoom(); @@ -42217,6 +42220,9 @@ package android.telephony { field public static final String KEY_MONTHLY_DATA_CYCLE_DAY_INT = "monthly_data_cycle_day_int"; field public static final String KEY_ONLY_SINGLE_DC_ALLOWED_INT_ARRAY = "only_single_dc_allowed_int_array"; field public static final String KEY_OPERATOR_SELECTION_EXPAND_BOOL = "operator_selection_expand_bool"; + field public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG = "opportunistic_network_data_switch_hysteresis_time_long"; + field public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_OR_EXIT_HYSTERESIS_TIME_LONG = "opportunistic_network_entry_or_exit_hysteresis_time_long"; + field public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_BANDWIDTH_INT = "opportunistic_network_entry_threshold_bandwidth_int"; field public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSRP_INT = "opportunistic_network_entry_threshold_rsrp_int"; field public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSSNR_INT = "opportunistic_network_entry_threshold_rssnr_int"; field public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSRP_INT = "opportunistic_network_exit_threshold_rsrp_int"; @@ -42878,6 +42884,7 @@ package android.telephony { public class SubscriptionInfo implements android.os.Parcelable { method public android.graphics.Bitmap createIconBitmap(android.content.Context); method public int describeContents(); + method public int getCardId(); method public int getCarrierId(); method public CharSequence getCarrierName(); method public String getCountryIso(); @@ -42994,6 +43001,7 @@ package android.telephony { method public android.telephony.TelephonyManager createForSubscriptionId(int); method @RequiresPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) public java.util.List<android.telephony.CellInfo> getAllCellInfo(); method public int getCallState(); + method public int getCardIdForDefaultEuicc(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) @WorkerThread public android.os.PersistableBundle getCarrierConfig(); method public int getCarrierIdFromSimMccMnc(); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public android.telephony.CellLocation getCellLocation(); @@ -43041,6 +43049,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getSubscriberId(); method public String getTypeAllocationCode(); method public String getTypeAllocationCode(int); + method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public java.util.List<android.telephony.UiccCardInfo> getUiccCardsInfo(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVisualVoicemailPackageName(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailAlphaTag(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailNumber(); @@ -43132,6 +43141,7 @@ package android.telephony { field public static final String EXTRA_STATE_RINGING; field public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID"; field public static final String EXTRA_VOICEMAIL_NUMBER = "android.telephony.extra.VOICEMAIL_NUMBER"; + field public static final int INVALID_CARD_ID = -1; // 0xffffffff field public static final String METADATA_HIDE_VOICEMAIL_SETTINGS_MENU = "android.telephony.HIDE_VOICEMAIL_SETTINGS_MENU"; field public static final int NETWORK_TYPE_1xRTT = 7; // 0x7 field public static final int NETWORK_TYPE_CDMA = 4; // 0x4 @@ -43199,6 +43209,18 @@ package android.telephony { method public void onResults(java.util.List<android.telephony.CellInfo>); } + public final class UiccCardInfo implements android.os.Parcelable { + ctor public UiccCardInfo(boolean, int, String, String, int); + method public int describeContents(); + method public int getCardId(); + method public String getEid(); + method public String getIccId(); + method public int getSlotIndex(); + method public boolean isEuicc(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.telephony.UiccCardInfo> CREATOR; + } + public abstract class VisualVoicemailService extends android.app.Service { ctor public VisualVoicemailService(); method public android.os.IBinder onBind(android.content.Intent); diff --git a/api/system-current.txt b/api/system-current.txt index e0801b7acbe1..97094c7b62b5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6226,7 +6226,6 @@ package android.telephony { public class SubscriptionInfo implements android.os.Parcelable { method @Nullable public java.util.List<android.telephony.UiccAccessRule> getAccessRules(); - method public int getCardId(); method public int getProfileClass(); } @@ -6286,7 +6285,6 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void enableVideoCalling(boolean); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getAidForAppType(int); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int); - method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getCardIdForDefaultEuicc(); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.CarrierRestrictionRules getCarrierRestrictionRules(); @@ -6310,7 +6308,6 @@ package android.telephony { method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getSimLocale(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSupportedRadioAccessFamily(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public java.util.List<android.telephony.TelephonyHistogram> getTelephonyHistograms(); - method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.UiccCardInfo[] getUiccCardsInfo(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.UiccSlotInfo[] getUiccSlotsInfo(); method @Nullable public android.os.Bundle getVisualVoicemailSettings(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getVoiceActivationState(); @@ -6358,7 +6355,6 @@ package android.telephony { field public static final String EXTRA_SIM_STATE = "android.telephony.extra.SIM_STATE"; field public static final String EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL = "android.telephony.extra.VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL"; field public static final String EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING = "android.telephony.extra.VOICEMAIL_SCRAMBLED_PIN_STRING"; - field public static final int INVALID_CARD_ID = -1; // 0xffffffff field public static final long MAX_NUMBER_VERIFICATION_TIMEOUT_MILLIS = 60000L; // 0xea60L field public static final int NETWORK_MODE_CDMA_EVDO = 4; // 0x4 field public static final int NETWORK_MODE_CDMA_NO_EVDO = 5; // 0x5 @@ -6433,18 +6429,6 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.UiccAccessRule> CREATOR; } - public class UiccCardInfo implements android.os.Parcelable { - ctor public UiccCardInfo(boolean, int, String, String, int); - method public int describeContents(); - method public int getCardId(); - method public String getEid(); - method public String getIccId(); - method public int getSlotIndex(); - method public boolean isEuicc(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.UiccCardInfo> CREATOR; - } - public class UiccSlotInfo implements android.os.Parcelable { ctor public UiccSlotInfo(boolean, boolean, String, int, int, boolean); method public int describeContents(); diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 30536099456a..5fd148e5d5af 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -23,9 +23,11 @@ option java_outer_classname = "AtomsProto"; import "frameworks/base/cmds/statsd/src/atom_field_options.proto"; import "frameworks/base/core/proto/android/app/enums.proto"; import "frameworks/base/core/proto/android/app/job/enums.proto"; +import "frameworks/base/core/proto/android/bluetooth/a2dp/enums.proto"; import "frameworks/base/core/proto/android/bluetooth/enums.proto"; import "frameworks/base/core/proto/android/bluetooth/hci/enums.proto"; import "frameworks/base/core/proto/android/bluetooth/hfp/enums.proto"; +import "frameworks/base/core/proto/android/bluetooth/smp/enums.proto"; import "frameworks/base/core/proto/android/net/networkcapabilities.proto"; import "frameworks/base/core/proto/android/os/enums.proto"; import "frameworks/base/core/proto/android/server/connectivity/data_stall_event.proto"; @@ -142,6 +144,23 @@ message Atom { NfcHceTransactionOccurred nfc_hce_transaction_occurred = 139; SeStateChanged se_state_changed = 140; SeOmapiReported se_omapi_reported = 141; + BluetoothActiveDeviceChanged bluetooth_active_device_changed = 151; + BluetoothA2dpPlaybackStateChanged bluetooth_a2dp_playback_state_changed = 152; + BluetoothA2dpCodecConfigChanged bluetooth_a2dp_codec_config_changed = 153; + BluetoothA2dpCodecCapabilityChanged bluetooth_a2dp_codec_capability_changed = 154; + BluetoothA2dpAudioUnderrunReported bluetooth_a2dp_audio_underrun_reported = 155; + BluetoothA2dpAudioOverrunReported bluetooth_a2dp_audio_overrun_reported = 156; + BluetoothDeviceRssiReported bluetooth_device_rssi_reported = 157; + BluetoothDeviceFailedContactCounterReported bluetooth_device_failed_contact_counter_reported = 158; + BluetoothDeviceTxPowerLevelReported bluetooth_device_tx_power_level_reported = 159; + BluetoothHciTimeoutReported bluetooth_hci_timeout_reported = 160; + BluetoothQualityReportReported bluetooth_quality_report_reported = 161; + BluetoothManufacturerInfoReported bluetooth_device_info_reported = 162; + BluetoothRemoteVersionInfoReported bluetooth_remote_version_info_reported = 163; + BluetoothSdpAttributeReported bluetooth_sdp_attribute_reported = 164; + BluetoothBondStateChanged bluetooth_bond_state_changed = 165; + BluetoothClassicPairingEventReported bluetooth_classic_pairing_event_reported = 166; + BluetoothSmpPairingEventReported bluetooth_smp_pairing_event_reported = 167; } // Pulled events will start at field 10000. @@ -1084,6 +1103,27 @@ message BluetoothScoConnectionStateChanged { optional android.bluetooth.hfp.ScoCodec codec = 3; } +/** + * Logged when active device of a profile changes + * + * Logged from: + * packages/apps/Bluetooth/src/com/android/bluetooth/a2dp/A2dpService.java + * packages/apps/Bluetooth/src/com/android/bluetooth/hfp/HeadsetService.java + * packages/apps/Bluetooth/src/com/android/bluetooth/hearingaid/HearingAidService.java + */ +message BluetoothActiveDeviceChanged { + // The profile whose active device has changed. Eg. A2DP, HEADSET, HEARING_AID + // From android.bluetooth.BluetoothProfile + optional int32 bt_profile = 1; + // An identifier that can be used to match events for this new active device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if there is no active device for this profile + optional bytes obfuscated_id = 2 [(android.os.statsd.log_mode) = MODE_BYTES]; +} + // Logs when there is an event affecting Bluetooth device's link layer connection. // - This event is triggered when there is a related HCI command or event // - Users of this metrics can deduce Bluetooth device's connection state from these events @@ -1167,6 +1207,516 @@ message BluetoothLinkLayerConnectionEvent { optional android.bluetooth.hci.StatusEnum reason_code = 9; } +/** + * Logs when there is a change in Bluetooth A2DP playback state + * + * Logged from: + * packages/apps/Bluetooth/src/com/android/bluetooth/a2dp/A2dpService.java + */ +message BluetoothA2dpPlaybackStateChanged { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Current playback state + // Default: PLAYBACK_STATE_UNKNOWN + optional android.bluetooth.a2dp.PlaybackStateEnum playback_state = 2; + // Current audio coding mode + // Default: AUDIO_CODING_MODE_UNKNOWN + optional android.bluetooth.a2dp.AudioCodingModeEnum audio_coding_mode = 3; +} + +/** + * Logs when there is a change in A2DP codec config for a particular remote device + * + * Logged from: + * frameworks/base/core/java/android/bluetooth/BluetoothCodecConfig.java + * packages/apps/Bluetooth/src/com/android/bluetooth/a2dp/A2dpService.java + */ +message BluetoothA2dpCodecConfigChanged { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Type of codec as defined by various SOURCE_CODEC_TYPE_* constants in BluetoothCodecConfig + // Default SOURCE_CODEC_TYPE_INVALID + optional int32 codec_type = 2; + // Codec priroity, the higher the more preferred, -1 for disabled + // Default: CODEC_PRIORITY_DEFAULT + optional int32 codec_priority = 3; + // Sample rate in Hz as defined by various SAMPLE_RATE_* constants in BluetoothCodecConfig + // Default: SAMPLE_RATE_NONE + optional int32 sample_rate = 4; + // Bits per sample as defined by various BITS_PER_SAMPLE_* constants in BluetoothCodecConfig + // Default: BITS_PER_SAMPLE_NONE + optional int32 bits_per_sample = 5; + // Channel mode as defined by various CHANNEL_MODE_* constants in BluetoothCodecConfig + // Default: CHANNEL_MODE_NONE + optional int32 channel_mode = 6; + // Codec specific values + // Default 0 + optional int64 codec_specific_1 = 7; + optional int64 codec_specific_2 = 8; + optional int64 codec_specific_3 = 9; + optional int64 codec_specific_4 = 10; +} + +/** + * Logs when there is a change in selectable A2DP codec capability for a paricular remote device + * Each codec's capability is logged separately due to statsd restriction + * + * Logged from: + * frameworks/base/core/java/android/bluetooth/BluetoothCodecConfig.java + * packages/apps/Bluetooth/src/com/android/bluetooth/a2dp/A2dpService.java + */ +message BluetoothA2dpCodecCapabilityChanged { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Type of codec as defined by various SOURCE_CODEC_TYPE_* constants in BluetoothCodecConfig + // Default SOURCE_CODEC_TYPE_INVALID + optional int32 codec_type = 2; + // Codec priroity, the higher the more preferred, -1 for disabled + // Default: CODEC_PRIORITY_DEFAULT + optional int32 codec_priority = 3; + // A bit field of supported sample rates as defined by various SAMPLE_RATE_* constants + // in BluetoothCodecConfig + // Default: empty and SAMPLE_RATE_NONE for individual item + optional int32 sample_rate = 4; + // A bit field of supported bits per sample as defined by various BITS_PER_SAMPLE_* constants + // in BluetoothCodecConfig + // Default: empty and BITS_PER_SAMPLE_NONE for individual item + optional int32 bits_per_sample = 5; + // A bit field of supported channel mode as defined by various CHANNEL_MODE_* constants in + // BluetoothCodecConfig + // Default: empty and CHANNEL_MODE_NONE for individual item + optional int32 channel_mode = 6; + // Codec specific values + // Default 0 + optional int64 codec_specific_1 = 7; + optional int64 codec_specific_2 = 8; + optional int64 codec_specific_3 = 9; + optional int64 codec_specific_4 = 10; +} + +/** + * Logs when A2DP failed to read from PCM source. + * This typically happens when audio HAL cannot supply A2DP with data fast enough for encoding. + * + * Logged from: + * system/bt + */ +message BluetoothA2dpAudioUnderrunReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Encoding interval in nanoseconds + // Default: 0 + optional int64 encoding_interval_nanos = 2; + // Number of bytes of PCM data that could not be read from the source + // Default: 0 + optional int32 num_missing_pcm_bytes = 3; +} + +/** + * Logs when A2DP failed send encoded data to the remote device fast enough such that the transmit + * buffer queue is full and we have to drop data + * + * Logged from: + * system/bt + */ +message BluetoothA2dpAudioOverrunReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Encoding interval in nanoseconds + // Default: 0 + optional int64 encoding_interval_nanos = 2; + // Number of buffers dropped in this event + // Each buffer is encoded in one encoding interval and consists of multiple encoded frames + // Default: 0 + optional int32 num_dropped_buffers = 3; + // Number of encoded buffers dropped in this event + // Default 0 + optional int32 num_dropped_encoded_frames = 4; + // Number of encoded bytes dropped in this event + // Default: 0 + optional int32 num_dropped_encoded_bytes = 5; +} + +/** + * Logs when we receive reports regarding a device's RSSI value + * + * Logged from: + * system/bt + */ +message BluetoothDeviceRssiReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Connection handle of this connection if available + // Range: 0x0000 - 0x0EFF (12 bits) + // Default: 0xFFFF if the handle is unknown + optional int32 connection_handle = 2; + // HCI command status code if this is triggerred by hci_cmd + // Default: STATUS_UNKNOWN + optional android.bluetooth.hci.StatusEnum hci_status = 3; + // BR/EDR + // Range: -128 ≤ N ≤ 127 (signed integer) + // Units: dB + // LE: + // Range: -127 to 20, 127 (signed integer) + // Units: dBm + // Invalid when an out of range value is reported + optional int32 rssi = 4; +} + +/** + * Logs when we receive reports regarding how many consecutive failed contacts for a connection + * + * Logged from: + * system/bt + */ +message BluetoothDeviceFailedContactCounterReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Connection handle of this connection if available + // Range: 0x0000 - 0x0EFF (12 bits) + // Default: 0xFFFF if the handle is unknown + optional int32 connection_handle = 2; + // HCI command status code if this is triggerred by hci_cmd + // Default: STATUS_UNKNOWN + optional android.bluetooth.hci.StatusEnum cmd_status = 3; + // Number of consecutive failed contacts for a connection corresponding to the Handle + // Range: uint16_t, 0-0xFFFF + // Default: 0xFFFFF + optional int32 failed_contact_counter = 4; +} + +/** + * Logs when we receive reports regarding the tranmit power level used for a specific connection + * + * Logged from: + * system/bt + */ +message BluetoothDeviceTxPowerLevelReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Connection handle of this connection if available + // Range: 0x0000 - 0x0EFF (12 bits) + // Default: 0xFFFF if the handle is unknown + optional int32 connection_handle = 2; + // HCI command status code if this is triggered by hci_cmd + // Default: STATUS_UNKNOWN + optional android.bluetooth.hci.StatusEnum hci_status = 3; + // Range: -30 ≤ N ≤ 20 + // Units: dBm + // Invalid when an out of range value is reported + optional int32 transmit_power_level = 4; +} + +/** + * Logs when Bluetooth controller failed to reply with command status within a timeout period after + * receiving an HCI command from the host + * + * Logged from: system/bt + */ +message BluetoothHciTimeoutReported { + // HCI command associated with this event + // Default: CMD_UNKNOWN + optional android.bluetooth.hci.CommandEnum hci_command = 1; +} + +/** + * Logs when we receive Bluetooth Link Quality Report event from the controller + * See Android Bluetooth HCI specification for more details + * + * Note: all count and bytes field are counted since last event + * + * Logged from: system/bt + */ +message BluetoothQualityReportReported { + // Quality report ID + // Original type: uint8_t + // Default: BQR_ID_UNKNOWN + optional android.bluetooth.hci.BqrIdEnum quality_report_id = 1; + // Packet type of the connection + // Original type: uint8_t + // Default: BQR_PACKET_TYPE_UNKNOWN + optional android.bluetooth.hci.BqrPacketTypeEnum packet_types = 2; + // Connection handle of the connection + // Original type: uint16_t + optional int32 connection_handle = 3; + // Performing Role for the connection + // Original type: uint8_t + optional int32 connection_role = 4; + // Current Transmit Power Level for the connection. This value is the same as the controller's + // response to the HCI_Read_Transmit_Power_Level HCI command + // Original type: uint8_t + optional int32 tx_power_level = 5; + // Received Signal Strength Indication (RSSI) value for the connection. This value is an + // absolute receiver signal strength value + // Original type: int8_t + optional int32 rssi = 6; + // Signal-to-Noise Ratio (SNR) value for the connection. It is the average SNR of all the + // channels used by the link currently + // Original type: uint8_t + optional int32 snr = 7; + // Indicates the number of unused channels in AFH_channel_map + // Original type: uint8_t + optional int32 unused_afh_channel_count = 8; + // Indicates the number of the channels which are interfered and quality is bad but are still + // selected for AFH + // Original type: uint8_t + optional int32 afh_select_unideal_channel_count = 9; + // Current Link Supervision Timeout Setting + // Unit: N * 0.3125 ms (1 Bluetooth Clock) + // Original type: uint16_t + optional int32 lsto = 10; + // Piconet Clock for the specified Connection_Handle. This value is the same as the controller's + // response to HCI_Read_Clock HCI command with the parameter "Which_Clock" of + // 0x01 (Piconet Clock) + // Unit: N * 0.3125 ms (1 Bluetooth Clock) + // Original type: uint32_t + optional int64 connection_piconet_clock = 11; + // The count of retransmission + // Original type: uint32_t + optional int64 retransmission_count = 12; + // The count of no RX + // Original type: uint32_t + optional int64 no_rx_count = 13; + // The count of NAK (Negative Acknowledge) + // Original type: uint32_t + optional int64 nak_count = 14; + // Controller timestamp of last TX ACK + // Unit: N * 0.3125 ms (1 Bluetooth Clock) + // Original type: uint32_t + optional int64 last_tx_ack_timestamp = 15; + // The count of Flow-off (STOP) + // Original type: uint32_t + optional int64 flow_off_count = 16; + // Controller timestamp of last Flow-on (GO) + // Unit: N * 0.3125 ms (1 Bluetooth Clock) + // Original type: uint32_t + optional int64 last_flow_on_timestamp = 17; + // Buffer overflow count (how many bytes of TX data are dropped) since the last event + // Original type: uint32_t + optional int64 buffer_overflow_bytes = 18; + // Buffer underflow count (in byte) since last event + // Original type: uint32_t + optional int64 buffer_underflow_bytes = 19; +} + +/** + * Logs when a Bluetooth device's manufacturer information is learnt by the Bluetooth stack + * + * Notes: + * - Each event can be partially filled as we might learn different pieces of device + * information at different time + * - Multiple device info events can be combined to give more complete picture + * - When multiple device info events tries to describe the same information, the + * later one wins + * + * Logged from: + * packages/apps/Bluetooth + */ +message BluetoothManufacturerInfoReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Where is this device info obtained from + optional android.bluetooth.DeviceInfoSrcEnum source_type = 2; + // Name of the data source + // For EXTERNAL: package name of the data source + // For INTERNAL: null for general case, component name otherwise + optional string source_name = 3; + // Name of the manufacturer of this device + optional string manufacturer = 4; + // Model of this device + optional string model = 5; + // Hardware version of this device + optional string hardware_version = 6; + // Software version of this device + optional string software_version = 7; +} + +/** + * Logs when we receive Bluetooth Read Remote Version Information Complete Event from the remote + * device, as documented by the Bluetooth Core HCI specification + * Reference: https://www.bluetooth.com/specifications/bluetooth-core-specification + * Vol 2, Part E, Page 1118 + * + * Logged from: + * system/bt + */ +message BluetoothRemoteVersionInfoReported { + // Connection handle of the connection + // Original type: uint16_t + optional int32 connection_handle = 1; + // HCI command status code + // Default: STATUS_UNKNOWN + optional android.bluetooth.hci.StatusEnum hci_status = 2; + // 1 byte Version of current LMP in the remote controller + optional int32 lmp_version = 3; + // 2 bytes LMP manufacturer code of the remote controller + // https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers + optional int32 lmp_manufacturer_code = 4; + // 4 bytes subversion of the LMP in the remote controller + optional int32 lmp_subversion = 5; +} + +/** + * Logs when certain Bluetooth SDP attributes are discovered + * Constant definitions are from: + * https://www.bluetooth.com/specifications/assigned-numbers/service-discovery + * + * Current logged attributes: + * - BluetoothProfileDescriptorList + * - Supported Features Bitmask + * + * Logged from: + * system/bt + */ +message BluetoothSdpAttributeReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Short form UUIDs used to identify Bluetooth protocols, profiles, and service classes + // Original type: uint16_t + optional int32 protocol_uuid = 2; + // Short form UUIDs used to identify Bluetooth SDP attribute types + // Original type: uint16_t + optional int32 attribute_id = 3; + // Attribute value for the particular attribute + optional bytes attribute_value = 4 [(android.os.statsd.log_mode) = MODE_BYTES]; +} + +/** + * Logs when bond state of a Bluetooth device changes + * + * Logged from: + * frameworks/base/core/java/android/bluetooth/BluetoothDevice.java + * packages/apps/Bluetooth/src/com/android/bluetooth/btservice/BondStateMachine.java + */ +message BluetoothBondStateChanged { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Preferred transport type to remote dual mode device + // Default: TRANSPORT_AUTO means no preference + optional android.bluetooth.TransportTypeEnum transport = 2; + // The type of this Bluetooth device (Classic, LE, or Dual mode) + // Default: UNKNOWN + optional android.bluetooth.DeviceTypeEnum type = 3; + // Current bond state (NONE, BONDING, BONDED) + // Default: BOND_STATE_UNKNOWN + optional android.bluetooth.BondStateEnum bond_state = 4; + // Bonding sub state + // Default: BOND_SUB_STATE_UNKNOWN + optional android.bluetooth.BondSubStateEnum bonding_sub_state = 5; + // Unbond Reason + // Default: UNBOND_REASON_UNKNOWN + optional android.bluetooth.UnbondReasonEnum unbond_reason = 6; +} + +/** + * Logs there is an event related Bluetooth classic pairing + * + * Logged from: + * system/bt + */ +message BluetoothClassicPairingEventReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // Connection handle of this connection if available + // Range: 0x0000 - 0x0EFF (12 bits) + // Default: 0xFFFF if the handle is unknown + optional int32 connection_handle = 2; + // HCI command associated with this event + // Default: CMD_UNKNOWN + optional android.bluetooth.hci.CommandEnum hci_cmd = 3; + // HCI event associated with this event + // Default: EVT_UNKNOWN + optional android.bluetooth.hci.EventEnum hci_event = 4; + // HCI command status code if this is triggerred by hci_cmd + // Default: STATUS_UNKNOWN + optional android.bluetooth.hci.StatusEnum cmd_status = 5; + // HCI reason code associated with this event + // Default: STATUS_UNKNOWN + optional android.bluetooth.hci.StatusEnum reason_code = 6; +} + +/** + * Logs when there is an event related to Bluetooth Security Manager Protocol (SMP) + * + * Logged from: + * system/bt + */ +message BluetoothSmpPairingEventReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + optional bytes obfuscated_id = 1 [(android.os.statsd.log_mode) = MODE_BYTES]; + // SMP command sent or received over L2CAP + // Default: CMD_UNKNOWN + optional android.bluetooth.smp.CommandEnum smp_command = 2; + // Whether this command is sent or received + // Default: DIRECTION_UNKNOWN + optional android.bluetooth.DirectionEnum direction = 3; + // SMP failure reason code + // Default: PAIRING_FAIL_REASON_DEFAULT + optional android.bluetooth.smp.PairingFailReasonEnum smp_fail_reason = 4; +} /** * Logs when something is plugged into or removed from the USB-C connector. diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 1b08ecd32fca..18a006ffff31 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -4464,11 +4464,16 @@ public class DevicePolicyManager { } /** + * Service-specific error code used in implementation of {@code setAlwaysOnVpnPackage} methods. + * @hide + */ + public static final int ERROR_VPN_PACKAGE_NOT_FOUND = 1; + + /** * Called by a device or profile owner to configure an always-on VPN connection through a * specific application for the current user. This connection is automatically granted and * persisted after a reboot. - * <p> - * To support the always-on feature, an app must + * <p> To support the always-on feature, an app must * <ul> * <li>declare a {@link android.net.VpnService} in its manifest, guarded by * {@link android.Manifest.permission#BIND_VPN_SERVICE};</li> @@ -4477,25 +4482,61 @@ public class DevicePolicyManager { * {@link android.net.VpnService#SERVICE_META_DATA_SUPPORTS_ALWAYS_ON}.</li> * </ul> * The call will fail if called with the package name of an unsupported VPN app. + * <p> Enabling lockdown via {@code lockdownEnabled} argument carries the risk that any failure + * of the VPN provider could break networking for all apps. * * @param vpnPackage The package name for an installed VPN app on the device, or {@code null} to * remove an existing always-on VPN configuration. * @param lockdownEnabled {@code true} to disallow networking when the VPN is not connected or - * {@code false} otherwise. This carries the risk that any failure of the VPN provider - * could break networking for all apps. This has no effect when clearing. + * {@code false} otherwise. This has no effect when clearing. * @throws SecurityException if {@code admin} is not a device or a profile owner. * @throws NameNotFoundException if {@code vpnPackage} is not installed. * @throws UnsupportedOperationException if {@code vpnPackage} exists but does not support being * set as always-on, or if always-on VPN is not available. + * @see #setAlwaysOnVpnPackage(ComponentName, String, boolean, List) */ public void setAlwaysOnVpnPackage(@NonNull ComponentName admin, @Nullable String vpnPackage, - boolean lockdownEnabled) - throws NameNotFoundException, UnsupportedOperationException { + boolean lockdownEnabled) throws NameNotFoundException { + setAlwaysOnVpnPackage(admin, vpnPackage, lockdownEnabled, Collections.emptyList()); + } + + /** + * A version of {@link #setAlwaysOnVpnPackage(ComponentName, String, boolean)} that allows the + * admin to specify a set of apps that should be able to access the network directly when VPN + * is not connected. When VPN connects these apps switch over to VPN if allowed to use that VPN. + * System apps can always bypass VPN. + * <p> Note that the system doesn't update the whitelist when packages are installed or + * uninstalled, the admin app must call this method to keep the list up to date. + * + * @param vpnPackage package name for an installed VPN app on the device, or {@code null} + * to remove an existing always-on VPN configuration + * @param lockdownEnabled {@code true} to disallow networking when the VPN is not connected or + * {@code false} otherwise. This has no effect when clearing. + * @param lockdownWhitelist Packages that will be able to access the network directly when VPN + * is in lockdown mode but not connected. Has no effect when clearing. + * @throws SecurityException if {@code admin} is not a device or a profile + * owner. + * @throws NameNotFoundException if {@code vpnPackage} or one of + * {@code lockdownWhitelist} is not installed. + * @throws UnsupportedOperationException if {@code vpnPackage} exists but does + * not support being set as always-on, or if always-on VPN is not + * available. + */ + public void setAlwaysOnVpnPackage(@NonNull ComponentName admin, @Nullable String vpnPackage, + boolean lockdownEnabled, @Nullable List<String> lockdownWhitelist) + throws NameNotFoundException { throwIfParentInstance("setAlwaysOnVpnPackage"); if (mService != null) { try { - if (!mService.setAlwaysOnVpnPackage(admin, vpnPackage, lockdownEnabled)) { - throw new NameNotFoundException(vpnPackage); + mService.setAlwaysOnVpnPackage( + admin, vpnPackage, lockdownEnabled, lockdownWhitelist); + } catch (ServiceSpecificException e) { + switch (e.errorCode) { + case ERROR_VPN_PACKAGE_NOT_FOUND: + throw new NameNotFoundException(e.getMessage()); + default: + throw new RuntimeException( + "Unknown error setting always-on VPN: " + e.errorCode, e); } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); @@ -4504,6 +4545,51 @@ public class DevicePolicyManager { } /** + * Called by device or profile owner to query whether current always-on VPN is configured in + * lockdown mode. Returns {@code false} when no always-on configuration is set. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * + * @throws SecurityException if {@code admin} is not a device or a profile owner. + * + * @see #setAlwaysOnVpnPackage(ComponentName, String, boolean) + */ + public boolean isAlwaysOnVpnLockdownEnabled(@NonNull ComponentName admin) { + throwIfParentInstance("isAlwaysOnVpnLockdownEnabled"); + if (mService != null) { + try { + return mService.isAlwaysOnVpnLockdownEnabled(admin); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + return false; + } + + /** + * Called by device or profile owner to query the list of packages that are allowed to access + * the network directly when always-on VPN is in lockdown mode but not connected. Returns + * {@code null} when always-on VPN is not active or not in lockdown mode. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * + * @throws SecurityException if {@code admin} is not a device or a profile owner. + * + * @see #setAlwaysOnVpnPackage(ComponentName, String, boolean, List) + */ + public @Nullable List<String> getAlwaysOnVpnLockdownWhitelist(@NonNull ComponentName admin) { + throwIfParentInstance("getAlwaysOnVpnLockdownWhitelist"); + if (mService != null) { + try { + return mService.getAlwaysOnVpnLockdownWhitelist(admin); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + return null; + } + + /** * Called by a device or profile owner to read the name of the package administering an * always-on VPN connection for the current user. If there is no such package, or the always-on * VPN is provided by the system instead of by an application, {@code null} will be returned. diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 37508cdc1119..00463028a685 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -182,8 +182,10 @@ interface IDevicePolicyManager { void setCertInstallerPackage(in ComponentName who, String installerPackage); String getCertInstallerPackage(in ComponentName who); - boolean setAlwaysOnVpnPackage(in ComponentName who, String vpnPackage, boolean lockdown); + boolean setAlwaysOnVpnPackage(in ComponentName who, String vpnPackage, boolean lockdown, in List<String> lockdownWhitelist); String getAlwaysOnVpnPackage(in ComponentName who); + boolean isAlwaysOnVpnLockdownEnabled(in ComponentName who); + List<String> getAlwaysOnVpnLockdownWhitelist(in ComponentName who); void addPersistentPreferredActivity(in ComponentName admin, in IntentFilter filter, in ComponentName activity); void clearPackagePersistentPreferredActivities(in ComponentName admin, String packageName); diff --git a/core/proto/Android.bp b/core/proto/Android.bp index 80cc2d4cab94..3b891d6b4947 100644 --- a/core/proto/Android.bp +++ b/core/proto/Android.bp @@ -21,7 +21,10 @@ cc_library_static { type: "lite", }, srcs: [ + "android/bluetooth/a2dp/enums.proto", "android/bluetooth/enums.proto", "android/bluetooth/hci/enums.proto", + "android/bluetooth/hfp/enums.proto", + "android/bluetooth/smp/enums.proto", ], } diff --git a/core/proto/android/bluetooth/a2dp/enums.proto b/core/proto/android/bluetooth/a2dp/enums.proto new file mode 100644 index 000000000000..5a025bdd6c10 --- /dev/null +++ b/core/proto/android/bluetooth/a2dp/enums.proto @@ -0,0 +1,35 @@ +/* + * 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. + */ + +syntax = "proto2"; +package android.bluetooth.a2dp; + +option java_outer_classname = "BluetoothA2dpProtoEnums"; +option java_multiple_files = true; + +// A2dp playback state enum, defined from: +// frameworks/base/core/java/android/bluetooth/BluetoothA2dp.java +enum PlaybackStateEnum { + PLAYBACK_STATE_UNKNOWN = 0; + PLAYBACK_STATE_PLAYING = 10; + PLAYBACK_STATE_NOT_PLAYING = 11; +} + +enum AudioCodingModeEnum { + AUDIO_CODING_MODE_UNKNOWN = 0; + AUDIO_CODING_MODE_HARDWARE = 1; + AUDIO_CODING_MODE_SOFTWARE = 2; +} diff --git a/core/proto/android/bluetooth/enums.proto b/core/proto/android/bluetooth/enums.proto index 76c240ecff4d..a88a06cf091c 100644 --- a/core/proto/android/bluetooth/enums.proto +++ b/core/proto/android/bluetooth/enums.proto @@ -56,3 +56,57 @@ enum LinkTypeEnum { LINK_TYPE_ACL = 0x01; LINK_TYPE_ESCO = 0x02; } + +enum DeviceInfoSrcEnum { + DEVICE_INFO_SRC_UNKNOWN = 0; + // Within Android Bluetooth stack + DEVICE_INFO_INTERNAL = 1; + // Outside Android Bluetooth stack + DEVICE_INFO_EXTERNAL = 2; +} + +enum DeviceTypeEnum { + DEVICE_TYPE_UNKNOWN = 0; + DEVICE_TYPE_CLASSIC = 1; + DEVICE_TYPE_LE = 2; + DEVICE_TYPE_DUAL = 3; +} + +// Defined in frameworks/base/core/java/android/bluetooth/BluetoothDevice.java +enum TransportTypeEnum { + TRANSPORT_TYPE_AUTO = 0; + TRANSPORT_TYPE_BREDR = 1; + TRANSPORT_TYPE_LE = 2; +} + +// Bond state enum +// Defined in frameworks/base/core/java/android/bluetooth/BluetoothDevice.java +enum BondStateEnum { + BOND_STATE_UNKNOWN = 0; + BOND_STATE_NONE = 10; + BOND_STATE_BONDING = 11; + BOND_STATE_BONDED = 12; +} + +// Sub states within the bonding general state +enum BondSubStateEnum { + BOND_SUB_STATE_UNKNOWN = 0; + BOND_SUB_STATE_LOCAL_OOB_DATA_PROVIDED = 1; + BOND_SUB_STATE_LOCAL_PIN_REQUESTED = 2; + BOND_SUB_STATE_LOCAL_PIN_REPLIED = 3; + BOND_SUB_STATE_LOCAL_SSP_REQUESTED = 4; + BOND_SUB_STATE_LOCAL_SSP_REPLIED = 5; +} + +enum UnbondReasonEnum { + UNBOND_REASON_UNKNOWN = 0; + UNBOND_REASON_AUTH_FAILED = 1; + UNBOND_REASON_AUTH_REJECTED = 2; + UNBOND_REASON_AUTH_CANCELED = 3; + UNBOND_REASON_REMOTE_DEVICE_DOWN = 4; + UNBOND_REASON_DISCOVERY_IN_PROGRESS = 5; + UNBOND_REASON_AUTH_TIMEOUT = 6; + UNBOND_REASON_REPEATED_ATTEMPTS = 7; + UNBOND_REASON_REMOTE_AUTH_CANCELED = 8; + UNBOND_REASON_REMOVED = 9; +} diff --git a/core/proto/android/bluetooth/hci/enums.proto b/core/proto/android/bluetooth/hci/enums.proto index e1d96bbce68a..ef894e548351 100644 --- a/core/proto/android/bluetooth/hci/enums.proto +++ b/core/proto/android/bluetooth/hci/enums.proto @@ -351,7 +351,7 @@ enum EventEnum { EVT_COMMAND_COMPLETE = 0x0E; EVT_COMMAND_STATUS = 0x0F; EVT_HARDWARE_ERROR = 0x10; - EVT_FLUSH_OCCURED = 0x11; + EVT_FLUSH_OCCURRED = 0x11; EVT_ROLE_CHANGE = 0x12; EVT_NUM_COMPL_DATA_PKTS = 0x13; EVT_MODE_CHANGE = 0x14; @@ -517,3 +517,43 @@ enum StatusEnum { STATUS_CLB_DATA_TOO_BIG = 0x43; STATUS_OPERATION_CANCELED_BY_HOST = 0x44; // Not currently used in system/bt } + +enum BqrIdEnum { + BQR_ID_UNKNOWN = 0x00; + BQR_ID_MONITOR_MODE = 0x01; + BQR_ID_APPROACH_LSTO = 0x02; + BQR_ID_A2DP_AUDIO_CHOPPY = 0x03; + BQR_ID_SCO_VOICE_CHOPPY = 0x04; +} + +enum BqrPacketTypeEnum { + BQR_PACKET_TYPE_UNKNOWN = 0x00; + BQR_PACKET_TYPE_ID = 0x01; + BQR_PACKET_TYPE_NULL = 0x02; + BQR_PACKET_TYPE_POLL = 0x03; + BQR_PACKET_TYPE_FHS = 0x04; + BQR_PACKET_TYPE_HV1 = 0x05; + BQR_PACKET_TYPE_HV2 = 0x06; + BQR_PACKET_TYPE_HV3 = 0x07; + BQR_PACKET_TYPE_DV = 0x08; + BQR_PACKET_TYPE_EV3 = 0x09; + BQR_PACKET_TYPE_EV4 = 0x0A; + BQR_PACKET_TYPE_EV5 = 0x0B; + BQR_PACKET_TYPE_2EV3 = 0x0C; + BQR_PACKET_TYPE_2EV5 = 0x0D; + BQR_PACKET_TYPE_3EV3 = 0x0E; + BQR_PACKET_TYPE_3EV5 = 0x0F; + BQR_PACKET_TYPE_DM1 = 0x10; + BQR_PACKET_TYPE_DH1 = 0x11; + BQR_PACKET_TYPE_DM3 = 0x12; + BQR_PACKET_TYPE_DH3 = 0x13; + BQR_PACKET_TYPE_DM5 = 0x14; + BQR_PACKET_TYPE_DH5 = 0x15; + BQR_PACKET_TYPE_AUX1 = 0x16; + BQR_PACKET_TYPE_2DH1 = 0x17; + BQR_PACKET_TYPE_2DH3 = 0x18; + BQR_PACKET_TYPE_2DH5 = 0x19; + BQR_PACKET_TYPE_3DH1 = 0x1A; + BQR_PACKET_TYPE_3DH3 = 0x1B; + BQR_PACKET_TYPE_3DH5 = 0x1C; +} diff --git a/core/proto/android/bluetooth/smp/enums.proto b/core/proto/android/bluetooth/smp/enums.proto new file mode 100644 index 000000000000..c6747b78dc29 --- /dev/null +++ b/core/proto/android/bluetooth/smp/enums.proto @@ -0,0 +1,58 @@ +/* + * Copyright 2019 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. + */ + +syntax = "proto2"; +package android.bluetooth.smp; + +option java_outer_classname = "BluetoothSmpProtoEnums"; +option java_multiple_files = true; + +// SMP Pairing command codes +enum CommandEnum { + CMD_UNKNOWN = 0x00; + CMD_PAIRING_REQUEST = 0x01; + CMD_PAIRING_RESPONSE = 0x02; + CMD_PAIRING_CONFIRM = 0x03; + CMD_PAIRING_RANDOM = 0x04; + CMD_PAIRING_FAILED = 0x05; + CMD_ENCRYPTION_INFON = 0x06; + CMD_MASTER_IDENTIFICATION = 0x07; + CMD_IDENTITY_INFO = 0x08; + CMD_IDENTITY_ADDR_INFO = 0x09; + CMD_SIGNING_INFO = 0x0A; + CMD_SECURITY_REQUEST = 0x0B; + CMD_PAIRING_PUBLIC_KEY = 0x0C; + CMD_PAIRING_DHKEY_CHECK = 0x0D; + CMD_PAIRING_KEYPRESS_INFO = 0x0E; +} + +enum PairingFailReasonEnum { + PAIRING_FAIL_REASON_RESERVED = 0x00; + PAIRING_FAIL_REASON_PASSKEY_ENTRY = 0x01; + PAIRING_FAIL_REASON_OOB = 0x02; + PAIRING_FAIL_REASON_AUTH_REQ = 0x03; + PAIRING_FAIL_REASON_CONFIRM_VALUE = 0x04; + PAIRING_FAIL_REASON_PAIR_NOT_SUPPORT = 0x05; + PAIRING_FAIL_REASON_ENC_KEY_SIZE = 0x06; + PAIRING_FAIL_REASON_INVALID_CMD = 0x07; + PAIRING_FAIL_REASON_UNSPECIFIED = 0x08; + PAIRING_FAIL_REASON_REPEATED_ATTEMPTS = 0x09; + PAIRING_FAIL_REASON_INVALID_PARAMETERS = 0x0A; + PAIRING_FAIL_REASON_DHKEY_CHK = 0x0B; + PAIRING_FAIL_REASON_NUMERIC_COMPARISON = 0x0C; + PAIRING_FAIL_REASON_CLASSIC_PAIRING_IN_PROGR = 0x0D; + PAIRING_FAIL_REASON_XTRANS_DERIVE_NOT_ALLOW = 0x0E; +}
\ No newline at end of file diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 8f5d36abcf2c..31e1e358ee6d 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -1852,7 +1852,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } AlarmManager getAlarmManager() { - return (AlarmManager) mContext.getSystemService(AlarmManager.class); + return mContext.getSystemService(AlarmManager.class); + } + + ConnectivityManager getConnectivityManager() { + return mContext.getSystemService(ConnectivityManager.class); } IWindowManager getIWindowManager() { @@ -5881,7 +5885,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { * @throws UnsupportedOperationException if the package does not support being set as always-on. */ @Override - public boolean setAlwaysOnVpnPackage(ComponentName admin, String vpnPackage, boolean lockdown) + public boolean setAlwaysOnVpnPackage(ComponentName admin, String vpnPackage, boolean lockdown, + List<String> lockdownWhitelist) throws SecurityException { enforceProfileOrDeviceOwner(admin); @@ -5889,11 +5894,23 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final long token = mInjector.binderClearCallingIdentity(); try { if (vpnPackage != null && !isPackageInstalledForUser(vpnPackage, userId)) { - return false; + Slog.w(LOG_TAG, "Non-existent VPN package specified: " + vpnPackage); + throw new ServiceSpecificException( + DevicePolicyManager.ERROR_VPN_PACKAGE_NOT_FOUND, vpnPackage); + } + + if (vpnPackage != null && lockdown && lockdownWhitelist != null) { + for (String packageName : lockdownWhitelist) { + if (!isPackageInstalledForUser(packageName, userId)) { + Slog.w(LOG_TAG, "Non-existent package in VPN whitelist: " + packageName); + throw new ServiceSpecificException( + DevicePolicyManager.ERROR_VPN_PACKAGE_NOT_FOUND, packageName); + } + } } - ConnectivityManager connectivityManager = (ConnectivityManager) - mContext.getSystemService(Context.CONNECTIVITY_SERVICE); - if (!connectivityManager.setAlwaysOnVpnPackageForUser(userId, vpnPackage, lockdown)) { + // If some package is uninstalled after the check above, it will be ignored by CM. + if (!mInjector.getConnectivityManager().setAlwaysOnVpnPackageForUser( + userId, vpnPackage, lockdown, lockdownWhitelist)) { throw new UnsupportedOperationException(); } } finally { @@ -5903,16 +5920,40 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } @Override - public String getAlwaysOnVpnPackage(ComponentName admin) + public String getAlwaysOnVpnPackage(ComponentName admin) throws SecurityException { + enforceProfileOrDeviceOwner(admin); + + final int userId = mInjector.userHandleGetCallingUserId(); + final long token = mInjector.binderClearCallingIdentity(); + try { + return mInjector.getConnectivityManager().getAlwaysOnVpnPackageForUser(userId); + } finally { + mInjector.binderRestoreCallingIdentity(token); + } + } + + @Override + public boolean isAlwaysOnVpnLockdownEnabled(ComponentName admin) throws SecurityException { + enforceProfileOrDeviceOwner(admin); + + final int userId = mInjector.userHandleGetCallingUserId(); + final long token = mInjector.binderClearCallingIdentity(); + try { + return mInjector.getConnectivityManager().isVpnLockdownEnabled(userId); + } finally { + mInjector.binderRestoreCallingIdentity(token); + } + } + + @Override + public List<String> getAlwaysOnVpnLockdownWhitelist(ComponentName admin) throws SecurityException { enforceProfileOrDeviceOwner(admin); final int userId = mInjector.userHandleGetCallingUserId(); final long token = mInjector.binderClearCallingIdentity(); - try{ - ConnectivityManager connectivityManager = (ConnectivityManager) - mContext.getSystemService(Context.CONNECTIVITY_SERVICE); - return connectivityManager.getAlwaysOnVpnPackageForUser(userId); + try { + return mInjector.getConnectivityManager().getVpnLockdownWhitelist(userId); } finally { mInjector.binderRestoreCallingIdentity(token); } @@ -6382,9 +6423,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } long token = mInjector.binderClearCallingIdentity(); try { - ConnectivityManager connectivityManager = (ConnectivityManager) - mContext.getSystemService(Context.CONNECTIVITY_SERVICE); - connectivityManager.setGlobalProxy(proxyInfo); + mInjector.getConnectivityManager().setGlobalProxy(proxyInfo); } finally { mInjector.binderRestoreCallingIdentity(token); } diff --git a/telecomm/java/android/telecom/VideoProfile.java b/telecomm/java/android/telecom/VideoProfile.java index 7b2306128b7b..157f12c9f105 100644 --- a/telecomm/java/android/telecom/VideoProfile.java +++ b/telecomm/java/android/telecom/VideoProfile.java @@ -16,7 +16,9 @@ package android.telecom; +import android.annotation.FloatRange; import android.annotation.IntDef; +import android.annotation.IntRange; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; @@ -364,7 +366,7 @@ public class VideoProfile implements Parcelable { * @param width The width of the camera video (in pixels). * @param height The height of the camera video (in pixels). */ - public CameraCapabilities(int width, int height) { + public CameraCapabilities(@IntRange(from = 0) int width, @IntRange(from = 0) int height) { this(width, height, false, 1.0f); } @@ -376,7 +378,8 @@ public class VideoProfile implements Parcelable { * @param zoomSupported True when camera supports zoom. * @param maxZoom Maximum zoom supported by camera. */ - public CameraCapabilities(int width, int height, boolean zoomSupported, float maxZoom) { + public CameraCapabilities(@IntRange(from = 0) int width, @IntRange(from = 0) int height, + boolean zoomSupported, @FloatRange(from = 1.0f) float maxZoom) { mWidth = width; mHeight = height; mZoomSupported = zoomSupported; diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 26cba773c9cc..190e82b6cc5b 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -2371,33 +2371,54 @@ public class CarrierConfigManager { "support_emergency_dialer_shortcut_bool"; /** - * Controls RSRP threshold at which AlternativeNetworkService will decide whether + * Controls RSRP threshold at which OpportunisticNetworkService will decide whether * the opportunistic network is good enough for internet data. */ public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSRP_INT = "opportunistic_network_entry_threshold_rsrp_int"; /** - * Controls RSSNR threshold at which AlternativeNetworkService will decide whether + * Controls RSSNR threshold at which OpportunisticNetworkService will decide whether * the opportunistic network is good enough for internet data. */ public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSSNR_INT = "opportunistic_network_entry_threshold_rssnr_int"; /** - * Controls RSRP threshold below which AlternativeNetworkService will decide whether + * Controls RSRP threshold below which OpportunisticNetworkService will decide whether * the opportunistic network available is not good enough for internet data. */ public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSRP_INT = "opportunistic_network_exit_threshold_rsrp_int"; /** - * Controls RSSNR threshold below which AlternativeNetworkService will decide whether + * Controls RSSNR threshold below which OpportunisticNetworkService will decide whether * the opportunistic network available is not good enough for internet data. */ public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT = "opportunistic_network_exit_threshold_rssnr_int"; + /** + * Controls bandwidth threshold in Kbps at which OpportunisticNetworkService will decide whether + * the opportunistic network is good enough for internet data. + */ + public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_BANDWIDTH_INT = + "opportunistic_network_entry_threshold_bandwidth_int"; + + /** + * Controls hysteresis time in milli seconds for which OpportunisticNetworkService + * will wait before attaching to a network. + */ + public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_OR_EXIT_HYSTERESIS_TIME_LONG = + "opportunistic_network_entry_or_exit_hysteresis_time_long"; + + /** + * Controls hysteresis time in milli seconds for which OpportunisticNetworkService + * will wait before switching data to a network. + */ + public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG = + "opportunistic_network_data_switch_hysteresis_time_long"; + /** The default value for every variable. */ private final static PersistableBundle sDefaults; @@ -2767,6 +2788,12 @@ public class CarrierConfigManager { sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSSNR_INT, 45); /* Default value is minimum RSSNR level needed for SIGNAL_STRENGTH_MODERATE */ sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT, 10); + /* Default value is 1024 kbps */ + sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_BANDWIDTH_INT, 1024); + /* Default value is 10 seconds */ + sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_OR_EXIT_HYSTERESIS_TIME_LONG, 10000); + /* Default value is 10 seconds. */ + sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG, 10000); } /** diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java index 4e4ef4d6c236..443f90844c50 100644 --- a/telephony/java/android/telephony/SubscriptionInfo.java +++ b/telephony/java/android/telephony/SubscriptionInfo.java @@ -577,10 +577,10 @@ public class SubscriptionInfo implements Parcelable { } /** - * @return the cardId of the SIM card which contains the subscription. - * @hide + * Returns the card ID of the SIM card which contains the subscription (see + * {@link UiccCardInfo#getCardId()}. + * @return the cardId */ - @SystemApi public int getCardId() { return this.mCardId; } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 2461aad80246..9a279d3ecfe9 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -227,10 +227,9 @@ public class TelephonyManager { public static final int SRVCC_STATE_HANDOVER_CANCELED = 3; /** - * An invalid card identifier. - * @hide + * An invalid UICC card identifier. See {@link #getCardIdForDefaultEuicc()} and + * {@link UiccCardInfo#getCardId()}. */ - @SystemApi public static final int INVALID_CARD_ID = -1; /** @hide */ @@ -3118,14 +3117,8 @@ public class TelephonyManager { * unique to a device, and always refer to the same UICC or eUICC card unless the device goes * through a factory reset. * - * <p>Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} - * * @return card ID of the default eUICC card. - * @hide */ - @SystemApi - @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges - @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getCardIdForDefaultEuicc() { try { ITelephony telephony = getITelephony(); @@ -3139,25 +3132,37 @@ public class TelephonyManager { } /** - * Gets information about currently inserted UICCs and eUICCs. See {@link UiccCardInfo} for more - * details on the kind of information available. - * - * @return UiccCardInfo an array of UiccCardInfo objects, representing information on the - * currently inserted UICCs and eUICCs. + * Gets information about currently inserted UICCs and enabled eUICCs. + * <p> + * Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * <p> + * If the caller has carrier priviliges on any active subscription, then they have permission to + * get simple information like the card ID ({@link UiccCardInfo#getCardId()}), whether the card + * is an eUICC ({@link UiccCardInfo#isEuicc()}), and the slot index where the card is inserted + * ({@link UiccCardInfo#getSlotIndex()}). + * <p> + * To get private information such as the EID ({@link UiccCardInfo#getEid()}) or ICCID + * ({@link UiccCardInfo#getIccId()}), the caller must have carrier priviliges on that specific + * UICC or eUICC card. + * <p> + * See {@link UiccCardInfo} for more details on the kind of information available. * - * @hide + * @return a list of UiccCardInfo objects, representing information on the currently inserted + * UICCs and eUICCs. Each UiccCardInfo in the list will have private information filtered out if + * the caller does not have adequate permissions for that card. */ - @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - public UiccCardInfo[] getUiccCardsInfo() { + public List<UiccCardInfo> getUiccCardsInfo() { try { ITelephony telephony = getITelephony(); if (telephony == null) { - return null; + Log.e(TAG, "Error in getUiccCardsInfo: unable to connect to Telephony service."); + return new ArrayList<UiccCardInfo>(); } - return telephony.getUiccCardsInfo(); + return telephony.getUiccCardsInfo(mContext.getOpPackageName()); } catch (RemoteException e) { - return null; + Log.e(TAG, "Error in getUiccCardsInfo: " + e); + return new ArrayList<UiccCardInfo>(); } } @@ -8949,6 +8954,9 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) { + if (carriers == null || !SubscriptionManager.isValidPhoneId(slotIndex)) { + return -1; + } // Execute the method setCarrierRestrictionRules with an empty excluded list and // indicating priority for the allowed list. CarrierRestrictionRules carrierRestrictionRules = CarrierRestrictionRules.newBuilder() @@ -8959,7 +8967,7 @@ public class TelephonyManager { int result = setCarrierRestrictionRules(carrierRestrictionRules); - // Convert boolean result into int, as required by this method. + // Convert result into int, as required by this method. if (result == SET_CARRIER_RESTRICTION_SUCCESS) { return carriers.size(); } else { @@ -9052,9 +9060,11 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) { - CarrierRestrictionRules carrierRestrictionRule = getCarrierRestrictionRules(); - if (carrierRestrictionRule != null) { - return carrierRestrictionRule.getAllowedCarriers(); + if (SubscriptionManager.isValidPhoneId(slotIndex)) { + CarrierRestrictionRules carrierRestrictionRule = getCarrierRestrictionRules(); + if (carrierRestrictionRule != null) { + return carrierRestrictionRule.getAllowedCarriers(); + } } return new ArrayList<CarrierIdentifier>(0); } diff --git a/telephony/java/android/telephony/UiccCardInfo.java b/telephony/java/android/telephony/UiccCardInfo.java index 45e4704e8894..19f357a14687 100644 --- a/telephony/java/android/telephony/UiccCardInfo.java +++ b/telephony/java/android/telephony/UiccCardInfo.java @@ -15,7 +15,6 @@ */ package android.telephony; -import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; @@ -23,10 +22,8 @@ import java.util.Objects; /** * The UiccCardInfo represents information about a currently inserted UICC or embedded eUICC. - * @hide */ -@SystemApi -public class UiccCardInfo implements Parcelable { +public final class UiccCardInfo implements Parcelable { private final boolean mIsEuicc; private final int mCardId; @@ -95,6 +92,9 @@ public class UiccCardInfo implements Parcelable { /** * Get the embedded ID (EID) of the eUICC. If the UiccCardInfo is not an eUICC * (see {@link #isEuicc()}), returns null. + * <p> + * Note that this field may be omitted if the caller does not have the correct permissions + * (see {@link TelephonyManager#getUiccCardsInfo()}). */ public String getEid() { if (!mIsEuicc) { @@ -105,6 +105,9 @@ public class UiccCardInfo implements Parcelable { /** * Get the ICCID of the UICC. + * <p> + * Note that this field may be omitted if the caller does not have the correct permissions + * (see {@link TelephonyManager#getUiccCardsInfo()}). */ public String getIccId() { return mIccId; @@ -117,6 +120,16 @@ public class UiccCardInfo implements Parcelable { return mSlotIndex; } + /** + * Returns a copy of the UiccCardinfo with the clears the EID and ICCID set to null. These + * values are generally private and require carrier privileges to view. + * + * @hide + */ + public UiccCardInfo getUnprivileged() { + return new UiccCardInfo(mIsEuicc, mCardId, null, null, mSlotIndex); + } + @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d381514a3eec..77a63bdc3649 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1484,25 +1484,34 @@ interface ITelephony { * Get the card ID of the default eUICC card. If there is no eUICC, returns * {@link #INVALID_CARD_ID}. * - * <p>Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} - * * @param subId subscription ID used for authentication * @param callingPackage package making the call * @return card ID of the default eUICC card. - * @hide - */ - int getCardIdForDefaultEuicc(int subId, String callingPackage); - - /** - * Gets information about currently inserted UICCs and eUICCs. See {@link UiccCardInfo} for more - * details on the kind of information available. - * - * @return UiccCardInfo an array of UiccCardInfo objects, representing information on the - * currently inserted UICCs and eUICCs. - * - * @hide */ - UiccCardInfo[] getUiccCardsInfo(); + int getCardIdForDefaultEuicc(int subId, String callingPackage); + + /** + * Gets information about currently inserted UICCs and enabled eUICCs. + * <p> + * Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * <p> + * If the caller has carrier priviliges on any active subscription, then they have permission to + * get simple information like the card ID ({@link UiccCardInfo#getCardId()}), whether the card + * is an eUICC ({@link UiccCardInfo#isEuicc()}), and the slot index where the card is inserted + * ({@link UiccCardInfo#getSlotIndex()}). + * <p> + * To get private information such as the EID ({@link UiccCardInfo#getEid()}) or ICCID + * ({@link UiccCardInfo#getIccId()}), the caller must have carrier priviliges on that specific + * UICC or eUICC card. + * <p> + * See {@link UiccCardInfo} for more details on the kind of information available. + * + * @param callingPackage package making the call, used to evaluate carrier privileges + * @return a list of UiccCardInfo objects, representing information on the currently inserted + * UICCs and eUICCs. Each UiccCardInfo in the list will have private information filtered out if + * the caller does not have adequate permissions for that card. + */ + List<UiccCardInfo> getUiccCardsInfo(String callingPackage); /** * Get slot info for all the UICC slots. diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py index 75c3eba7765b..59e89f515e82 100644 --- a/tools/apilint/apilint.py +++ b/tools/apilint/apilint.py @@ -223,6 +223,7 @@ class Package(): class V2Tokenizer(object): __slots__ = ["raw"] + SIGNATURE_PREFIX = "// Signature format: " DELIMITER = re.compile(r'\s+|[()@<>;,={}/"!?]|\[\]|\.\.\.') STRING_SPECIAL = re.compile(r'["\\]') @@ -610,8 +611,12 @@ def _parse_stream_to_generator(f): else: blame = None - if line == 1 and raw == "// Signature format: 2.0": - sig_format = 2 + if line == 1 and raw.startswith("// Signature format: "): + sig_format_string = raw[len(V2Tokenizer.SIGNATURE_PREFIX):] + if sig_format_string in ["2.0", "3.0"]: + sig_format = 2 + else: + raise ValueError("Unknown format: %s" % (sig_format_string,)) elif raw.startswith("package"): pkg = Package(line, raw, blame) elif raw.startswith(" ") and raw.endswith("{"): diff --git a/tools/apilint/apilint_test.py b/tools/apilint/apilint_test.py index 9c261d506dac..3716bf9f5d6f 100644 --- a/tools/apilint/apilint_test.py +++ b/tools/apilint/apilint_test.py @@ -164,6 +164,23 @@ package android { self.assertEquals(api['android.SomeEnum'].ctors[0].split[0], 'ctor') self.assertEquals(api['android.SomeEnum'].methods[0].split[0], 'method') +class ParseV3Stream(unittest.TestCase): + def test_field_kinds(self): + api = apilint._parse_stream(""" +// Signature format: 3.0 +package a { + + public final class ContextKt { + method public static inline <reified T> T! getSystemService(android.content.Context); + method public static inline void withStyledAttributes(android.content.Context, android.util.AttributeSet? set = null, int[] attrs, @AttrRes int defStyleAttr = 0, @StyleRes int defStyleRes = 0, kotlin.jvm.functions.Function1<? super android.content.res.TypedArray,kotlin.Unit> block); + } +} + """.strip().split('\n')) + self.assertEquals(api['a.ContextKt'].methods[0].name, 'getSystemService') + self.assertEquals(api['a.ContextKt'].methods[0].split[:4], ['method', 'public', 'static', 'inline']) + self.assertEquals(api['a.ContextKt'].methods[1].name, 'withStyledAttributes') + self.assertEquals(api['a.ContextKt'].methods[1].split[:4], ['method', 'public', 'static', 'inline']) + class V2TokenizerTests(unittest.TestCase): def _test(self, raw, expected): self.assertEquals(apilint.V2Tokenizer(raw).tokenize(), expected) |