Merge "Refactor BluetoothHeadset APIs used by Settings"
diff --git a/Android.bp b/Android.bp
index 100f70d..7d91b1e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -324,6 +324,7 @@
"android.hardware.radio-V1.2-java",
"android.hardware.radio-V1.3-java",
"android.hardware.radio-V1.4-java",
+ "android.hardware.radio-V1.5-java",
"android.hardware.thermal-V1.0-java-constants",
"android.hardware.thermal-V1.0-java",
"android.hardware.thermal-V1.1-java",
@@ -771,6 +772,31 @@
},
}
+filegroup {
+ name: "incremental_aidl",
+ srcs: [
+ "core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl",
+ ],
+ path: "core/java",
+}
+
+aidl_interface {
+ name: "libincremental_aidl",
+ srcs: [
+ ":incremental_aidl",
+ ],
+ backend: {
+ java: {
+ sdk_version: "28",
+ },
+ cpp: {
+ enabled: true,
+ },
+ ndk: {
+ enabled: true,
+ },
+ },
+}
gensrcs {
name: "gen-platform-proto-constants",
diff --git a/api/current.txt b/api/current.txt
index 80cc14c..4850897 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5115,12 +5115,12 @@
method public android.content.Intent getResultData();
}
- public abstract class IntentService extends android.app.Service {
- ctor public IntentService(String);
- method @Nullable public android.os.IBinder onBind(android.content.Intent);
- method @WorkerThread protected abstract void onHandleIntent(@Nullable android.content.Intent);
- method public void onStart(@Nullable android.content.Intent, int);
- method public void setIntentRedelivery(boolean);
+ @Deprecated public abstract class IntentService extends android.app.Service {
+ ctor @Deprecated public IntentService(String);
+ method @Deprecated @Nullable public android.os.IBinder onBind(android.content.Intent);
+ method @Deprecated @WorkerThread protected abstract void onHandleIntent(@Nullable android.content.Intent);
+ method @Deprecated public void onStart(@Nullable android.content.Intent, int);
+ method @Deprecated public void setIntentRedelivery(boolean);
}
public class KeyguardManager {
@@ -43113,6 +43113,7 @@
method public int getCallProperties();
method public String getCallerDisplayName();
method public int getCallerDisplayNamePresentation();
+ method public int getCallerNumberVerificationStatus();
method public final long getConnectTimeMillis();
method public long getCreationTimeMillis();
method public android.telecom.DisconnectCause getDisconnectCause();
@@ -43294,6 +43295,7 @@
method public final android.telecom.CallAudioState getCallAudioState();
method public final String getCallerDisplayName();
method public final int getCallerDisplayNamePresentation();
+ method public int getCallerNumberVerificationStatus();
method public final android.telecom.Conference getConference();
method public final java.util.List<android.telecom.Conferenceable> getConferenceables();
method public final int getConnectionCapabilities();
@@ -43345,6 +43347,7 @@
method public final void setAudioModeIsVoip(boolean);
method public final void setAudioRoute(int);
method public final void setCallerDisplayName(String, int);
+ method public void setCallerNumberVerificationStatus(int);
method public final void setConferenceableConnections(java.util.List<android.telecom.Connection>);
method public final void setConferenceables(java.util.List<android.telecom.Conferenceable>);
method public final void setConnectionCapabilities(int);
@@ -43364,6 +43367,27 @@
method public final void setVideoProvider(android.telecom.Connection.VideoProvider);
method public final void setVideoState(int);
method public static String stateToString(int);
+ field public static final int AUDIO_CODEC_AMR = 1; // 0x1
+ field public static final int AUDIO_CODEC_AMR_WB = 2; // 0x2
+ field public static final int AUDIO_CODEC_EVRC = 4; // 0x4
+ field public static final int AUDIO_CODEC_EVRC_B = 5; // 0x5
+ field public static final int AUDIO_CODEC_EVRC_NW = 7; // 0x7
+ field public static final int AUDIO_CODEC_EVRC_WB = 6; // 0x6
+ field public static final int AUDIO_CODEC_EVS_FB = 20; // 0x14
+ field public static final int AUDIO_CODEC_EVS_NB = 17; // 0x11
+ field public static final int AUDIO_CODEC_EVS_SWB = 19; // 0x13
+ field public static final int AUDIO_CODEC_EVS_WB = 18; // 0x12
+ field public static final int AUDIO_CODEC_G711A = 13; // 0xd
+ field public static final int AUDIO_CODEC_G711AB = 15; // 0xf
+ field public static final int AUDIO_CODEC_G711U = 11; // 0xb
+ field public static final int AUDIO_CODEC_G722 = 14; // 0xe
+ field public static final int AUDIO_CODEC_G723 = 12; // 0xc
+ field public static final int AUDIO_CODEC_G729 = 16; // 0x10
+ field public static final int AUDIO_CODEC_GSM_EFR = 8; // 0x8
+ field public static final int AUDIO_CODEC_GSM_FR = 9; // 0x9
+ field public static final int AUDIO_CODEC_GSM_HR = 10; // 0xa
+ field public static final int AUDIO_CODEC_NONE = 0; // 0x0
+ field public static final int AUDIO_CODEC_QCELP13K = 3; // 0x3
field public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 8388608; // 0x800000
field public static final int CAPABILITY_CAN_PAUSE_VIDEO = 1048576; // 0x100000
field public static final int CAPABILITY_CAN_PULL_CALL = 16777216; // 0x1000000
@@ -43397,6 +43421,7 @@
field public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED = "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
field public static final String EXTRA_ANSWERING_DROPS_FG_CALL = "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
field public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME = "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
+ field public static final String EXTRA_AUDIO_CODEC = "android.telecom.extra.AUDIO_CODEC";
field public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
field public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
field public static final String EXTRA_IS_RTT_AUDIO_PRESENT = "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
@@ -43418,6 +43443,9 @@
field public static final int STATE_NEW = 1; // 0x1
field public static final int STATE_PULLING_CALL = 7; // 0x7
field public static final int STATE_RINGING = 2; // 0x2
+ field public static final int VERIFICATION_STATUS_FAILED = 2; // 0x2
+ field public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0; // 0x0
+ field public static final int VERIFICATION_STATUS_PASSED = 1; // 0x1
}
public static final class Connection.RttModifyStatus {
@@ -43931,6 +43959,7 @@
field public static final int EUTRAN = 3; // 0x3
field public static final int GERAN = 1; // 0x1
field public static final int IWLAN = 5; // 0x5
+ field public static final int NGRAN = 6; // 0x6
field public static final int UNKNOWN = 0; // 0x0
field public static final int UTRAN = 2; // 0x2
}
@@ -44003,6 +44032,52 @@
field public static final int BAND_T810 = 7; // 0x7
}
+ public static final class AccessNetworkConstants.NgranBands {
+ field public static final int BAND_1 = 1; // 0x1
+ field public static final int BAND_12 = 12; // 0xc
+ field public static final int BAND_14 = 14; // 0xe
+ field public static final int BAND_18 = 18; // 0x12
+ field public static final int BAND_2 = 2; // 0x2
+ field public static final int BAND_20 = 20; // 0x14
+ field public static final int BAND_25 = 25; // 0x19
+ field public static final int BAND_257 = 257; // 0x101
+ field public static final int BAND_258 = 258; // 0x102
+ field public static final int BAND_260 = 260; // 0x104
+ field public static final int BAND_261 = 261; // 0x105
+ field public static final int BAND_28 = 28; // 0x1c
+ field public static final int BAND_29 = 29; // 0x1d
+ field public static final int BAND_3 = 3; // 0x3
+ field public static final int BAND_30 = 30; // 0x1e
+ field public static final int BAND_34 = 34; // 0x22
+ field public static final int BAND_38 = 38; // 0x26
+ field public static final int BAND_39 = 39; // 0x27
+ field public static final int BAND_40 = 40; // 0x28
+ field public static final int BAND_41 = 41; // 0x29
+ field public static final int BAND_48 = 48; // 0x30
+ field public static final int BAND_5 = 5; // 0x5
+ field public static final int BAND_50 = 50; // 0x32
+ field public static final int BAND_51 = 51; // 0x33
+ field public static final int BAND_65 = 65; // 0x41
+ field public static final int BAND_66 = 66; // 0x42
+ field public static final int BAND_7 = 7; // 0x7
+ field public static final int BAND_70 = 70; // 0x46
+ field public static final int BAND_71 = 71; // 0x47
+ field public static final int BAND_74 = 74; // 0x4a
+ field public static final int BAND_75 = 75; // 0x4b
+ field public static final int BAND_76 = 76; // 0x4c
+ field public static final int BAND_77 = 77; // 0x4d
+ field public static final int BAND_78 = 78; // 0x4e
+ field public static final int BAND_79 = 79; // 0x4f
+ field public static final int BAND_8 = 8; // 0x8
+ field public static final int BAND_80 = 80; // 0x50
+ field public static final int BAND_81 = 81; // 0x51
+ field public static final int BAND_82 = 82; // 0x52
+ field public static final int BAND_83 = 83; // 0x53
+ field public static final int BAND_84 = 84; // 0x54
+ field public static final int BAND_86 = 86; // 0x56
+ field public static final int BAND_90 = 90; // 0x5a
+ }
+
public static final class AccessNetworkConstants.UtranBand {
field public static final int BAND_1 = 1; // 0x1
field public static final int BAND_10 = 10; // 0xa
@@ -44388,6 +44463,7 @@
method public abstract int getAsuLevel();
method public abstract int getDbm();
method @IntRange(from=android.telephony.CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN, to=android.telephony.CellSignalStrength.SIGNAL_STRENGTH_GREAT) public abstract int getLevel();
+ method public static final int getNumSignalStrengthLevels();
method public abstract int hashCode();
field public static final int SIGNAL_STRENGTH_GOOD = 3; // 0x3
field public static final int SIGNAL_STRENGTH_GREAT = 4; // 0x4
diff --git a/api/system-current.txt b/api/system-current.txt
index 3e6bcac..a82d12d3 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4195,6 +4195,7 @@
public class Network implements android.os.Parcelable {
ctor public Network(@NonNull android.net.Network);
method @NonNull public android.net.Network getPrivateDnsBypassingCopy();
+ field public final int netId;
}
public final class NetworkCapabilities implements android.os.Parcelable {
@@ -4439,7 +4440,7 @@
method @NonNull public java.util.List<android.net.ipsec.ike.IkeTrafficSelector> getOutboundTrafficSelectors();
}
- public abstract class ChildSessionOptions {
+ public abstract class ChildSessionParams {
}
public class IkeFqdnIdentification extends android.net.ipsec.ike.IkeIdentification {
@@ -4484,11 +4485,11 @@
}
public final class IkeSession implements java.lang.AutoCloseable {
- ctor public IkeSession(@NonNull android.content.Context, @NonNull android.net.ipsec.ike.IkeSessionOptions, @NonNull android.net.ipsec.ike.ChildSessionOptions, @NonNull java.util.concurrent.Executor, @NonNull android.net.ipsec.ike.IkeSessionCallback, @NonNull android.net.ipsec.ike.ChildSessionCallback);
+ ctor public IkeSession(@NonNull android.content.Context, @NonNull android.net.ipsec.ike.IkeSessionParams, @NonNull android.net.ipsec.ike.ChildSessionParams, @NonNull java.util.concurrent.Executor, @NonNull android.net.ipsec.ike.IkeSessionCallback, @NonNull android.net.ipsec.ike.ChildSessionCallback);
method public void close();
method public void closeChildSession(@NonNull android.net.ipsec.ike.ChildSessionCallback);
method public void kill();
- method public void openChildSession(@NonNull android.net.ipsec.ike.ChildSessionOptions, @NonNull android.net.ipsec.ike.ChildSessionCallback);
+ method public void openChildSession(@NonNull android.net.ipsec.ike.ChildSessionParams, @NonNull android.net.ipsec.ike.ChildSessionCallback);
}
public interface IkeSessionCallback {
@@ -4506,21 +4507,21 @@
field public static final int EXTENSION_TYPE_MOBIKE = 2; // 0x2
}
- public final class IkeSessionOptions {
+ public final class IkeSessionParams {
}
- public static final class IkeSessionOptions.Builder {
- ctor public IkeSessionOptions.Builder();
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder addSaProposal(@NonNull android.net.ipsec.ike.IkeSaProposal);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions build();
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setAuthDigitalSignature(@NonNull java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.security.PrivateKey);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setAuthDigitalSignature(@NonNull java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.util.List<java.security.cert.X509Certificate>, @NonNull java.security.PrivateKey);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setAuthEap(@NonNull java.security.cert.X509Certificate, @NonNull android.net.eap.EapSessionConfig);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setAuthPsk(@NonNull byte[]);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setLocalIdentification(@NonNull android.net.ipsec.ike.IkeIdentification);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setRemoteIdentification(@NonNull android.net.ipsec.ike.IkeIdentification);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setServerAddress(@NonNull java.net.InetAddress);
- method @NonNull public android.net.ipsec.ike.IkeSessionOptions.Builder setUdpEncapsulationSocket(@NonNull android.net.IpSecManager.UdpEncapsulationSocket);
+ public static final class IkeSessionParams.Builder {
+ ctor public IkeSessionParams.Builder();
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder addSaProposal(@NonNull android.net.ipsec.ike.IkeSaProposal);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams build();
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthDigitalSignature(@NonNull java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.security.PrivateKey);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthDigitalSignature(@NonNull java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.util.List<java.security.cert.X509Certificate>, @NonNull java.security.PrivateKey);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthEap(@NonNull java.security.cert.X509Certificate, @NonNull android.net.eap.EapSessionConfig);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthPsk(@NonNull byte[]);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setLocalIdentification(@NonNull android.net.ipsec.ike.IkeIdentification);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setRemoteIdentification(@NonNull android.net.ipsec.ike.IkeIdentification);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setServerAddress(@NonNull java.net.InetAddress);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setUdpEncapsulationSocket(@NonNull android.net.IpSecManager.UdpEncapsulationSocket);
}
public final class IkeTrafficSelector {
@@ -4557,33 +4558,33 @@
field public static final int PSEUDORANDOM_FUNCTION_HMAC_SHA1 = 2; // 0x2
}
- public final class TransportModeChildSessionOptions extends android.net.ipsec.ike.ChildSessionOptions {
+ public final class TransportModeChildSessionParams extends android.net.ipsec.ike.ChildSessionParams {
}
- public static final class TransportModeChildSessionOptions.Builder {
- ctor public TransportModeChildSessionOptions.Builder();
- method @NonNull public android.net.ipsec.ike.TransportModeChildSessionOptions.Builder addInboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
- method @NonNull public android.net.ipsec.ike.TransportModeChildSessionOptions.Builder addOutboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
- method @NonNull public android.net.ipsec.ike.TransportModeChildSessionOptions.Builder addSaProposal(@NonNull android.net.ipsec.ike.ChildSaProposal);
- method @NonNull public android.net.ipsec.ike.TransportModeChildSessionOptions build();
+ public static final class TransportModeChildSessionParams.Builder {
+ ctor public TransportModeChildSessionParams.Builder();
+ method @NonNull public android.net.ipsec.ike.TransportModeChildSessionParams.Builder addInboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
+ method @NonNull public android.net.ipsec.ike.TransportModeChildSessionParams.Builder addOutboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
+ method @NonNull public android.net.ipsec.ike.TransportModeChildSessionParams.Builder addSaProposal(@NonNull android.net.ipsec.ike.ChildSaProposal);
+ method @NonNull public android.net.ipsec.ike.TransportModeChildSessionParams build();
}
- public final class TunnelModeChildSessionOptions extends android.net.ipsec.ike.ChildSessionOptions {
+ public final class TunnelModeChildSessionParams extends android.net.ipsec.ike.ChildSessionParams {
}
- public static final class TunnelModeChildSessionOptions.Builder {
- ctor public TunnelModeChildSessionOptions.Builder();
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInternalAddressRequest(int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInternalAddressRequest(@NonNull java.net.InetAddress, int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInternalDhcpServerRequest(int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInternalDhcpServerRequest(@NonNull java.net.InetAddress);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInternalDnsServerRequest(int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInternalDnsServerRequest(@NonNull java.net.InetAddress);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addInternalSubnetRequest(int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addOutboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions.Builder addSaProposal(@NonNull android.net.ipsec.ike.ChildSaProposal);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionOptions build();
+ public static final class TunnelModeChildSessionParams.Builder {
+ ctor public TunnelModeChildSessionParams.Builder();
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalAddressRequest(int);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalAddressRequest(@NonNull java.net.InetAddress, int);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDhcpServerRequest(int);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDhcpServerRequest(@NonNull java.net.InetAddress);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDnsServerRequest(int);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDnsServerRequest(@NonNull java.net.InetAddress);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalSubnetRequest(int);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addOutboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addSaProposal(@NonNull android.net.ipsec.ike.ChildSaProposal);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams build();
}
}
@@ -6175,6 +6176,18 @@
package android.provider {
+ public class BlockedNumberContract {
+ field public static final String METHOD_NOTIFY_EMERGENCY_CONTACT = "notify_emergency_contact";
+ field public static final String METHOD_SHOULD_SYSTEM_BLOCK_NUMBER = "should_system_block_number";
+ field public static final String RES_BLOCK_STATUS = "block_status";
+ field public static final int STATUS_BLOCKED_IN_LIST = 1; // 0x1
+ field public static final int STATUS_BLOCKED_NOT_IN_CONTACTS = 5; // 0x5
+ field public static final int STATUS_BLOCKED_PAYPHONE = 4; // 0x4
+ field public static final int STATUS_BLOCKED_RESTRICTED = 2; // 0x2
+ field public static final int STATUS_BLOCKED_UNKNOWN_NUMBER = 3; // 0x3
+ field public static final int STATUS_NOT_BLOCKED = 0; // 0x0
+ }
+
public static final class ContactsContract.MetadataSync implements android.provider.BaseColumns android.provider.ContactsContract.MetadataSyncColumns {
field public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata";
field public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata";
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 32d90b7..4440bf8 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -324,6 +324,8 @@
AppCompatibilityChangeReported app_compatibility_change_reported =
228 [(allow_from_any_uid) = true];
+ PerfettoUploaded perfetto_uploaded =
+ 229 [(log_from_module) = "perfetto"];
}
// Pulled events will start at field 10000.
@@ -6858,3 +6860,37 @@
optional Source source = 4;
}
+
+/**
+ * Logged from
+ * external/perfetto/src/perfetto_cmd/perfetto_cmd.cc
+ */
+message PerfettoUploaded {
+ enum Event {
+ PERFETTO_UNDEFINED = 0;
+ PERFETTO_TRACE_BEGIN = 1;
+ PERFETTO_BACKGROUND_TRACE_BEGIN = 2;
+ PERFETTO_ON_CONNECT = 3;
+ PERFETTO_ON_TRACING_DISABLED = 4;
+ PERFETTO_UPLOAD_DROPBOX_BEGIN = 5;
+ PERFETTO_UPLOAD_DROPBOX_SUCCESS = 6;
+ PERFETTO_UPLOAD_DROPBOX_FAILURE = 7;
+ PERFETTO_UPLOAD_INCIDENT_BEGIN = 8;
+ PERFETTO_UPLOAD_INCIDENT_SUCCESS = 9;
+ PERFETTO_UPLOAD_INCIDENT_FAILURE = 10;
+ PERFETTO_FINALIZE_TRACE_AND_EXIT = 11;
+ PERFETTO_TRIGGER_BEGIN = 12;
+ PERFETTO_TRIGGER_SUCCESS = 13;
+ PERFETTO_TRIGGER_FAILURE = 14;
+ PERFETTO_HIT_GUARDRAILS = 15;
+ PERFETTO_ON_TIMEOUT = 16;
+ PERFETTO_NOT_UPLOADING_EMPTY_TRACE = 17;
+ }
+
+ // Which stage of the pipeline we are reporting from.
+ optional Event event = 1;
+
+ // UUID matching the one set inside the SystemInfo trace packet.
+ optional int64 trace_uuid_lsb = 2;
+ optional int64 trace_uuid_msb = 3;
+}
diff --git a/core/java/android/app/IntentService.java b/core/java/android/app/IntentService.java
index 11c747f..74fb99a 100644
--- a/core/java/android/app/IntentService.java
+++ b/core/java/android/app/IntentService.java
@@ -44,13 +44,6 @@
* long as necessary (and will not block the application's main loop), but
* only one request will be processed at a time.
*
- * <p class="note"><b>Note:</b> IntentService is subject to all the
- * <a href="/preview/features/background.html">background execution limits</a>
- * imposed with Android 8.0 (API level 26). In most cases, you are better off
- * using {@link android.support.v4.app.JobIntentService}, which uses jobs
- * instead of services when running on Android 8.0 or higher.
- * </p>
- *
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For a detailed discussion about how to create services, read the
@@ -59,8 +52,14 @@
* </div>
*
* @see android.support.v4.app.JobIntentService
- * @see android.os.AsyncTask
+ *
+ * @deprecated IntentService is subject to all the
+ * <a href="/preview/features/background.html">background execution limits</a>
+ * imposed with Android 8.0 (API level 26). Consider using {@link androidx.work.WorkManager}
+ * or {@link androidx.core.app.JobIntentService}, which uses jobs
+ * instead of services when running on Android 8.0 or higher.
*/
+@Deprecated
public abstract class IntentService extends Service {
private volatile Looper mServiceLooper;
@UnsupportedAppUsage
diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java
index 1f91b3f..9b62e3b 100644
--- a/core/java/android/app/Service.java
+++ b/core/java/android/app/Service.java
@@ -57,7 +57,7 @@
* networking) operations, it should spawn its own thread in which to do that
* work. More information on this can be found in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html">Processes and
- * Threads</a>. The {@link IntentService} class is available
+ * Threads</a>. The {@link androidx.core.app.JobIntentService} class is available
* as a standard implementation of Service that has its own thread where it
* schedules its work to be done.</p>
*
diff --git a/core/java/android/app/timezonedetector/TimeZoneDetector.java b/core/java/android/app/timezonedetector/TimeZoneDetector.java
index 909cbc2..387a36b 100644
--- a/core/java/android/app/timezonedetector/TimeZoneDetector.java
+++ b/core/java/android/app/timezonedetector/TimeZoneDetector.java
@@ -17,6 +17,7 @@
package android.app.timezonedetector;
import android.annotation.NonNull;
+import android.annotation.RequiresPermission;
import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;
@@ -26,10 +27,11 @@
/**
* The interface through which system components can send signals to the TimeZoneDetectorService.
+ *
* @hide
*/
@SystemService(Context.TIME_ZONE_DETECTOR_SERVICE)
-public final class TimeZoneDetector {
+public class TimeZoneDetector {
private static final String TAG = "timezonedetector.TimeZoneDetector";
private static final boolean DEBUG = false;
@@ -41,10 +43,11 @@
}
/**
- * Suggests the current time zone to the detector. The detector may ignore the signal if better
- * signals are available such as those that come from more reliable sources or were
- * determined more recently.
+ * Suggests the current time zone, determined using telephony signals, to the detector. The
+ * detector may ignore the signal based on system settings, whether better information is
+ * available, and so on.
*/
+ @RequiresPermission(android.Manifest.permission.SET_TIME_ZONE)
public void suggestPhoneTimeZone(@NonNull PhoneTimeZoneSuggestion timeZoneSuggestion) {
if (DEBUG) {
Log.d(TAG, "suggestPhoneTimeZone called: " + timeZoneSuggestion);
@@ -56,4 +59,28 @@
}
}
+ /**
+ * Suggests the current time zone, determined for the user's manually information, to the
+ * detector. The detector may ignore the signal based on system settings.
+ */
+ @RequiresPermission(android.Manifest.permission.SET_TIME_ZONE)
+ public void suggestManualTimeZone(@NonNull ManualTimeZoneSuggestion timeZoneSuggestion) {
+ if (DEBUG) {
+ Log.d(TAG, "suggestManualTimeZone called: " + timeZoneSuggestion);
+ }
+ try {
+ mITimeZoneDetectorService.suggestManualTimeZone(timeZoneSuggestion);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * A shared utility method to create a {@link ManualTimeZoneSuggestion}.
+ */
+ public static ManualTimeZoneSuggestion createManualTimeZoneSuggestion(String tzId, String why) {
+ ManualTimeZoneSuggestion suggestion = new ManualTimeZoneSuggestion(tzId);
+ suggestion.addDebugInfo(why);
+ return suggestion;
+ }
}
diff --git a/core/java/android/net/MacAddress.aidl b/core/java/android/net/MacAddress.aidl
new file mode 100644
index 0000000..48a18a7
--- /dev/null
+++ b/core/java/android/net/MacAddress.aidl
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright (C) 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.
+ */
+
+package android.net;
+
+@JavaOnlyStableParcelable parcelable MacAddress;
diff --git a/core/java/android/net/Network.java b/core/java/android/net/Network.java
index 3f56def..f12ba13 100644
--- a/core/java/android/net/Network.java
+++ b/core/java/android/net/Network.java
@@ -63,7 +63,7 @@
/**
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
public final int netId;
// Objects used to perform per-network operations such as getSocketFactory
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 387775b..d016ec4 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -27,7 +27,7 @@
import android.server.ServerProtoEnums;
import android.service.batterystats.BatteryStatsServiceDumpHistoryProto;
import android.service.batterystats.BatteryStatsServiceDumpProto;
-import android.telephony.SignalStrength;
+import android.telephony.CellSignalStrength;
import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
import android.util.ArrayMap;
@@ -2509,7 +2509,7 @@
new String[] {"in", "out", "em", "off"}),
new BitDescription(HistoryItem.STATE_PHONE_SIGNAL_STRENGTH_MASK,
HistoryItem.STATE_PHONE_SIGNAL_STRENGTH_SHIFT, "phone_signal_strength", "Pss",
- SignalStrength.SIGNAL_STRENGTH_NAMES,
+ new String[] { "none", "poor", "moderate", "good", "great" },
new String[] { "0", "1", "2", "3", "4" }),
new BitDescription(HistoryItem.STATE_BRIGHTNESS_MASK,
HistoryItem.STATE_BRIGHTNESS_SHIFT, "brightness", "Sb",
@@ -3856,14 +3856,14 @@
dumpLine(pw, 0 /* uid */, category, SCREEN_BRIGHTNESS_DATA, args);
// Dump signal strength stats
- args = new Object[SignalStrength.NUM_SIGNAL_STRENGTH_BINS];
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ args = new Object[CellSignalStrength.getNumSignalStrengthLevels()];
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
args[i] = getPhoneSignalStrengthTime(i, rawRealtime, which) / 1000;
}
dumpLine(pw, 0 /* uid */, category, SIGNAL_STRENGTH_TIME_DATA, args);
dumpLine(pw, 0 /* uid */, category, SIGNAL_SCANNING_TIME_DATA,
getPhoneSignalScanningTime(rawRealtime, which) / 1000);
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
args[i] = getPhoneSignalStrengthCount(i, which);
}
dumpLine(pw, 0 /* uid */, category, SIGNAL_STRENGTH_COUNT_DATA, args);
@@ -4931,7 +4931,7 @@
"good (-108dBm to -98dBm): ",
"great (greater than -98dBm): "};
didOne = false;
- final int numCellularRxBins = Math.min(SignalStrength.NUM_SIGNAL_STRENGTH_BINS,
+ final int numCellularRxBins = Math.min(CellSignalStrength.getNumSignalStrengthLevels(),
cellularRxSignalStrengthDescription.length);
for (int i=0; i<numCellularRxBins; i++) {
final long time = getPhoneSignalStrengthTime(i, rawRealtime, which);
@@ -8186,7 +8186,7 @@
which);
// Phone signal strength (SIGNAL_STRENGTH_TIME_DATA and SIGNAL_STRENGTH_COUNT_DATA)
- for (int i = 0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; ++i) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); ++i) {
final long pssToken = proto.start(SystemProto.PHONE_SIGNAL_STRENGTH);
proto.write(SystemProto.PhoneSignalStrength.NAME, i);
dumpTimer(proto, SystemProto.PhoneSignalStrength.TOTAL, getPhoneSignalStrengthTimer(i),
diff --git a/core/java/android/os/connectivity/CellularBatteryStats.java b/core/java/android/os/connectivity/CellularBatteryStats.java
index 2e09040..6adab06 100644
--- a/core/java/android/os/connectivity/CellularBatteryStats.java
+++ b/core/java/android/os/connectivity/CellularBatteryStats.java
@@ -18,9 +18,8 @@
import android.os.BatteryStats;
import android.os.Parcel;
import android.os.Parcelable;
-
+import android.telephony.CellSignalStrength;
import android.telephony.ModemActivityInfo;
-import android.telephony.SignalStrength;
import java.util.Arrays;
@@ -209,7 +208,7 @@
public void setTimeInRxSignalStrengthLevelMs(long[] t) {
mTimeInRxSignalStrengthLevelMs = Arrays.copyOfRange(t, 0,
- Math.min(t.length, SignalStrength.NUM_SIGNAL_STRENGTH_BINS));
+ Math.min(t.length, CellSignalStrength.getNumSignalStrengthLevels()));
return;
}
@@ -245,11 +244,11 @@
mEnergyConsumedMaMs = 0;
mTimeInRatMs = new long[BatteryStats.NUM_DATA_CONNECTION_TYPES];
Arrays.fill(mTimeInRatMs, 0);
- mTimeInRxSignalStrengthLevelMs = new long[SignalStrength.NUM_SIGNAL_STRENGTH_BINS];
+ mTimeInRxSignalStrengthLevelMs = new long[CellSignalStrength.getNumSignalStrengthLevels()];
Arrays.fill(mTimeInRxSignalStrengthLevelMs, 0);
mTxTimeMs = new long[ModemActivityInfo.TX_POWER_LEVELS];
Arrays.fill(mTxTimeMs, 0);
mMonitoredRailChargeConsumedMaMs = 0;
return;
}
-}
\ No newline at end of file
+}
diff --git a/core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl b/core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl
new file mode 100644
index 0000000..0ae353d
--- /dev/null
+++ b/core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 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.
+ */
+
+package android.os.incremental;
+
+/**
+ * Wraps two file descriptors that Incremental Service uses to communicate
+ * with Incremental FileSystem.
+ * @hide
+ */
+parcelable IncrementalFileSystemControlParcel {
+ @nullable ParcelFileDescriptor cmd;
+ @nullable ParcelFileDescriptor log;
+}
diff --git a/core/java/android/provider/BlockedNumberContract.java b/core/java/android/provider/BlockedNumberContract.java
index dd2ea81..1eb7664 100644
--- a/core/java/android/provider/BlockedNumberContract.java
+++ b/core/java/android/provider/BlockedNumberContract.java
@@ -16,6 +16,7 @@
package android.provider;
import android.annotation.IntDef;
+import android.annotation.SystemApi;
import android.annotation.WorkerThread;
import android.content.Context;
import android.net.Uri;
@@ -239,6 +240,7 @@
* blocked.
* @hide
*/
+ @SystemApi
public static final int STATUS_NOT_BLOCKED = 0;
/**
@@ -246,6 +248,7 @@
* because it is in the list of blocked numbers maintained by the provider.
* @hide
*/
+ @SystemApi
public static final int STATUS_BLOCKED_IN_LIST = 1;
/**
@@ -253,6 +256,7 @@
* because it is from a restricted number.
* @hide
*/
+ @SystemApi
public static final int STATUS_BLOCKED_RESTRICTED = 2;
/**
@@ -260,6 +264,7 @@
* because it is from an unknown number.
* @hide
*/
+ @SystemApi
public static final int STATUS_BLOCKED_UNKNOWN_NUMBER = 3;
/**
@@ -267,6 +272,7 @@
* because it is from a pay phone.
* @hide
*/
+ @SystemApi
public static final int STATUS_BLOCKED_PAYPHONE = 4;
/**
@@ -274,12 +280,14 @@
* because it is from a number not in the users contacts.
* @hide
*/
+ @SystemApi
public static final int STATUS_BLOCKED_NOT_IN_CONTACTS = 5;
/**
* Integer reason indicating whether a call was blocked, and if so why.
* @hide
*/
+ @SystemApi
public static final String RES_BLOCK_STATUS = "block_status";
/** @hide */
@@ -290,6 +298,31 @@
"can_current_user_block_numbers";
/** @hide */
+ @SystemApi
+ public static final String METHOD_NOTIFY_EMERGENCY_CONTACT = "notify_emergency_contact";
+
+ /** @hide */
+ public static final String METHOD_END_BLOCK_SUPPRESSION = "end_block_suppression";
+
+ /** @hide */
+ @SystemApi
+ public static final String METHOD_SHOULD_SYSTEM_BLOCK_NUMBER = "should_system_block_number";
+
+ /** @hide */
+ public static final String METHOD_GET_BLOCK_SUPPRESSION_STATUS =
+ "get_block_suppression_status";
+
+ /** @hide */
+ public static final String METHOD_SHOULD_SHOW_EMERGENCY_CALL_NOTIFICATION =
+ "should_show_emergency_call_notification";
+
+ /** @hide */
+ public static final String METHOD_GET_ENHANCED_BLOCK_SETTING = "get_enhanced_block_setting";
+
+ /** @hide */
+ public static final String METHOD_SET_ENHANCED_BLOCK_SETTING = "set_enhanced_block_setting";
+
+ /** @hide */
public static final String RES_CAN_BLOCK_NUMBERS = "can_block";
/** @hide */
@@ -406,26 +439,11 @@
public static final String ACTION_BLOCK_SUPPRESSION_STATE_CHANGED =
"android.provider.action.BLOCK_SUPPRESSION_STATE_CHANGED";
- public static final String METHOD_NOTIFY_EMERGENCY_CONTACT = "notify_emergency_contact";
-
- public static final String METHOD_END_BLOCK_SUPPRESSION = "end_block_suppression";
-
- public static final String METHOD_SHOULD_SYSTEM_BLOCK_NUMBER = "should_system_block_number";
-
- public static final String METHOD_GET_BLOCK_SUPPRESSION_STATUS =
- "get_block_suppression_status";
-
- public static final String METHOD_SHOULD_SHOW_EMERGENCY_CALL_NOTIFICATION =
- "should_show_emergency_call_notification";
-
public static final String RES_IS_BLOCKING_SUPPRESSED = "blocking_suppressed";
public static final String RES_BLOCKING_SUPPRESSED_UNTIL_TIMESTAMP =
"blocking_suppressed_until_timestamp";
- public static final String METHOD_GET_ENHANCED_BLOCK_SETTING = "get_enhanced_block_setting";
- public static final String METHOD_SET_ENHANCED_BLOCK_SETTING = "set_enhanced_block_setting";
-
/* Preference key of block numbers not in contacts setting. */
public static final String ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED =
"block_numbers_not_in_contacts_setting";
diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java
index e80df2d..ebdde0a 100644
--- a/core/java/android/provider/Telephony.java
+++ b/core/java/android/provider/Telephony.java
@@ -45,7 +45,6 @@
import android.text.TextUtils;
import android.util.Patterns;
-import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.SmsApplication;
import java.lang.annotation.Retention;
@@ -1344,7 +1343,7 @@
}
String format = intent.getStringExtra("format");
- int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
+ int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultSmsSubscriptionId());
Rlog.v(TAG, " getMessagesFromIntent sub_id : " + subId);
diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl b/core/java/android/telephony/DataConnectionRealTimeInfo.aidl
similarity index 100%
rename from telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl
rename to core/java/android/telephony/DataConnectionRealTimeInfo.aidl
diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.java b/core/java/android/telephony/DataConnectionRealTimeInfo.java
similarity index 100%
rename from telephony/java/android/telephony/DataConnectionRealTimeInfo.java
rename to core/java/android/telephony/DataConnectionRealTimeInfo.java
diff --git a/core/java/com/android/internal/compat/CompatibilityChangeInfo.java b/core/java/com/android/internal/compat/CompatibilityChangeInfo.java
index e48e2df..16628d7 100644
--- a/core/java/com/android/internal/compat/CompatibilityChangeInfo.java
+++ b/core/java/com/android/internal/compat/CompatibilityChangeInfo.java
@@ -30,6 +30,7 @@
private final @Nullable String mName;
private final int mEnableAfterTargetSdk;
private final boolean mDisabled;
+ private final @Nullable String mDescription;
public long getId() {
return mChangeId;
@@ -48,12 +49,18 @@
return mDisabled;
}
+ public String getDescription() {
+ return mDescription;
+ }
+
public CompatibilityChangeInfo(
- Long changeId, String name, int enableAfterTargetSdk, boolean disabled) {
+ Long changeId, String name, int enableAfterTargetSdk, boolean disabled,
+ String description) {
this.mChangeId = changeId;
this.mName = name;
this.mEnableAfterTargetSdk = enableAfterTargetSdk;
this.mDisabled = disabled;
+ this.mDescription = description;
}
private CompatibilityChangeInfo(Parcel in) {
@@ -61,6 +68,7 @@
mName = in.readString();
mEnableAfterTargetSdk = in.readInt();
mDisabled = in.readBoolean();
+ mDescription = in.readString();
}
@Override
@@ -74,6 +82,7 @@
dest.writeString(mName);
dest.writeInt(mEnableAfterTargetSdk);
dest.writeBoolean(mDisabled);
+ dest.writeString(mDescription);
}
public static final Parcelable.Creator<CompatibilityChangeInfo> CREATOR =
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index e1a640ee..427474c 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -58,6 +58,7 @@
import android.os.connectivity.GpsBatteryStats;
import android.os.connectivity.WifiBatteryStats;
import android.provider.Settings;
+import android.telephony.CellSignalStrength;
import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.ModemActivityInfo;
import android.telephony.ServiceState;
@@ -830,7 +831,7 @@
int mPhoneSignalStrengthBin = -1;
int mPhoneSignalStrengthBinRaw = -1;
final StopwatchTimer[] mPhoneSignalStrengthsTimer =
- new StopwatchTimer[SignalStrength.NUM_SIGNAL_STRENGTH_BINS];
+ new StopwatchTimer[CellSignalStrength.getNumSignalStrengthLevels()];
StopwatchTimer mPhoneSignalScanningTimer;
@@ -5130,7 +5131,7 @@
void stopAllPhoneSignalStrengthTimersLocked(int except) {
final long elapsedRealtime = mClocks.elapsedRealtime();
- for (int i = 0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
if (i == except) {
continue;
}
@@ -5145,7 +5146,7 @@
// In this case we will always be STATE_OUT_OF_SERVICE, so need
// to infer that we are scanning from other data.
if (state == ServiceState.STATE_OUT_OF_SERVICE
- && signalBin > SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
+ && signalBin > CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
state = ServiceState.STATE_IN_SERVICE;
}
}
@@ -5168,7 +5169,7 @@
// In this case we will always be STATE_OUT_OF_SERVICE, so need
// to infer that we are scanning from other data.
if (state == ServiceState.STATE_OUT_OF_SERVICE
- && strengthBin > SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
+ && strengthBin > CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
state = ServiceState.STATE_IN_SERVICE;
}
}
@@ -5185,7 +5186,7 @@
// bin and have the scanning bit set.
} else if (state == ServiceState.STATE_OUT_OF_SERVICE) {
scanning = true;
- strengthBin = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ strengthBin = CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
if (!mPhoneSignalScanningTimer.isRunningLocked()) {
mHistoryCur.states |= HistoryItem.STATE_PHONE_SCANNING_FLAG;
newHistory = true;
@@ -9785,7 +9786,7 @@
mDeviceLightIdlingTimer = new StopwatchTimer(mClocks, null, -15, null, mOnBatteryTimeBase);
mDeviceIdlingTimer = new StopwatchTimer(mClocks, null, -12, null, mOnBatteryTimeBase);
mPhoneOnTimer = new StopwatchTimer(mClocks, null, -3, null, mOnBatteryTimeBase);
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
mPhoneSignalStrengthsTimer[i] = new StopwatchTimer(mClocks, null, -200-i, null,
mOnBatteryTimeBase);
}
@@ -10494,7 +10495,7 @@
mFlashlightOnTimer.reset(false);
mCameraOnTimer.reset(false);
mBluetoothScanTimer.reset(false);
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
mPhoneSignalStrengthsTimer[i].reset(false);
}
mPhoneSignalScanningTimer.reset(false);
@@ -11055,7 +11056,7 @@
mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_RX);
int[] txTimeMs = deltaInfo.getTxTimeMillis();
for (int i = 0; i < Math.min(txTimeMs.length,
- SignalStrength.NUM_SIGNAL_STRENGTH_BINS); i++) {
+ CellSignalStrength.getNumSignalStrengthLevels()); i++) {
energyUsed += txTimeMs[i] * mPowerProfile.getAveragePower(
PowerProfile.POWER_MODEM_CONTROLLER_TX, i);
}
@@ -12604,7 +12605,8 @@
for (int i = 0; i < timeInRatMs.length; i++) {
timeInRatMs[i] = getPhoneDataConnectionTime(i, rawRealTime, which) / 1000;
}
- long[] timeInRxSignalStrengthLevelMs = new long[SignalStrength.NUM_SIGNAL_STRENGTH_BINS];
+ long[] timeInRxSignalStrengthLevelMs =
+ new long[CellSignalStrength.getNumSignalStrengthLevels()];
for (int i = 0; i < timeInRxSignalStrengthLevelMs.length; i++) {
timeInRxSignalStrengthLevelMs[i]
= getPhoneSignalStrengthTime(i, rawRealTime, which) / 1000;
@@ -13608,7 +13610,7 @@
mDeviceLightIdlingTimer.readSummaryFromParcelLocked(in);
mDeviceIdlingTimer.readSummaryFromParcelLocked(in);
mPhoneOnTimer.readSummaryFromParcelLocked(in);
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
mPhoneSignalStrengthsTimer[i].readSummaryFromParcelLocked(in);
}
mPhoneSignalScanningTimer.readSummaryFromParcelLocked(in);
@@ -14093,7 +14095,7 @@
mDeviceLightIdlingTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
mDeviceIdlingTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
mPhoneOnTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
mPhoneSignalStrengthsTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS);
}
mPhoneSignalScanningTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
@@ -14571,7 +14573,7 @@
mOnBatteryTimeBase, in);
mDeviceIdlingTimer = new StopwatchTimer(mClocks, null, -12, null, mOnBatteryTimeBase, in);
mPhoneOnTimer = new StopwatchTimer(mClocks, null, -3, null, mOnBatteryTimeBase, in);
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
mPhoneSignalStrengthsTimer[i] = new StopwatchTimer(mClocks, null, -200-i,
null, mOnBatteryTimeBase, in);
}
@@ -14790,7 +14792,7 @@
mDeviceLightIdlingTimer.writeToParcel(out, uSecRealtime);
mDeviceIdlingTimer.writeToParcel(out, uSecRealtime);
mPhoneOnTimer.writeToParcel(out, uSecRealtime);
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
mPhoneSignalStrengthsTimer[i].writeToParcel(out, uSecRealtime);
}
mPhoneSignalScanningTimer.writeToParcel(out, uSecRealtime);
@@ -14981,7 +14983,7 @@
mDeviceIdlingTimer.logState(pr, " ");
pr.println("*** Phone timer:");
mPhoneOnTimer.logState(pr, " ");
- for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
+ for (int i = 0; i < CellSignalStrength.getNumSignalStrengthLevels(); i++) {
pr.println("*** Phone signal strength #" + i + ":");
mPhoneSignalStrengthsTimer[i].logState(pr, " ");
}
diff --git a/core/java/com/android/internal/os/MobileRadioPowerCalculator.java b/core/java/com/android/internal/os/MobileRadioPowerCalculator.java
index 9e8f06d..7c77d28 100644
--- a/core/java/com/android/internal/os/MobileRadioPowerCalculator.java
+++ b/core/java/com/android/internal/os/MobileRadioPowerCalculator.java
@@ -16,14 +16,14 @@
package com.android.internal.os;
import android.os.BatteryStats;
-import android.telephony.SignalStrength;
+import android.telephony.CellSignalStrength;
import android.util.Log;
public class MobileRadioPowerCalculator extends PowerCalculator {
private static final String TAG = "MobileRadioPowerController";
private static final boolean DEBUG = BatteryStatsHelper.DEBUG;
private final double mPowerRadioOn;
- private final double[] mPowerBins = new double[SignalStrength.NUM_SIGNAL_STRENGTH_BINS];
+ private final double[] mPowerBins = new double[CellSignalStrength.getNumSignalStrengthLevels()];
private final double mPowerScan;
private BatteryStats mStats;
private long mTotalAppMobileActiveMs = 0;
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 6417b28..541b937 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -2250,6 +2250,20 @@
return (jint) check_AudioSystem_Command(AudioSystem::setRttEnabled(enabled));
}
+static jint
+android_media_AudioSystem_setAudioHalPids(JNIEnv *env, jobject clazz, jintArray jPids)
+{
+ if (jPids == NULL) {
+ return (jint)AUDIO_JAVA_BAD_VALUE;
+ }
+ pid_t *nPidsArray = (pid_t *)env->GetIntArrayElements(jPids, NULL);
+ std::vector<pid_t> nPids(nPidsArray, nPidsArray + env->GetArrayLength(jPids));
+ status_t status = AudioSystem::setAudioHalPids(nPids);
+ env->ReleaseIntArrayElements(jPids, nPidsArray, 0);
+ jint jStatus = nativeToJavaStatus(status);
+ return jStatus;
+}
+
// ----------------------------------------------------------------------------
static const JNINativeMethod gMethods[] = {
@@ -2328,6 +2342,7 @@
(void*)android_media_AudioSystem_getHwOffloadEncodingFormatsSupportedForA2DP},
{"setAllowedCapturePolicy", "(II)I", (void *)android_media_AudioSystem_setAllowedCapturePolicy},
{"setRttEnabled", "(Z)I", (void *)android_media_AudioSystem_setRttEnabled},
+ {"setAudioHalPids", "([I)I", (void *)android_media_AudioSystem_setAudioHalPids},
};
static const JNINativeMethod gEventHandlerMethods[] = {
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index d53b529..d5e263f 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -3855,6 +3855,8 @@
instead of 'Emergency calls only' when SIM is unready. -->
<string-array translatable="false" name="config_display_no_service_when_sim_unready">
<item>"DE"</item>
+ <item>"GB"</item>
+ <item>"JP"</item>
</string-array>
<!-- Class names of device specific services inheriting com.android.server.SystemService. The
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index bb731a8..900572d 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -1124,6 +1124,12 @@
*/
public static native boolean isHapticPlaybackSupported();
+ /**
+ * Send audio HAL server process pids to native audioserver process for use
+ * when generating audio HAL servers tombstones
+ */
+ public static native int setAudioHalPids(int[] pids);
+
// Items shared with audio service
/**
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java b/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java
index 5ac788e..3b41fa9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java
+++ b/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java
@@ -32,7 +32,7 @@
import android.graphics.Rect;
import android.graphics.drawable.DrawableWrapper;
import android.os.Handler;
-import android.telephony.SignalStrength;
+import android.telephony.CellSignalStrength;
import android.util.LayoutDirection;
import android.util.PathParser;
@@ -145,7 +145,7 @@
private int unpackLevel(int packedState) {
int numBins = (packedState & NUM_LEVEL_MASK) >> NUM_LEVEL_SHIFT;
- int levelOffset = numBins == (SignalStrength.NUM_SIGNAL_STRENGTH_BINS + 1) ? 10 : 0;
+ int levelOffset = numBins == (CellSignalStrength.getNumSignalStrengthLevels() + 1) ? 10 : 0;
int level = (packedState & LEVEL_MASK);
return level + levelOffset;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
index 91c6ab1..f91deea 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
@@ -26,6 +26,7 @@
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.os.Looper;
+import android.telephony.CellSignalStrength;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
@@ -180,7 +181,7 @@
@Test
public void testCdmaSignalRoaming() {
- for (int testStrength = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ for (int testStrength = CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
testStrength <= SignalStrength.SIGNAL_STRENGTH_GREAT; testStrength++) {
setupDefaultSignal();
setCdma();
@@ -203,7 +204,7 @@
@Test
public void testQsSignalStrength() {
- for (int testStrength = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ for (int testStrength = CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
testStrength <= SignalStrength.SIGNAL_STRENGTH_GREAT; testStrength++) {
setupDefaultSignal();
setLevel(testStrength);
@@ -216,7 +217,7 @@
@Test
public void testCdmaQsSignalStrength() {
- for (int testStrength = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ for (int testStrength = CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
testStrength <= SignalStrength.SIGNAL_STRENGTH_GREAT; testStrength++) {
setupDefaultSignal();
setCdma();
diff --git a/services/core/java/com/android/server/OWNERS b/services/core/java/com/android/server/OWNERS
index a9c38bc..76e0c13 100644
--- a/services/core/java/com/android/server/OWNERS
+++ b/services/core/java/com/android/server/OWNERS
@@ -4,3 +4,6 @@
# Vibrator / Threads
per-file VibratorService.java, DisplayThread.java = michaelwr@google.com
per-file VibratorService.java, DisplayThread.java = ogunwale@google.com
+
+# Zram writeback
+per-file ZramWriteback.java = minchan@google.com, rajekumar@google.com, srnvs@google.com
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index f8b0072..fc34434 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -37,6 +37,7 @@
import android.os.Message;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.telephony.Annotation;
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState;
@@ -1563,8 +1564,8 @@
&& (mDataConnectionState[phoneId] != state
|| mDataConnectionNetworkType[phoneId] != networkType)) {
String str = "onDataConnectionStateChanged("
- + TelephonyManager.dataStateToString(state)
- + ", " + TelephonyManager.getNetworkTypeName(networkType)
+ + dataStateToString(state)
+ + ", " + getNetworkTypeName(networkType)
+ ") subId=" + subId + ", phoneId=" + phoneId;
log(str);
mLocalLog.log(str);
@@ -2676,4 +2677,73 @@
}
}
}
+
+ /**
+ * Convert data state to string
+ *
+ * @return The data state in string format.
+ */
+ private String dataStateToString(@TelephonyManager.DataState int state) {
+ switch (state) {
+ case TelephonyManager.DATA_DISCONNECTED: return "DISCONNECTED";
+ case TelephonyManager.DATA_CONNECTING: return "CONNECTING";
+ case TelephonyManager.DATA_CONNECTED: return "CONNECTED";
+ case TelephonyManager.DATA_SUSPENDED: return "SUSPENDED";
+ }
+ return "UNKNOWN(" + state + ")";
+ }
+
+ /**
+ * Returns a string representation of the radio technology (network type)
+ * currently in use on the device.
+ * @param subId for which network type is returned
+ * @return the name of the radio technology
+ *
+ */
+ private String getNetworkTypeName(@Annotation.NetworkType int type) {
+ switch (type) {
+ case TelephonyManager.NETWORK_TYPE_GPRS:
+ return "GPRS";
+ case TelephonyManager.NETWORK_TYPE_EDGE:
+ return "EDGE";
+ case TelephonyManager.NETWORK_TYPE_UMTS:
+ return "UMTS";
+ case TelephonyManager.NETWORK_TYPE_HSDPA:
+ return "HSDPA";
+ case TelephonyManager.NETWORK_TYPE_HSUPA:
+ return "HSUPA";
+ case TelephonyManager.NETWORK_TYPE_HSPA:
+ return "HSPA";
+ case TelephonyManager.NETWORK_TYPE_CDMA:
+ return "CDMA";
+ case TelephonyManager.NETWORK_TYPE_EVDO_0:
+ return "CDMA - EvDo rev. 0";
+ case TelephonyManager.NETWORK_TYPE_EVDO_A:
+ return "CDMA - EvDo rev. A";
+ case TelephonyManager.NETWORK_TYPE_EVDO_B:
+ return "CDMA - EvDo rev. B";
+ case TelephonyManager.NETWORK_TYPE_1xRTT:
+ return "CDMA - 1xRTT";
+ case TelephonyManager.NETWORK_TYPE_LTE:
+ return "LTE";
+ case TelephonyManager.NETWORK_TYPE_EHRPD:
+ return "CDMA - eHRPD";
+ case TelephonyManager.NETWORK_TYPE_IDEN:
+ return "iDEN";
+ case TelephonyManager.NETWORK_TYPE_HSPAP:
+ return "HSPA+";
+ case TelephonyManager.NETWORK_TYPE_GSM:
+ return "GSM";
+ case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
+ return "TD_SCDMA";
+ case TelephonyManager.NETWORK_TYPE_IWLAN:
+ return "IWLAN";
+ case TelephonyManager.NETWORK_TYPE_LTE_CA:
+ return "LTE_CA";
+ case TelephonyManager.NETWORK_TYPE_NR:
+ return "NR";
+ default:
+ return "UNKNOWN";
+ }
+ }
}
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 48f08e3..bae9680 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -61,6 +61,7 @@
import android.hardware.hdmi.HdmiTvClient;
import android.hardware.input.InputManager;
import android.hardware.usb.UsbManager;
+import android.hidl.manager.V1_0.IServiceManager;
import android.media.AudioAttributes;
import android.media.AudioFocusInfo;
import android.media.AudioFocusRequest;
@@ -148,10 +149,12 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
+import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -721,6 +724,8 @@
AudioSystem.setErrorCallback(mAudioSystemCallback);
+ updateAudioHalPids();
+
boolean cameraSoundForced = readCameraSoundForced();
mCameraSoundForced = new Boolean(cameraSoundForced);
sendMsg(mAudioHandler,
@@ -949,6 +954,8 @@
}
Log.e(TAG, "Audioserver started.");
+ updateAudioHalPids();
+
// indicate to audio HAL that we start the reconfiguration phase after a media
// server crash
// Note that we only execute this when the media server
@@ -7291,6 +7298,41 @@
}
//======================
+ // Audio HAL process dump
+ //======================
+
+ private static final String AUDIO_HAL_SERVICE_PREFIX = "android.hardware.audio";
+
+ private Set<Integer> getAudioHalPids() {
+ try {
+ IServiceManager serviceManager = IServiceManager.getService();
+ ArrayList<IServiceManager.InstanceDebugInfo> dump =
+ serviceManager.debugDump();
+ HashSet<Integer> pids = new HashSet<>();
+ for (IServiceManager.InstanceDebugInfo info : dump) {
+ if (info.pid != IServiceManager.PidConstant.NO_PID
+ && info.interfaceName != null
+ && info.interfaceName.startsWith(AUDIO_HAL_SERVICE_PREFIX)) {
+ pids.add(info.pid);
+ }
+ }
+ return pids;
+ } catch (RemoteException e) {
+ return new HashSet<Integer>();
+ }
+ }
+
+ private void updateAudioHalPids() {
+ Set<Integer> pidsSet = getAudioHalPids();
+ if (pidsSet.isEmpty()) {
+ Slog.w(TAG, "Could not retrieve audio HAL service pids");
+ return;
+ }
+ int[] pidsArray = pidsSet.stream().mapToInt(Integer::intValue).toArray();
+ AudioSystem.setAudioHalPids(pidsArray);
+ }
+
+ //======================
// misc
//======================
private final HashMap<IBinder, AudioPolicyProxy> mAudioPolicies =
diff --git a/services/core/java/com/android/server/compat/CompatChange.java b/services/core/java/com/android/server/compat/CompatChange.java
index 95582f7..2eec419 100644
--- a/services/core/java/com/android/server/compat/CompatChange.java
+++ b/services/core/java/com/android/server/compat/CompatChange.java
@@ -55,7 +55,7 @@
private Map<String, Boolean> mPackageOverrides;
public CompatChange(long changeId) {
- this(changeId, null, -1, false);
+ this(changeId, null, -1, false, null);
}
/**
@@ -66,8 +66,8 @@
* @param disabled If {@code true}, overrides any {@code enableAfterTargetSdk} set.
*/
public CompatChange(long changeId, @Nullable String name, int enableAfterTargetSdk,
- boolean disabled) {
- super(changeId, name, enableAfterTargetSdk, disabled);
+ boolean disabled, String description) {
+ super(changeId, name, enableAfterTargetSdk, disabled, description);
}
/**
@@ -75,7 +75,7 @@
*/
public CompatChange(Change change) {
super(change.getId(), change.getName(), change.getEnableAfterTargetSdk(),
- change.getDisabled());
+ change.getDisabled(), change.getDescription());
}
void registerListener(ChangeListener listener) {
diff --git a/services/core/java/com/android/server/compat/CompatConfig.java b/services/core/java/com/android/server/compat/CompatConfig.java
index 39c6e75..cf83dd6 100644
--- a/services/core/java/com/android/server/compat/CompatConfig.java
+++ b/services/core/java/com/android/server/compat/CompatConfig.java
@@ -319,7 +319,8 @@
changeInfos[i] = new CompatibilityChangeInfo(change.getId(),
change.getName(),
change.getEnableAfterTargetSdk(),
- change.getDisabled());
+ change.getDisabled(),
+ change.getDescription());
}
return changeInfos;
}
diff --git a/services/core/xsd/platform-compat-config.xsd b/services/core/xsd/platform-compat-config.xsd
index ee39e50..a70568f 100644
--- a/services/core/xsd/platform-compat-config.xsd
+++ b/services/core/xsd/platform-compat-config.xsd
@@ -28,6 +28,7 @@
<xs:attribute type="xs:string" name="name" use="required"/>
<xs:attribute type="xs:boolean" name="disabled"/>
<xs:attribute type="xs:int" name="enableAfterTargetSdk"/>
+ <xs:attribute type="xs:string" name="description"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
diff --git a/services/core/xsd/platform-compat-schema/current.txt b/services/core/xsd/platform-compat-schema/current.txt
index 8456785..3a33f63 100644
--- a/services/core/xsd/platform-compat-schema/current.txt
+++ b/services/core/xsd/platform-compat-schema/current.txt
@@ -3,11 +3,13 @@
public class Change {
ctor public Change();
+ method public String getDescription();
method public boolean getDisabled();
method public int getEnableAfterTargetSdk();
method public long getId();
method public String getName();
method public String getValue();
+ method public void setDescription(String);
method public void setDisabled(boolean);
method public void setEnableAfterTargetSdk(int);
method public void setId(long);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index e8617bc..127b8e0 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -135,6 +135,8 @@
import android.app.backup.IBackupManager;
import android.app.timedetector.ManualTimeSuggestion;
import android.app.timedetector.TimeDetector;
+import android.app.timezonedetector.ManualTimeZoneSuggestion;
+import android.app.timezonedetector.TimeZoneDetector;
import android.app.trust.TrustManager;
import android.app.usage.UsageStatsManagerInternal;
import android.content.ActivityNotFoundException;
@@ -1956,6 +1958,10 @@
return mContext.getSystemService(TimeDetector.class);
}
+ TimeZoneDetector getTimeZoneDetector() {
+ return mContext.getSystemService(TimeZoneDetector.class);
+ }
+
ConnectivityManager getConnectivityManager() {
return mContext.getSystemService(ConnectivityManager.class);
}
@@ -10880,8 +10886,11 @@
if (mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) == 1) {
return false;
}
+ ManualTimeZoneSuggestion manualTimeZoneSuggestion =
+ TimeZoneDetector.createManualTimeZoneSuggestion(
+ timeZone, "DevicePolicyManagerService: setTimeZone");
mInjector.binderWithCleanCallingIdentity(() ->
- mInjector.getAlarmManager().setTimeZone(timeZone));
+ mInjector.getTimeZoneDetector().suggestManualTimeZone(manualTimeZoneSuggestion));
return true;
}
diff --git a/services/net/java/android/net/ip/IpClientCallbacks.java b/services/net/java/android/net/ip/IpClientCallbacks.java
index db01ae4..61cd88a 100644
--- a/services/net/java/android/net/ip/IpClientCallbacks.java
+++ b/services/net/java/android/net/ip/IpClientCallbacks.java
@@ -17,8 +17,11 @@
package android.net.ip;
import android.net.DhcpResults;
+import android.net.Layer2PacketParcelable;
import android.net.LinkProperties;
+import java.util.List;
+
/**
* Callbacks for handling IpClient events.
*
@@ -116,4 +119,9 @@
* whenever 464xlat is being started or stopped.
*/
public void setNeighborDiscoveryOffload(boolean enable) {}
+
+ /**
+ * Invoked on starting preconnection process.
+ */
+ public void onPreconnectionStart(List<Layer2PacketParcelable> packets) {}
}
diff --git a/services/net/java/android/net/ip/IpClientManager.java b/services/net/java/android/net/ip/IpClientManager.java
index 1e653cd..4b7ed3c 100644
--- a/services/net/java/android/net/ip/IpClientManager.java
+++ b/services/net/java/android/net/ip/IpClientManager.java
@@ -234,7 +234,7 @@
slot, KeepalivePacketDataUtil.toStableParcelable(pkt));
return true;
} catch (RemoteException e) {
- log("Error adding Keepalive Packet Filter ", e);
+ log("Error adding NAT-T Keepalive Packet Filter ", e);
return false;
} finally {
Binder.restoreCallingIdentity(token);
@@ -272,4 +272,22 @@
Binder.restoreCallingIdentity(token);
}
}
+
+ /**
+ * Notify IpClient that preconnection is complete and that the link is ready for use.
+ * The success parameter indicates whether the packets passed in by 'onPreconnectionStart'
+ * were successfully sent to the network or not.
+ */
+ public boolean notifyPreconnectionComplete(boolean success) {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mIpClient.notifyPreconnectionComplete(success);
+ return true;
+ } catch (RemoteException e) {
+ log("Error notifying IpClient Preconnection completed", e);
+ return false;
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
}
diff --git a/services/net/java/android/net/ip/IpClientUtil.java b/services/net/java/android/net/ip/IpClientUtil.java
index 714ade1..4d60e62 100644
--- a/services/net/java/android/net/ip/IpClientUtil.java
+++ b/services/net/java/android/net/ip/IpClientUtil.java
@@ -20,12 +20,14 @@
import android.content.Context;
import android.net.DhcpResultsParcelable;
+import android.net.Layer2PacketParcelable;
import android.net.LinkProperties;
import android.net.NetworkStackClient;
import android.os.ConditionVariable;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.List;
/**
@@ -176,6 +178,12 @@
mCb.setNeighborDiscoveryOffload(enable);
}
+ // Invoked on starting preconnection process.
+ @Override
+ public void onPreconnectionStart(List<Layer2PacketParcelable> packets) {
+ mCb.onPreconnectionStart(packets);
+ }
+
@Override
public int getInterfaceVersion() {
return this.VERSION;
diff --git a/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java b/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java
index f8c87fc..7267976 100644
--- a/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java
+++ b/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java
@@ -73,36 +73,36 @@
@Test
public void testDisabledChangeDisabled() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, true));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, true, ""));
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.some.package", 1))).isFalse();
}
@Test
public void testTargetSdkChangeDisabled() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, false));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, false, null));
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.some.package", 2))).isFalse();
}
@Test
public void testTargetSdkChangeEnabled() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, false));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, false, ""));
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.some.package", 3))).isTrue();
}
@Test
public void testDisabledOverrideTargetSdkChange() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, true));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, true, null));
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.some.package", 3))).isFalse();
}
@Test
public void testGetDisabledChanges() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, true));
- pc.addChange(new CompatChange(2345L, "OTHER_CHANGE", -1, false));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, true, null));
+ pc.addChange(new CompatChange(2345L, "OTHER_CHANGE", -1, false, null));
assertThat(pc.getDisabledChanges(
makeAppInfo("com.some.package", 2))).asList().containsExactly(1234L);
}
@@ -110,9 +110,9 @@
@Test
public void testGetDisabledChangesSorted() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, true));
- pc.addChange(new CompatChange(123L, "OTHER_CHANGE", 2, true));
- pc.addChange(new CompatChange(12L, "THIRD_CHANGE", 2, true));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", 2, true, null));
+ pc.addChange(new CompatChange(123L, "OTHER_CHANGE", 2, true, null));
+ pc.addChange(new CompatChange(12L, "THIRD_CHANGE", 2, true, null));
assertThat(pc.getDisabledChanges(
makeAppInfo("com.some.package", 2))).asList().containsExactly(12L, 123L, 1234L);
}
@@ -120,7 +120,7 @@
@Test
public void testPackageOverrideEnabled() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, true)); // disabled
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, true, null)); // disabled
pc.addOverride(1234L, "com.some.package", true);
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.some.package", 2))).isTrue();
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.other.package", 2))).isFalse();
@@ -129,7 +129,7 @@
@Test
public void testPackageOverrideDisabled() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, false));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, false, null));
pc.addOverride(1234L, "com.some.package", false);
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.some.package", 2))).isFalse();
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.other.package", 2))).isTrue();
@@ -152,7 +152,7 @@
@Test
public void testRemovePackageOverride() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, false));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, false, null));
pc.addOverride(1234L, "com.some.package", false);
pc.removeOverride(1234L, "com.some.package");
assertThat(pc.isChangeEnabled(1234L, makeAppInfo("com.some.package", 2))).isTrue();
@@ -161,8 +161,8 @@
@Test
public void testLookupChangeId() {
CompatConfig pc = new CompatConfig();
- pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, false));
- pc.addChange(new CompatChange(2345L, "ANOTHER_CHANGE", -1, false));
+ pc.addChange(new CompatChange(1234L, "MY_CHANGE", -1, false, null));
+ pc.addChange(new CompatChange(2345L, "ANOTHER_CHANGE", -1, false, null));
assertThat(pc.lookupChangeId("MY_CHANGE")).isEqualTo(1234L);
}
@@ -174,8 +174,9 @@
@Test
public void testReadConfig() {
- Change[] changes = {new Change(1234L, "MY_CHANGE1", false, 2), new Change(1235L,
- "MY_CHANGE2", true, null), new Change(1236L, "MY_CHANGE3", false, null)};
+ Change[] changes = {new Change(1234L, "MY_CHANGE1", false, 2, null), new Change(1235L,
+ "MY_CHANGE2", true, null, "description"), new Change(1236L, "MY_CHANGE3", false,
+ null, "")};
File dir = createTempDir();
writeChangesToFile(changes, new File(dir.getPath() + "/platform_compat_config.xml"));
@@ -191,9 +192,9 @@
@Test
public void testReadConfigMultipleFiles() {
- Change[] changes1 = {new Change(1234L, "MY_CHANGE1", false, 2)};
- Change[] changes2 = {new Change(1235L, "MY_CHANGE2", true, null), new Change(1236L,
- "MY_CHANGE3", false, null)};
+ Change[] changes1 = {new Change(1234L, "MY_CHANGE1", false, 2, null)};
+ Change[] changes2 = {new Change(1235L, "MY_CHANGE2", true, null, ""), new Change(1236L,
+ "MY_CHANGE3", false, null, null)};
File dir = createTempDir();
writeChangesToFile(changes1,
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java
index 0fde850..0763aa2 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java
@@ -23,6 +23,7 @@
import android.app.PendingIntent;
import android.app.backup.IBackupManager;
import android.app.timedetector.TimeDetector;
+import android.app.timezonedetector.TimeZoneDetector;
import android.app.usage.UsageStatsManagerInternal;
import android.content.Context;
import android.content.Intent;
@@ -223,6 +224,11 @@
}
@Override
+ TimeZoneDetector getTimeZoneDetector() {
+ return services.timeZoneDetector;
+ }
+
+ @Override
LockPatternUtils newLockPatternUtils() {
return services.lockPatternUtils;
}
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index b93b47a..7c0afed 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -64,6 +64,8 @@
import android.app.admin.DevicePolicyManagerInternal;
import android.app.admin.PasswordMetrics;
import android.app.timedetector.ManualTimeSuggestion;
+import android.app.timezonedetector.ManualTimeZoneSuggestion;
+import android.app.timezonedetector.TimeZoneDetector;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Intent;
@@ -3506,7 +3508,9 @@
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
dpm.setTimeZone(admin1, "Asia/Shanghai");
- verify(getServices().alarmManager).setTimeZone("Asia/Shanghai");
+ ManualTimeZoneSuggestion suggestion =
+ TimeZoneDetector.createManualTimeZoneSuggestion("Asia/Shanghai", "Test debug info");
+ verify(getServices().timeZoneDetector).suggestManualTimeZone(suggestion);
}
public void testSetTimeZoneFailWithPO() throws Exception {
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
index b208f82..16d5db9 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
@@ -32,6 +32,7 @@
import android.app.NotificationManager;
import android.app.backup.IBackupManager;
import android.app.timedetector.TimeDetector;
+import android.app.timezonedetector.TimeZoneDetector;
import android.app.usage.UsageStatsManagerInternal;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
@@ -109,6 +110,7 @@
public final AccountManager accountManager;
public final AlarmManager alarmManager;
public final TimeDetector timeDetector;
+ public final TimeZoneDetector timeZoneDetector;
public final KeyChain.KeyChainConnection keyChainConnection;
/** Note this is a partial mock, not a real mock. */
public final PackageManager packageManager;
@@ -149,6 +151,7 @@
accountManager = mock(AccountManager.class);
alarmManager = mock(AlarmManager.class);
timeDetector = mock(TimeDetector.class);
+ timeZoneDetector = mock(TimeZoneDetector.class);
keyChainConnection = mock(KeyChain.KeyChainConnection.class, RETURNS_DEEP_STUBS);
// Package manager is huge, so we use a partial mock instead.
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index a0739c4..86ad795 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -291,7 +291,6 @@
*/
public static final int DIRECTION_OUTGOING = 1;
-
/** Call can currently be put on hold or unheld. */
public static final int CAPABILITY_HOLD = 0x00000001;
@@ -571,6 +570,7 @@
private final Bundle mIntentExtras;
private final long mCreationTimeMillis;
private final @CallDirection int mCallDirection;
+ private final @Connection.VerificationStatus int mCallerNumberVerificationStatus;
/**
* Whether the supplied capabilities supports the specified capability.
@@ -880,6 +880,15 @@
return mCallDirection;
}
+ /**
+ * Gets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * @return the verification status.
+ */
+ public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
@Override
public boolean equals(Object o) {
if (o instanceof Details) {
@@ -901,7 +910,9 @@
areBundlesEqual(mExtras, d.mExtras) &&
areBundlesEqual(mIntentExtras, d.mIntentExtras) &&
Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis) &&
- Objects.equals(mCallDirection, d.mCallDirection);
+ Objects.equals(mCallDirection, d.mCallDirection) &&
+ Objects.equals(mCallerNumberVerificationStatus,
+ d.mCallerNumberVerificationStatus);
}
return false;
}
@@ -923,7 +934,8 @@
mExtras,
mIntentExtras,
mCreationTimeMillis,
- mCallDirection);
+ mCallDirection,
+ mCallerNumberVerificationStatus);
}
/** {@hide} */
@@ -944,7 +956,8 @@
Bundle extras,
Bundle intentExtras,
long creationTimeMillis,
- int callDirection) {
+ int callDirection,
+ int callerNumberVerificationStatus) {
mTelecomCallId = telecomCallId;
mHandle = handle;
mHandlePresentation = handlePresentation;
@@ -962,6 +975,7 @@
mIntentExtras = intentExtras;
mCreationTimeMillis = creationTimeMillis;
mCallDirection = callDirection;
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
}
/** {@hide} */
@@ -983,7 +997,8 @@
parcelableCall.getExtras(),
parcelableCall.getIntentExtras(),
parcelableCall.getCreationTimeMillis(),
- parcelableCall.getCallDirection());
+ parcelableCall.getCallDirection(),
+ parcelableCall.getCallerNumberVerificationStatus());
}
@Override
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 4c22ba9..c063279 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -16,6 +16,7 @@
package android.telecom;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
@@ -35,9 +36,7 @@
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.SystemClock;
-import android.telephony.Annotation.RilRadioTechnology;
-import android.telephony.ServiceState;
-import android.telephony.TelephonyManager;
+import android.telephony.ims.ImsStreamMediaProfile;
import android.util.ArraySet;
import android.view.Surface;
@@ -50,6 +49,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.nio.channels.Channels;
import java.util.ArrayList;
import java.util.Arrays;
@@ -153,6 +154,32 @@
public static final int STATE_PULLING_CALL = 7;
/**
+ * Indicates that the network could not perform verification.
+ */
+ public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0;
+
+ /**
+ * Indicates that verification by the network passed. This indicates there is a high likelihood
+ * that the call originated from a valid source.
+ */
+ public static final int VERIFICATION_STATUS_PASSED = 1;
+
+ /**
+ * Indicates that verification by the network failed. This indicates there is a high likelihood
+ * that the call did not originate from a valid source.
+ */
+ public static final int VERIFICATION_STATUS_FAILED = 2;
+
+ /**@hide*/
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = "VERIFICATION_STATUS_", value = {
+ VERIFICATION_STATUS_NOT_VERIFIED,
+ VERIFICATION_STATUS_PASSED,
+ VERIFICATION_STATUS_FAILED
+ })
+ public @interface VerificationStatus {}
+
+ /**
* Connection can currently be put on hold or unheld. This is distinct from
* {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
* it does not at the moment support the function. This can be true while the call is in the
@@ -475,6 +502,52 @@
//**********************************************************************************************
/**
+ * Define IMS Audio Codec
+ */
+ // Current audio codec is NONE
+ public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
+ // Current audio codec is AMR
+ public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
+ // Current audio codec is AMR_WB
+ public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
+ // Current audio codec is QCELP13K
+ public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
+ // Current audio codec is EVRC
+ public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
+ // Current audio codec is EVRC_B
+ public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
+ // Current audio codec is EVRC_WB
+ public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
+ // Current audio codec is EVRC_NW
+ public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
+ // Current audio codec is GSM_EFR
+ public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
+ // Current audio codec is GSM_FR
+ public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
+ // Current audio codec is GSM_HR
+ public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
+ // Current audio codec is G711U
+ public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
+ // Current audio codec is G723
+ public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
+ // Current audio codec is G711A
+ public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
+ // Current audio codec is G722
+ public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
+ // Current audio codec is G711AB
+ public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
+ // Current audio codec is G729
+ public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
+ // Current audio codec is EVS_NB
+ public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
+ // Current audio codec is EVS_WB
+ public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
+ // Current audio codec is EVS_SWB
+ public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
+ // Current audio codec is EVS_FB
+ public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
+
+ /**
* Connection extra key used to store the last forwarded number associated with the current
* connection. Used to communicate to the user interface that the connection was forwarded via
* the specified number.
@@ -567,6 +640,13 @@
"android.telecom.extra.IS_RTT_AUDIO_PRESENT";
/**
+ * The audio codec in use for the current {@link Connection}, if known. Valid values include
+ * {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
+ */
+ public static final String EXTRA_AUDIO_CODEC =
+ "android.telecom.extra.AUDIO_CODEC";
+
+ /**
* Connection event used to inform Telecom that it should play the on hold tone. This is used
* to play a tone when the peer puts the current call on hold. Sent to Telecom via
* {@link #sendConnectionEvent(String, Bundle)}.
@@ -1803,6 +1883,12 @@
private Set<String> mPreviousExtraKeys;
/**
+ * The verification status for an incoming call's phone number.
+ */
+ private @VerificationStatus int mCallerNumberVerificationStatus;
+
+
+ /**
* Create a new Connection.
*/
public Connection() {}
@@ -3304,4 +3390,26 @@
public void setCallDirection(@Call.Details.CallDirection int callDirection) {
mCallDirection = callDirection;
}
+
+ /**
+ * Gets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * @return the verification status.
+ */
+ public @VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
+ /**
+ * Sets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * <p>
+ * This property can only be set at the time of creation of a {@link Connection} being returned
+ * by
+ * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
+ */
+ public void setCallerNumberVerificationStatus(
+ @VerificationStatus int callerNumberVerificationStatus) {
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
+ }
}
diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java
index 812b805..3a0494e 100644
--- a/telecomm/java/android/telecom/ConnectionService.java
+++ b/telecomm/java/android/telecom/ConnectionService.java
@@ -1621,7 +1621,8 @@
connection.getStatusHints(),
connection.getDisconnectCause(),
createIdList(connection.getConferenceables()),
- connection.getExtras()));
+ connection.getExtras(),
+ connection.getCallerNumberVerificationStatus()));
if (isIncoming && request.shouldShowIncomingCallUi() && isSelfManaged) {
// Tell ConnectionService to show its incoming call UX.
@@ -2156,7 +2157,8 @@
emptyList,
connection.getExtras(),
conferenceId,
- connection.getCallDirection());
+ connection.getCallDirection(),
+ Connection.VERIFICATION_STATUS_NOT_VERIFIED);
mAdapter.addExistingConnection(id, parcelableConnection);
}
}
diff --git a/telecomm/java/android/telecom/ParcelableCall.java b/telecomm/java/android/telecom/ParcelableCall.java
index fdc3243..a234bb0 100644
--- a/telecomm/java/android/telecom/ParcelableCall.java
+++ b/telecomm/java/android/telecom/ParcelableCall.java
@@ -16,7 +16,6 @@
package android.telecom;
-import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Build;
@@ -66,6 +65,7 @@
private final Bundle mExtras;
private final long mCreationTimeMillis;
private final int mCallDirection;
+ private final int mCallerNumberVerificationStatus;
public ParcelableCall(
String id,
@@ -94,7 +94,8 @@
Bundle intentExtras,
Bundle extras,
long creationTimeMillis,
- int callDirection) {
+ int callDirection,
+ int callerNumberVerificationStatus) {
mId = id;
mState = state;
mDisconnectCause = disconnectCause;
@@ -122,6 +123,7 @@
mExtras = extras;
mCreationTimeMillis = creationTimeMillis;
mCallDirection = callDirection;
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
}
/** The unique ID of the call. */
@@ -322,6 +324,15 @@
return mCallDirection;
}
+ /**
+ * Gets the verification status for the phone number of an incoming call as identified in
+ * ATIS-1000082.
+ * @return the verification status.
+ */
+ public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
/** Responsible for creating ParcelableCall objects for deserialized Parcels. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public static final @android.annotation.NonNull Parcelable.Creator<ParcelableCall> CREATOR =
@@ -360,6 +371,7 @@
ParcelableRttCall rttCall = source.readParcelable(classLoader);
long creationTimeMillis = source.readLong();
int callDirection = source.readInt();
+ int callerNumberVerificationStatus = source.readInt();
return new ParcelableCall(
id,
state,
@@ -387,7 +399,8 @@
intentExtras,
extras,
creationTimeMillis,
- callDirection);
+ callDirection,
+ callerNumberVerificationStatus);
}
@Override
@@ -433,6 +446,7 @@
destination.writeParcelable(mRttCall, 0);
destination.writeLong(mCreationTimeMillis);
destination.writeInt(mCallDirection);
+ destination.writeInt(mCallerNumberVerificationStatus);
}
@Override
diff --git a/telecomm/java/android/telecom/ParcelableConnection.java b/telecomm/java/android/telecom/ParcelableConnection.java
index 4734af6..2b9ce9b 100644
--- a/telecomm/java/android/telecom/ParcelableConnection.java
+++ b/telecomm/java/android/telecom/ParcelableConnection.java
@@ -54,6 +54,7 @@
private final Bundle mExtras;
private String mParentCallId;
private @Call.Details.CallDirection int mCallDirection;
+ private @Connection.VerificationStatus int mCallerNumberVerificationStatus;
/** @hide */
public ParcelableConnection(
@@ -77,12 +78,13 @@
List<String> conferenceableConnectionIds,
Bundle extras,
String parentCallId,
- @Call.Details.CallDirection int callDirection) {
+ @Call.Details.CallDirection int callDirection,
+ @Connection.VerificationStatus int callerNumberVerificationStatus) {
this(phoneAccount, state, capabilities, properties, supportedAudioRoutes, address,
addressPresentation, callerDisplayName, callerDisplayNamePresentation,
videoProvider, videoState, ringbackRequested, isVoipAudioMode, connectTimeMillis,
connectElapsedTimeMillis, statusHints, disconnectCause, conferenceableConnectionIds,
- extras);
+ extras, callerNumberVerificationStatus);
mParentCallId = parentCallId;
mCallDirection = callDirection;
}
@@ -107,7 +109,8 @@
StatusHints statusHints,
DisconnectCause disconnectCause,
List<String> conferenceableConnectionIds,
- Bundle extras) {
+ Bundle extras,
+ @Connection.VerificationStatus int callerNumberVerificationStatus) {
mPhoneAccount = phoneAccount;
mState = state;
mConnectionCapabilities = capabilities;
@@ -129,6 +132,7 @@
mExtras = extras;
mParentCallId = null;
mCallDirection = Call.Details.DIRECTION_UNKNOWN;
+ mCallerNumberVerificationStatus = callerNumberVerificationStatus;
}
public PhoneAccountHandle getPhoneAccount() {
@@ -227,6 +231,10 @@
return mCallDirection;
}
+ public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
+ return mCallerNumberVerificationStatus;
+ }
+
@Override
public String toString() {
return new StringBuilder()
@@ -276,6 +284,7 @@
String parentCallId = source.readString();
long connectElapsedTimeMillis = source.readLong();
int callDirection = source.readInt();
+ int callerNumberVerificationStatus = source.readInt();
return new ParcelableConnection(
phoneAccount,
@@ -298,7 +307,8 @@
conferenceableConnectionIds,
extras,
parentCallId,
- callDirection);
+ callDirection,
+ callerNumberVerificationStatus);
}
@Override
@@ -338,5 +348,6 @@
destination.writeString(mParentCallId);
destination.writeLong(mConnectElapsedTimeMillis);
destination.writeInt(mCallDirection);
+ destination.writeInt(mCallerNumberVerificationStatus);
}
}
diff --git a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
similarity index 90%
rename from telephony/java/com/android/internal/telephony/TelephonyPermissions.java
rename to telephony/common/com/android/internal/telephony/TelephonyPermissions.java
index 8a852ee..606fd5b 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java
+++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
@@ -150,6 +150,27 @@
return false;
}
+ /**
+ * Check whether the app with the given pid/uid can read phone state.
+ *
+ * <p>This method behaves in one of the following ways:
+ * <ul>
+ * <li>return true: if the caller has the READ_PRIVILEGED_PHONE_STATE permission, the
+ * READ_PHONE_STATE runtime permission, or carrier privileges on the given subId.
+ * <li>throw SecurityException: if the caller didn't declare any of these permissions, or, for
+ * apps which support runtime permissions, if the caller does not currently have any of
+ * these permissions.
+ * <li>return false: if the caller lacks all of these permissions and doesn't support runtime
+ * permissions. This implies that the user revoked the ability to read phone state
+ * manually (via AppOps). In this case we can't throw as it would break app compatibility,
+ * so we return false to indicate that the calling function should return dummy data.
+ * </ul>
+ *
+ * <p>Note: for simplicity, this method always returns false for callers using legacy
+ * permissions and who have had READ_PHONE_STATE revoked, even if they are carrier-privileged.
+ * Such apps should migrate to runtime permissions or stop requiring READ_PHONE_STATE on P+
+ * devices.
+ */
@VisibleForTesting
public static boolean checkReadPhoneState(
Context context, Supplier<ITelephony> telephonySupplier, int subId, int pid, int uid,
@@ -202,6 +223,20 @@
callingPackage, message);
}
+ /**
+ * Check whether the app with the given pid/uid can read phone state, or has carrier
+ * privileges on any active subscription.
+ *
+ * <p>If the app does not have carrier privilege, this method will return {@code false} instead
+ * of throwing a SecurityException. Therefore, the callers cannot tell the difference
+ * between M+ apps which declare the runtime permission but do not have it, and pre-M apps
+ * which declare the static permission but had access revoked via AppOps. Apps in the former
+ * category expect SecurityExceptions; apps in the latter don't. So this method is suitable for
+ * use only if the behavior in both scenarios is meant to be identical.
+ *
+ * @return {@code true} if the app can read phone state or has carrier privilege;
+ * {@code false} otherwise.
+ */
@VisibleForTesting
public static boolean checkReadPhoneStateOnAnyActiveSub(
Context context, Supplier<ITelephony> telephonySupplier, int pid, int uid,
@@ -449,6 +484,11 @@
context, TELEPHONY_SUPPLIER, subId, pid, uid, callingPackage);
}
+ /**
+ * Check whether the app with the given pid/uid can read the call log.
+ * @return {@code true} if the specified app has the read call log permission and AppOpp granted
+ * to it, {@code false} otherwise.
+ */
@VisibleForTesting
public static boolean checkReadCallLog(
Context context, Supplier<ITelephony> telephonySupplier, int subId, int pid, int uid,
@@ -485,6 +525,12 @@
callingPackage, message);
}
+ /**
+ * Returns whether the caller can read phone numbers.
+ *
+ * <p>Besides apps with the ability to read phone state per {@link #checkReadPhoneState}, the
+ * default SMS app and apps with READ_SMS or READ_PHONE_NUMBERS can also read phone numbers.
+ */
@VisibleForTesting
public static boolean checkReadPhoneNumber(
Context context, Supplier<ITelephony> telephonySupplier, int subId, int pid, int uid,
@@ -523,10 +569,10 @@
} catch (SecurityException readPhoneNumberSecurityException) {
}
- throw new SecurityException(message + ": Neither user " + uid +
- " nor current process has " + android.Manifest.permission.READ_PHONE_STATE +
- ", " + android.Manifest.permission.READ_SMS + ", or " +
- android.Manifest.permission.READ_PHONE_NUMBERS);
+ throw new SecurityException(message + ": Neither user " + uid
+ + " nor current process has " + android.Manifest.permission.READ_PHONE_STATE
+ + ", " + android.Manifest.permission.READ_SMS + ", or "
+ + android.Manifest.permission.READ_PHONE_NUMBERS);
}
/**
@@ -537,8 +583,8 @@
*/
public static void enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
Context context, int subId, String message) {
- if (context.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) ==
- PERMISSION_GRANTED) {
+ if (context.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ == PERMISSION_GRANTED) {
return;
}
@@ -580,8 +626,8 @@
}
if (DBG) {
- Rlog.d(LOG_TAG, "No READ_PRIVILEDED_PHONE_STATE permission, " +
- "check carrier privilege next.");
+ Rlog.d(LOG_TAG, "No READ_PRIVILEDED_PHONE_STATE permission, "
+ + "check carrier privilege next.");
}
enforceCallingOrSelfCarrierPrivilege(subId, message);
@@ -606,8 +652,8 @@
private static void enforceCarrierPrivilege(
Supplier<ITelephony> telephonySupplier, int subId, int uid, String message) {
- if (getCarrierPrivilegeStatus(telephonySupplier, subId, uid) !=
- TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
+ if (getCarrierPrivilegeStatus(telephonySupplier, subId, uid)
+ != TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
if (DBG) Rlog.e(LOG_TAG, "No Carrier Privilege.");
throw new SecurityException(message);
}
diff --git a/telephony/java/android/telephony/AccessNetworkConstants.java b/telephony/java/android/telephony/AccessNetworkConstants.java
index a0aa60b..bb28df2 100644
--- a/telephony/java/android/telephony/AccessNetworkConstants.java
+++ b/telephony/java/android/telephony/AccessNetworkConstants.java
@@ -80,6 +80,7 @@
public static final int EUTRAN = 3;
public static final int CDMA2000 = 4;
public static final int IWLAN = 5;
+ public static final int NGRAN = 6;
/** @hide */
private AccessNetworkType() {}
@@ -93,6 +94,7 @@
case EUTRAN: return "EUTRAN";
case CDMA2000: return "CDMA2000";
case IWLAN: return "IWLAN";
+ case NGRAN: return "NGRAN";
default: return Integer.toString(type);
}
}
@@ -247,6 +249,61 @@
private CdmaBands() {};
}
+ /**
+ * Frequency bands for NGRAN
+ */
+ public static final class NgranBands {
+ /** FR1 bands */
+ public static final int BAND_1 = 1;
+ public static final int BAND_2 = 2;
+ public static final int BAND_3 = 3;
+ public static final int BAND_5 = 5;
+ public static final int BAND_7 = 7;
+ public static final int BAND_8 = 8;
+ public static final int BAND_12 = 12;
+ public static final int BAND_14 = 14;
+ public static final int BAND_18 = 18;
+ public static final int BAND_20 = 20;
+ public static final int BAND_25 = 25;
+ public static final int BAND_28 = 28;
+ public static final int BAND_29 = 29;
+ public static final int BAND_30 = 30;
+ public static final int BAND_34 = 34;
+ public static final int BAND_38 = 38;
+ public static final int BAND_39 = 39;
+ public static final int BAND_40 = 40;
+ public static final int BAND_41 = 41;
+ public static final int BAND_48 = 48;
+ public static final int BAND_50 = 50;
+ public static final int BAND_51 = 51;
+ public static final int BAND_65 = 65;
+ public static final int BAND_66 = 66;
+ public static final int BAND_70 = 70;
+ public static final int BAND_71 = 71;
+ public static final int BAND_74 = 74;
+ public static final int BAND_75 = 75;
+ public static final int BAND_76 = 76;
+ public static final int BAND_77 = 77;
+ public static final int BAND_78 = 78;
+ public static final int BAND_79 = 79;
+ public static final int BAND_80 = 80;
+ public static final int BAND_81 = 81;
+ public static final int BAND_82 = 82;
+ public static final int BAND_83 = 83;
+ public static final int BAND_84 = 84;
+ public static final int BAND_86 = 86;
+ public static final int BAND_90 = 90;
+
+ /** FR2 bands */
+ public static final int BAND_257 = 257;
+ public static final int BAND_258 = 258;
+ public static final int BAND_260 = 260;
+ public static final int BAND_261 = 261;
+
+ /** @hide */
+ private NgranBands() {};
+ }
+
/** @hide */
private AccessNetworkConstants() {};
}
diff --git a/telephony/java/android/telephony/Annotation.java b/telephony/java/android/telephony/Annotation.java
index 72f758e..f89bbc7 100644
--- a/telephony/java/android/telephony/Annotation.java
+++ b/telephony/java/android/telephony/Annotation.java
@@ -1,6 +1,7 @@
package android.telephony;
import android.annotation.IntDef;
+import android.telecom.Connection;
import android.telephony.data.ApnSetting;
import java.lang.annotation.Retention;
@@ -509,4 +510,30 @@
ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA,
ServiceState.RIL_RADIO_TECHNOLOGY_NR})
public @interface RilRadioTechnology {}
+
+ @IntDef({
+ Connection.AUDIO_CODEC_NONE,
+ Connection.AUDIO_CODEC_AMR,
+ Connection.AUDIO_CODEC_AMR_WB,
+ Connection.AUDIO_CODEC_QCELP13K,
+ Connection.AUDIO_CODEC_EVRC,
+ Connection.AUDIO_CODEC_EVRC_B,
+ Connection.AUDIO_CODEC_EVRC_WB,
+ Connection.AUDIO_CODEC_EVRC_NW,
+ Connection.AUDIO_CODEC_GSM_EFR,
+ Connection.AUDIO_CODEC_GSM_FR,
+ Connection.AUDIO_CODEC_G711U,
+ Connection.AUDIO_CODEC_G723,
+ Connection.AUDIO_CODEC_G711A,
+ Connection.AUDIO_CODEC_G722,
+ Connection.AUDIO_CODEC_G711AB,
+ Connection.AUDIO_CODEC_G729,
+ Connection.AUDIO_CODEC_EVS_NB,
+ Connection.AUDIO_CODEC_EVS_WB,
+ Connection.AUDIO_CODEC_EVS_SWB,
+ Connection.AUDIO_CODEC_EVS_FB
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ImsAudioCodec {
+ }
}
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 78ba5b0..92c6e93 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -1049,6 +1049,9 @@
*
* When {@code false}, the old behavior is used, where the toggle in accessibility settings is
* used to set the IMS stack's RTT enabled state.
+ *
+ * @deprecated -- this flag no longer does anything. Remove once the new behavior is verified.
+ *
* @hide
*/
public static final String KEY_IGNORE_RTT_MODE_SETTING_BOOL =
@@ -3478,7 +3481,7 @@
sDefaults.putInt(KEY_IMS_DTMF_TONE_DELAY_INT, 0);
sDefaults.putInt(KEY_CDMA_DTMF_TONE_DELAY_INT, 100);
sDefaults.putBoolean(KEY_CALL_FORWARDING_MAP_NON_NUMBER_TO_VOICEMAIL_BOOL, false);
- sDefaults.putBoolean(KEY_IGNORE_RTT_MODE_SETTING_BOOL, false);
+ sDefaults.putBoolean(KEY_IGNORE_RTT_MODE_SETTING_BOOL, true);
sDefaults.putInt(KEY_CDMA_3WAYCALL_FLASH_DELAY_INT , 0);
sDefaults.putBoolean(KEY_SUPPORT_CONFERENCE_CALL_BOOL, true);
sDefaults.putBoolean(KEY_SUPPORT_IMS_CONFERENCE_CALL_BOOL, true);
diff --git a/telephony/java/android/telephony/CellSignalStrength.java b/telephony/java/android/telephony/CellSignalStrength.java
index e65b048ec..cb8fdf0 100644
--- a/telephony/java/android/telephony/CellSignalStrength.java
+++ b/telephony/java/android/telephony/CellSignalStrength.java
@@ -46,11 +46,6 @@
protected static final int NUM_SIGNAL_STRENGTH_THRESHOLDS = NUM_SIGNAL_STRENGTH_BINS - 1;
/** @hide */
- public static final String[] SIGNAL_STRENGTH_NAMES = {
- "none", "poor", "moderate", "good", "great"
- };
-
- /** @hide */
protected CellSignalStrength() {
}
@@ -157,4 +152,12 @@
if ((value < rangeMin || value > rangeMax) && value != special) return CellInfo.UNAVAILABLE;
return value;
}
+
+ /**
+ * Returns the number of signal strength levels.
+ * @return Number of signal strength levels, enforced to be 5
+ */
+ public static final int getNumSignalStrengthLevels() {
+ return NUM_SIGNAL_STRENGTH_BINS;
+ }
}
diff --git a/telephony/java/android/telephony/RadioAccessSpecifier.java b/telephony/java/android/telephony/RadioAccessSpecifier.java
index 690e44a..a403095 100644
--- a/telephony/java/android/telephony/RadioAccessSpecifier.java
+++ b/telephony/java/android/telephony/RadioAccessSpecifier.java
@@ -97,8 +97,9 @@
* Returns the frequency bands that need to be scanned.
*
* The returned value is defined in either of {@link AccessNetworkConstants.GeranBand},
- * {@link AccessNetworkConstants.UtranBand} and {@link AccessNetworkConstants.EutranBand}, and
- * it depends on the returned value of {@link #getRadioAccessNetwork()}.
+ * {@link AccessNetworkConstants.UtranBand}, {@link AccessNetworkConstants.EutranBand},
+ * and {@link AccessNetworkConstants.NgranBands}, and it depends on
+ * the returned value of {@link #getRadioAccessNetwork()}.
*/
public int[] getBands() {
return mBands == null ? null : mBands.clone();
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index 480c9d9..9aafc1b 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -60,12 +60,6 @@
@UnsupportedAppUsage
public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
- /** SIGNAL_STRENGTH_NAMES is currently used by BatteryStats, but to-be-removed soon. */
- /** @hide */
- public static final String[] SIGNAL_STRENGTH_NAMES = {
- "none", "poor", "moderate", "good", "great"
- };
-
/**
* Indicates the invalid measures of signal strength.
*
diff --git a/tools/processors/unsupportedappusage/Android.bp b/tools/processors/unsupportedappusage/Android.bp
deleted file mode 100644
index 1e96234..0000000
--- a/tools/processors/unsupportedappusage/Android.bp
+++ /dev/null
@@ -1,34 +0,0 @@
-
-java_library_host {
- name: "unsupportedappusage-annotation-processor-lib",
- srcs: [
- "src/**/*.java",
- ],
- static_libs: [
- "guava",
- "unsupportedappusage-annotation"
- ],
- openjdk9: {
- javacflags: [
- "--add-modules=jdk.compiler",
- "--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
- "--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
- "--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
- "--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
- ],
- },
-}
-
-java_plugin {
- name: "unsupportedappusage-annotation-processor",
- processor_class: "android.processor.unsupportedappusage.UnsupportedAppUsageProcessor",
-
- java_resources: [
- "META-INF/**/*",
- ],
- static_libs: [
- "unsupportedappusage-annotation-processor-lib"
- ],
-
- use_tools_jar: true,
-}
diff --git a/tools/processors/unsupportedappusage/META-INF/services/javax.annotation.processing.Processor b/tools/processors/unsupportedappusage/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index 4a969d3..0000000
--- a/tools/processors/unsupportedappusage/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-android.processor.unsupportedappusage.UnsupportedAppUsageProcessor
diff --git a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SignatureBuilder.java b/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SignatureBuilder.java
deleted file mode 100644
index 65fc733..0000000
--- a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SignatureBuilder.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.processor.unsupportedappusage;
-
-import static javax.lang.model.element.ElementKind.PACKAGE;
-import static javax.tools.Diagnostic.Kind.ERROR;
-import static javax.tools.Diagnostic.Kind.WARNING;
-
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
-import com.sun.tools.javac.code.Type;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.processing.Messager;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.ArrayType;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-
-/**
- * Builds a dex signature for a given method or field.
- */
-public class SignatureBuilder {
-
- private static final Map<TypeKind, String> TYPE_MAP = ImmutableMap.<TypeKind, String>builder()
- .put(TypeKind.BOOLEAN, "Z")
- .put(TypeKind.BYTE, "B")
- .put(TypeKind.CHAR, "C")
- .put(TypeKind.DOUBLE, "D")
- .put(TypeKind.FLOAT, "F")
- .put(TypeKind.INT, "I")
- .put(TypeKind.LONG, "J")
- .put(TypeKind.SHORT, "S")
- .put(TypeKind.VOID, "V")
- .build();
-
- private final Messager mMessager;
-
- /**
- * Exception used internally when we can't build a signature. Whenever this is thrown, an error
- * will also be written to the Messager.
- */
- private class SignatureBuilderException extends Exception {
- public SignatureBuilderException(String message) {
- super(message);
- }
-
- public void report(Element offendingElement) {
- mMessager.printMessage(ERROR, getMessage(), offendingElement);
- }
- }
-
- public SignatureBuilder(Messager messager) {
- mMessager = messager;
- }
-
- /**
- * Returns a list of enclosing elements for the given element, with the package first, and
- * excluding the element itself.
- */
- private List<Element> getEnclosingElements(Element e) {
- List<Element> enclosing = new ArrayList<>();
- e = e.getEnclosingElement(); // don't include the element itself.
- while (e != null) {
- enclosing.add(e);
- e = e.getEnclosingElement();
- }
- Collections.reverse(enclosing);
- return enclosing;
- }
-
- /**
- * Get the dex signature for a clazz, in format "Lpackage/name/Outer$Inner;"
- */
- private String getClassSignature(TypeElement clazz) {
- StringBuilder sb = new StringBuilder("L");
- for (Element enclosing : getEnclosingElements(clazz)) {
- switch (enclosing.getKind()) {
- case MODULE:
- // ignore this.
- break;
- case PACKAGE:
- sb.append(((PackageElement) enclosing)
- .getQualifiedName()
- .toString()
- .replace('.', '/'));
- sb.append('/');
- break;
- default:
- sb.append(enclosing.getSimpleName()).append('$');
- break;
- }
-
- }
- return sb
- .append(clazz.getSimpleName())
- .append(";")
- .toString();
- }
-
- /**
- * Returns the type signature for a given type. For primitive types, a single character.
- * For classes, the class signature. For arrays, a "[" preceeding the component type.
- */
- private String getTypeSignature(TypeMirror type) throws SignatureBuilderException {
- String sig = TYPE_MAP.get(type.getKind());
- if (sig != null) {
- return sig;
- }
- switch (type.getKind()) {
- case ARRAY:
- return "[" + getTypeSignature(((ArrayType) type).getComponentType());
- case DECLARED:
- Element declaring = ((DeclaredType) type).asElement();
- if (!(declaring instanceof TypeElement)) {
- throw new SignatureBuilderException(
- "Can't handle declared type of kind " + declaring.getKind());
- }
- return getClassSignature((TypeElement) declaring);
- case TYPEVAR:
- Type.TypeVar typeVar = (Type.TypeVar) type;
- if (typeVar.getLowerBound().getKind() != TypeKind.NULL) {
- return getTypeSignature(typeVar.getLowerBound());
- } else if (typeVar.getUpperBound().getKind() != TypeKind.NULL) {
- return getTypeSignature(typeVar.getUpperBound());
- } else {
- throw new SignatureBuilderException("Can't handle typevar with no bound");
- }
-
- default:
- throw new SignatureBuilderException("Can't handle type of kind " + type.getKind());
- }
- }
-
- /**
- * Get the signature for an executable, either a method or a constructor.
- *
- * @param name "<init>" for constructor, else the method name
- * @param method The executable element in question.
- */
- private String getExecutableSignature(CharSequence name, ExecutableElement method)
- throws SignatureBuilderException {
- StringBuilder sig = new StringBuilder();
- sig.append(getClassSignature((TypeElement) method.getEnclosingElement()))
- .append("->")
- .append(name)
- .append("(");
- for (VariableElement param : method.getParameters()) {
- sig.append(getTypeSignature(param.asType()));
- }
- sig.append(")")
- .append(getTypeSignature(method.getReturnType()));
- return sig.toString();
- }
-
- private String buildMethodSignature(ExecutableElement method) throws SignatureBuilderException {
- return getExecutableSignature(method.getSimpleName(), method);
- }
-
- private String buildConstructorSignature(ExecutableElement cons)
- throws SignatureBuilderException {
- return getExecutableSignature("<init>", cons);
- }
-
- private String buildFieldSignature(VariableElement field) throws SignatureBuilderException {
- StringBuilder sig = new StringBuilder();
- sig.append(getClassSignature((TypeElement) field.getEnclosingElement()))
- .append("->")
- .append(field.getSimpleName())
- .append(":")
- .append(getTypeSignature(field.asType()))
- ;
- return sig.toString();
- }
-
- /**
- * Creates the signature for an annotated element.
- *
- * @param annotationType type of annotation being processed.
- * @param element element for which we want to create a signature.
- */
- public String buildSignature(Class<? extends Annotation> annotationType, Element element) {
- try {
- String signature;
- switch (element.getKind()) {
- case METHOD:
- signature = buildMethodSignature((ExecutableElement) element);
- break;
- case CONSTRUCTOR:
- signature = buildConstructorSignature((ExecutableElement) element);
- break;
- case FIELD:
- signature = buildFieldSignature((VariableElement) element);
- break;
- default:
- return null;
- }
- // Obtain annotation objects
- Annotation annotation = element.getAnnotation(annotationType);
- if (annotation == null) {
- throw new IllegalStateException(
- "Element doesn't have any UnsupportedAppUsage annotation");
- }
- try {
- Method expectedSignatureMethod = annotationType.getMethod("expectedSignature");
- // If we have an expected signature on the annotation, warn if it doesn't match.
- String expectedSignature = expectedSignatureMethod.invoke(annotation).toString();
- if (!Strings.isNullOrEmpty(expectedSignature)) {
- if (!signature.equals(expectedSignature)) {
- mMessager.printMessage(
- WARNING,
- String.format(
- "Expected signature doesn't match generated signature.\n"
- + " Expected: %s\n Generated: %s",
- expectedSignature, signature),
- element);
- }
- }
- return signature;
- } catch (NoSuchMethodException e) {
- throw new IllegalStateException(
- "Annotation type does not have expectedSignature parameter", e);
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new IllegalStateException(
- "Could not get expectedSignature parameter for annotation", e);
- }
- } catch (SignatureBuilderException problem) {
- problem.report(element);
- return null;
- }
- }
-}
diff --git a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SourcePosition.java b/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SourcePosition.java
deleted file mode 100644
index 4ae093c..0000000
--- a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SourcePosition.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.processor.unsupportedappusage;
-
-/**
- * Represents a source position within a source file
- */
-public class SourcePosition {
- public final String filename;
- public final int startLine;
- public final int startCol;
- public final int endLine;
- public final int endCol;
-
- public SourcePosition(String filename, int startLine, int startCol, int endLine, int endCol) {
- this.filename = filename;
- this.startLine = startLine;
- this.startCol = startCol;
- this.endLine = endLine;
- this.endCol = endCol;
- }
-}
diff --git a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessor.java b/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessor.java
deleted file mode 100644
index ca2c275..0000000
--- a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessor.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.processor.unsupportedappusage;
-
-import static javax.tools.StandardLocation.CLASS_OUTPUT;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableSet;
-import com.sun.tools.javac.model.JavacElements;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.util.Pair;
-import com.sun.tools.javac.util.Position;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.lang.annotation.Annotation;
-import java.net.URLEncoder;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.stream.Stream;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-
-/**
- * Annotation processor for {@link UnsupportedAppUsage} annotations.
- *
- * This processor currently outputs a CSV file with a mapping of dex signatures to corresponding
- * source positions.
- *
- * This is used for automating updates to the annotations themselves.
- */
-@SupportedAnnotationTypes({"android.annotation.UnsupportedAppUsage",
- "dalvik.annotation.compat.UnsupportedAppUsage"
-})
-public class UnsupportedAppUsageProcessor extends AbstractProcessor {
-
- // Package name for writing output. Output will be written to the "class output" location within
- // this package.
- private static final String PACKAGE = "unsupportedappusage";
- private static final String INDEX_CSV = "unsupportedappusage_index.csv";
-
- private static final ImmutableSet<Class<? extends Annotation>> SUPPORTED_ANNOTATIONS =
- ImmutableSet.of(android.annotation.UnsupportedAppUsage.class,
- dalvik.annotation.compat.UnsupportedAppUsage.class);
- private static final ImmutableSet<String> SUPPORTED_ANNOTATION_NAMES =
- SUPPORTED_ANNOTATIONS.stream().map(annotation -> annotation.getCanonicalName()).collect(
- ImmutableSet.toImmutableSet());
- private static final String OVERRIDE_SOURCE_POSITION_PROPERTY = "overrideSourcePosition";
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- /**
- * Write the contents of a stream to a text file, with one line per item.
- */
- private void writeToFile(String name,
- String headerLine,
- Stream<?> contents) throws IOException {
- PrintStream out = new PrintStream(processingEnv.getFiler().createResource(
- CLASS_OUTPUT,
- PACKAGE,
- name)
- .openOutputStream());
- out.println(headerLine);
- contents.forEach(o -> out.println(o));
- if (out.checkError()) {
- throw new IOException("Error when writing to " + name);
- }
- out.close();
- }
-
- /**
- * Find the annotation mirror for the @UnsupportedAppUsage annotation on the given element.
- */
- private AnnotationMirror getUnsupportedAppUsageAnnotationMirror(Element e) {
- for (AnnotationMirror m : e.getAnnotationMirrors()) {
- TypeElement type = (TypeElement) m.getAnnotationType().asElement();
- if (SUPPORTED_ANNOTATION_NAMES.contains(type.getQualifiedName().toString())) {
- return m;
- }
- }
- return null;
- }
-
- /**
- * Returns a CSV header line for the columns returned by
- * {@link #getAnnotationIndex(String, Element)}.
- */
- private String getCsvHeaders() {
- return Joiner.on(',').join(
- "signature",
- "file",
- "startline",
- "startcol",
- "endline",
- "endcol",
- "properties"
- );
- }
-
- private String encodeAnnotationProperties(AnnotationMirror annotation) {
- StringBuilder sb = new StringBuilder();
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> e
- : annotation.getElementValues().entrySet()) {
- if (e.getKey().getSimpleName().toString().equals(OVERRIDE_SOURCE_POSITION_PROPERTY)) {
- continue;
- }
- if (sb.length() > 0) {
- sb.append("&");
- }
- sb.append(e.getKey().getSimpleName())
- .append("=")
- .append(URLEncoder.encode(e.getValue().toString()));
- }
- return sb.toString();
- }
-
- private SourcePosition getSourcePositionOverride(
- Element annotatedElement, AnnotationMirror annotation) {
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> e
- : annotation.getElementValues().entrySet()) {
- if (e.getKey().getSimpleName().toString().equals(OVERRIDE_SOURCE_POSITION_PROPERTY)) {
- String[] position = e.getValue().getValue().toString().split(":");
- if (position.length != 5) {
- processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, String.format(
- "Expected %s to have format file:startLine:startCol:endLine:endCol",
- OVERRIDE_SOURCE_POSITION_PROPERTY), annotatedElement, annotation);
- return null;
- }
- try {
- return new SourcePosition(position[0], Integer.parseInt(position[1]),
- Integer.parseInt(position[2]), Integer.parseInt(position[3]),
- Integer.parseInt(position[4]));
- } catch (NumberFormatException nfe) {
- processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, String.format(
- "Expected %s to have format file:startLine:startCol:endLine:endCol; "
- + "error parsing integer: %s", OVERRIDE_SOURCE_POSITION_PROPERTY,
- nfe.getMessage()), annotatedElement, annotation);
- return null;
- }
- }
- }
- return null;
- }
-
- /**
- * Maps an annotated element to the source position of the @UnsupportedAppUsage annotation
- * attached to it. It returns CSV in the format:
- * dex-signature,filename,start-line,start-col,end-line,end-col
- *
- * The positions refer to the annotation itself, *not* the annotated member. This can therefore
- * be used to read just the annotation from the file, and to perform in-place edits on it.
- *
- * @param signature the dex signature for the element.
- * @param annotatedElement The annotated element
- * @return A single line of CSV text
- */
- private String getAnnotationIndex(String signature, Element annotatedElement) {
- JavacElements javacElem = (JavacElements) processingEnv.getElementUtils();
- AnnotationMirror unsupportedAppUsage =
- getUnsupportedAppUsageAnnotationMirror(annotatedElement);
- SourcePosition position = getSourcePositionOverride(annotatedElement, unsupportedAppUsage);
- if (position == null) {
- Pair<JCTree, JCTree.JCCompilationUnit> pair =
- javacElem.getTreeAndTopLevel(annotatedElement, unsupportedAppUsage, null);
- Position.LineMap lines = pair.snd.lineMap;
- position = new SourcePosition(
- pair.snd.getSourceFile().getName(),
- lines.getLineNumber(pair.fst.pos().getStartPosition()),
- lines.getColumnNumber(pair.fst.pos().getStartPosition()),
- lines.getLineNumber(pair.fst.pos().getEndPosition(pair.snd.endPositions)),
- lines.getColumnNumber(pair.fst.pos().getEndPosition(pair.snd.endPositions)));
- }
- return Joiner.on(",").join(
- signature,
- position.filename,
- position.startLine,
- position.startCol,
- position.endLine,
- position.endCol,
- encodeAnnotationProperties(unsupportedAppUsage));
- }
-
- /**
- * This is the main entry point in the processor, called by the compiler.
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- Map<String, Element> signatureMap = new TreeMap<>();
- SignatureBuilder sb = new SignatureBuilder(processingEnv.getMessager());
- for (Class<? extends Annotation> supportedAnnotation : SUPPORTED_ANNOTATIONS) {
- Set<? extends Element> annotated = roundEnv.getElementsAnnotatedWith(
- supportedAnnotation);
- if (annotated.size() == 0) {
- continue;
- }
- // Build signatures for each annotated member and put them in a map from signature to
- // member.
- for (Element e : annotated) {
- String sig = sb.buildSignature(supportedAnnotation, e);
- if (sig != null) {
- signatureMap.put(sig, e);
- }
- }
- }
-
- if (!signatureMap.isEmpty()) {
- try {
- writeToFile(INDEX_CSV,
- getCsvHeaders(),
- signatureMap.entrySet()
- .stream()
- .map(e -> getAnnotationIndex(e.getKey(), e.getValue())));
- } catch (IOException e) {
- throw new RuntimeException("Failed to write output", e);
- }
- }
- return true;
- }
-}
diff --git a/tools/processors/unsupportedappusage/test/Android.bp b/tools/processors/unsupportedappusage/test/Android.bp
deleted file mode 100644
index e10fd47..0000000
--- a/tools/processors/unsupportedappusage/test/Android.bp
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 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.
-
-java_test_host {
- name: "unsupportedappusage-processor-test",
-
- srcs: ["src/**/*.java"],
-
- static_libs: [
- "compile-testing-prebuilt",
- "unsupportedappusage-annotation-processor-lib",
- "truth-host-prebuilt",
- "mockito-host",
- "junit-host",
- "objenesis",
- ],
-}
diff --git a/tools/processors/unsupportedappusage/test/src/android/processor/unsupportedappusage/CsvReader.java b/tools/processors/unsupportedappusage/test/src/android/processor/unsupportedappusage/CsvReader.java
deleted file mode 100644
index 23db99e..0000000
--- a/tools/processors/unsupportedappusage/test/src/android/processor/unsupportedappusage/CsvReader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.processor.unsupportedappusage;
-
-import com.google.common.base.Splitter;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class CsvReader {
-
- private final Splitter mSplitter;
- private final List<String> mColumns;
- private final List<Map<String, String>> mContents;
-
- public CsvReader(InputStream in) throws IOException {
- mSplitter = Splitter.on(",");
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- mColumns = mSplitter.splitToList(br.readLine());
- mContents = new ArrayList<>();
- String line = br.readLine();
- while (line != null) {
- List<String> contents = mSplitter.splitToList(line);
- Map<String, String> contentMap = new HashMap<>();
- for (int i = 0; i < Math.min(contents.size(), mColumns.size()); ++i) {
- contentMap.put(mColumns.get(i), contents.get(i));
- }
- mContents.add(contentMap);
- line = br.readLine();
- }
- br.close();
- }
-
- public List<String> getColumns() {
- return mColumns;
- }
-
- public List<Map<String, String>> getContents() {
- return mContents;
- }
-}
diff --git a/tools/processors/unsupportedappusage/test/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessorTest.java b/tools/processors/unsupportedappusage/test/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessorTest.java
deleted file mode 100644
index 75158ee..0000000
--- a/tools/processors/unsupportedappusage/test/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessorTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.processor.unsupportedappusage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import com.google.testing.compile.Compilation;
-import com.google.testing.compile.CompilationSubject;
-import com.google.testing.compile.Compiler;
-import com.google.testing.compile.JavaFileObjects;
-
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Optional;
-
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-
-public class UnsupportedAppUsageProcessorTest {
-
- private static final JavaFileObject ANNOTATION = JavaFileObjects.forSourceLines(
- "dalvik.dalvik.annotation.compat.UnsupportedAppUsage",
- "package dalvik.annotation.compat;",
- "public @interface UnsupportedAppUsage {",
- " String expectedSignature() default \"\";\n",
- " String someProperty() default \"\";",
- " String overrideSourcePosition() default \"\";",
- "}");
-
- private CsvReader compileAndReadCsv(JavaFileObject source) throws IOException {
- Compilation compilation =
- Compiler.javac().withProcessors(new UnsupportedAppUsageProcessor())
- .compile(ANNOTATION, source);
- CompilationSubject.assertThat(compilation).succeeded();
- Optional<JavaFileObject> csv = compilation.generatedFile(StandardLocation.CLASS_OUTPUT,
- "unsupportedappusage/unsupportedappusage_index.csv");
- assertThat(csv.isPresent()).isTrue();
-
- return new CsvReader(csv.get().openInputStream());
- }
-
- @Test
- public void testSignatureFormat() throws Exception {
- JavaFileObject src = JavaFileObjects.forSourceLines("a.b.Class",
- "package a.b;",
- "import dalvik.annotation.compat.UnsupportedAppUsage;",
- "public class Class {",
- " @UnsupportedAppUsage",
- " public void method() {}",
- "}");
- assertThat(compileAndReadCsv(src).getContents().get(0)).containsEntry(
- "signature", "La/b/Class;->method()V"
- );
- }
-
- @Test
- public void testSourcePosition() throws Exception {
- JavaFileObject src = JavaFileObjects.forSourceLines("a.b.Class",
- "package a.b;", // 1
- "import dalvik.annotation.compat.UnsupportedAppUsage;", // 2
- "public class Class {", // 3
- " @UnsupportedAppUsage", // 4
- " public void method() {}", // 5
- "}");
- Map<String, String> row = compileAndReadCsv(src).getContents().get(0);
- assertThat(row).containsEntry("startline", "4");
- assertThat(row).containsEntry("startcol", "3");
- assertThat(row).containsEntry("endline", "4");
- assertThat(row).containsEntry("endcol", "23");
- }
-
- @Test
- public void testAnnotationProperties() throws Exception {
- JavaFileObject src = JavaFileObjects.forSourceLines("a.b.Class",
- "package a.b;", // 1
- "import dalvik.annotation.compat.UnsupportedAppUsage;", // 2
- "public class Class {", // 3
- " @UnsupportedAppUsage(someProperty=\"value\")", // 4
- " public void method() {}", // 5
- "}");
- assertThat(compileAndReadCsv(src).getContents().get(0)).containsEntry(
- "properties", "someProperty=%22value%22");
- }
-
- @Test
- public void testSourcePositionOverride() throws Exception {
- JavaFileObject src = JavaFileObjects.forSourceLines("a.b.Class",
- "package a.b;", // 1
- "import dalvik.annotation.compat.UnsupportedAppUsage;", // 2
- "public class Class {", // 3
- " @UnsupportedAppUsage(overrideSourcePosition=\"otherfile.aidl:30:10:31:20\")",
- " public void method() {}", // 5
- "}");
- Map<String, String> row = compileAndReadCsv(src).getContents().get(0);
- assertThat(row).containsEntry("file", "otherfile.aidl");
- assertThat(row).containsEntry("startline", "30");
- assertThat(row).containsEntry("startcol", "10");
- assertThat(row).containsEntry("endline", "31");
- assertThat(row).containsEntry("endcol", "20");
- assertThat(row).containsEntry("properties", "");
- }
-
- @Test
- public void testSourcePositionOverrideWrongFormat() throws Exception {
- JavaFileObject src = JavaFileObjects.forSourceLines("a.b.Class",
- "package a.b;", // 1
- "import dalvik.annotation.compat.UnsupportedAppUsage;", // 2
- "public class Class {", // 3
- " @UnsupportedAppUsage(overrideSourcePosition=\"invalid\")", // 4
- " public void method() {}", // 5
- "}");
- Compilation compilation =
- Compiler.javac().withProcessors(new UnsupportedAppUsageProcessor())
- .compile(ANNOTATION, src);
- CompilationSubject.assertThat(compilation).failed();
- CompilationSubject.assertThat(compilation).hadErrorContaining(
- "Expected overrideSourcePosition to have format "
- + "file:startLine:startCol:endLine:endCol").inFile(src).onLine(4);
- }
-
- @Test
- public void testSourcePositionOverrideInvalidInt() throws Exception {
- JavaFileObject src = JavaFileObjects.forSourceLines("a.b.Class",
- "package a.b;", // 1
- "import dalvik.annotation.compat.UnsupportedAppUsage;", // 2
- "public class Class {", // 3
- " @UnsupportedAppUsage(overrideSourcePosition=\"otherfile.aidl:a:b:c:d\")", // 4
- " public void method() {}", // 5
- "}");
- Compilation compilation =
- Compiler.javac().withProcessors(new UnsupportedAppUsageProcessor())
- .compile(ANNOTATION, src);
- CompilationSubject.assertThat(compilation).failed();
- CompilationSubject.assertThat(compilation).hadErrorContaining(
- "error parsing integer").inFile(src).onLine(4);
- }
-
-}