Merge "Remove "result2" in AccountManagerService"
diff --git a/Android.bp b/Android.bp
index b83c63f..cf9610d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -34,6 +34,11 @@
include_dirs: ["external/protobuf/src"],
},
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
target: {
host: {
proto: {
diff --git a/Android.mk b/Android.mk
index a437501..5fd323f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -595,6 +595,8 @@
LOCAL_MODULE := framework
+LOCAL_JAVAC_SHARD_SIZE := 150
+
LOCAL_DX_FLAGS := --core-library --multi-dex
LOCAL_JACK_FLAGS := --multi-dex native
diff --git a/api/current.txt b/api/current.txt
index a0cd51b..0b60cb8 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -25559,6 +25559,7 @@
method public java.lang.String getName();
method public int getTruncationLengthBits();
method public void writeToParcel(android.os.Parcel, int);
+ field public static final java.lang.String AUTH_CRYPT_AES_GCM = "rfc4106(gcm(aes))";
field public static final java.lang.String AUTH_HMAC_MD5 = "hmac(md5)";
field public static final java.lang.String AUTH_HMAC_SHA1 = "hmac(sha1)";
field public static final java.lang.String AUTH_HMAC_SHA256 = "hmac(sha256)";
@@ -25606,6 +25607,7 @@
public static class IpSecTransform.Builder {
ctor public IpSecTransform.Builder(android.content.Context);
method public android.net.IpSecTransform buildTransportModeTransform(java.net.InetAddress) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException, android.net.IpSecManager.SpiUnavailableException;
+ method public android.net.IpSecTransform.Builder setAuthenticatedEncryption(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setAuthentication(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setEncryption(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setIpv4Encapsulation(android.net.IpSecManager.UdpEncapsulationSocket, int);
diff --git a/api/system-current.txt b/api/system-current.txt
index c9b656b..e6ac107 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -27755,6 +27755,7 @@
method public java.lang.String getName();
method public int getTruncationLengthBits();
method public void writeToParcel(android.os.Parcel, int);
+ field public static final java.lang.String AUTH_CRYPT_AES_GCM = "rfc4106(gcm(aes))";
field public static final java.lang.String AUTH_HMAC_MD5 = "hmac(md5)";
field public static final java.lang.String AUTH_HMAC_SHA1 = "hmac(sha1)";
field public static final java.lang.String AUTH_HMAC_SHA256 = "hmac(sha256)";
@@ -27802,6 +27803,7 @@
public static class IpSecTransform.Builder {
ctor public IpSecTransform.Builder(android.content.Context);
method public android.net.IpSecTransform buildTransportModeTransform(java.net.InetAddress) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException, android.net.IpSecManager.SpiUnavailableException;
+ method public android.net.IpSecTransform.Builder setAuthenticatedEncryption(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setAuthentication(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setEncryption(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setIpv4Encapsulation(android.net.IpSecManager.UdpEncapsulationSocket, int);
diff --git a/api/test-current.txt b/api/test-current.txt
index 6936d56..0e41fc1 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -25668,6 +25668,7 @@
method public java.lang.String getName();
method public int getTruncationLengthBits();
method public void writeToParcel(android.os.Parcel, int);
+ field public static final java.lang.String AUTH_CRYPT_AES_GCM = "rfc4106(gcm(aes))";
field public static final java.lang.String AUTH_HMAC_MD5 = "hmac(md5)";
field public static final java.lang.String AUTH_HMAC_SHA1 = "hmac(sha1)";
field public static final java.lang.String AUTH_HMAC_SHA256 = "hmac(sha256)";
@@ -25715,6 +25716,7 @@
public static class IpSecTransform.Builder {
ctor public IpSecTransform.Builder(android.content.Context);
method public android.net.IpSecTransform buildTransportModeTransform(java.net.InetAddress) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException, android.net.IpSecManager.SpiUnavailableException;
+ method public android.net.IpSecTransform.Builder setAuthenticatedEncryption(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setAuthentication(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setEncryption(int, android.net.IpSecAlgorithm);
method public android.net.IpSecTransform.Builder setIpv4Encapsulation(android.net.IpSecManager.UdpEncapsulationSocket, int);
diff --git a/cmds/am/Android.bp b/cmds/am/Android.bp
index 7eb4edf..bb16df1 100644
--- a/cmds/am/Android.bp
+++ b/cmds/am/Android.bp
@@ -4,6 +4,7 @@
cc_library_host_static {
name: "libinstrumentation",
srcs: ["**/*.proto"],
+ cflags: ["-Wall", "-Werror"],
proto: {
type: "full",
export_proto_headers: true,
diff --git a/core/java/android/net/IpSecAlgorithm.java b/core/java/android/net/IpSecAlgorithm.java
index 79310e2..16b1452 100644
--- a/core/java/android/net/IpSecAlgorithm.java
+++ b/core/java/android/net/IpSecAlgorithm.java
@@ -31,7 +31,6 @@
* RFC 4301.
*/
public final class IpSecAlgorithm implements Parcelable {
-
/**
* AES-CBC Encryption/Ciphering Algorithm.
*
@@ -68,6 +67,7 @@
* <p>Valid truncation lengths are multiples of 8 bits from 192 to (default) 384.
*/
public static final String AUTH_HMAC_SHA384 = "hmac(sha384)";
+
/**
* SHA512 HMAC Authentication/Integrity Algorithm
*
@@ -75,8 +75,24 @@
*/
public static final String AUTH_HMAC_SHA512 = "hmac(sha512)";
+ /**
+ * AES-GCM Authentication/Integrity + Encryption/Ciphering Algorithm.
+ *
+ * <p>Valid lengths for this key are {128, 192, 256}.
+ *
+ * <p>Valid ICV (truncation) lengths are {64, 96, 128}.
+ */
+ public static final String AUTH_CRYPT_AES_GCM = "rfc4106(gcm(aes))";
+
/** @hide */
- @StringDef({CRYPT_AES_CBC, AUTH_HMAC_MD5, AUTH_HMAC_SHA1, AUTH_HMAC_SHA256, AUTH_HMAC_SHA512})
+ @StringDef({
+ CRYPT_AES_CBC,
+ AUTH_HMAC_MD5,
+ AUTH_HMAC_SHA1,
+ AUTH_HMAC_SHA256,
+ AUTH_HMAC_SHA512,
+ AUTH_CRYPT_AES_GCM
+ })
@Retention(RetentionPolicy.SOURCE)
public @interface AlgorithmName {}
@@ -102,7 +118,7 @@
* @param algoName precise name of the algorithm to be used.
* @param key non-null Key padded to a multiple of 8 bits.
* @param truncLenBits the number of bits of output hash to use; only meaningful for
- * Authentication.
+ * Authentication or Authenticated Encryption (equivalent to ICV length).
*/
public IpSecAlgorithm(@AlgorithmName String algoName, byte[] key, int truncLenBits) {
if (!isTruncationLengthValid(algoName, truncLenBits)) {
@@ -175,6 +191,8 @@
return (truncLenBits >= 192 && truncLenBits <= 384);
case AUTH_HMAC_SHA512:
return (truncLenBits >= 256 && truncLenBits <= 512);
+ case AUTH_CRYPT_AES_GCM:
+ return (truncLenBits == 64 || truncLenBits == 96 || truncLenBits == 128);
default:
return false;
}
diff --git a/core/java/android/net/IpSecConfig.java b/core/java/android/net/IpSecConfig.java
index 632b7fc..61b13a9 100644
--- a/core/java/android/net/IpSecConfig.java
+++ b/core/java/android/net/IpSecConfig.java
@@ -50,6 +50,9 @@
// Authentication Algorithm
private IpSecAlgorithm mAuthentication;
+ // Authenticated Encryption Algorithm
+ private IpSecAlgorithm mAuthenticatedEncryption;
+
@Override
public String toString() {
return new StringBuilder()
@@ -59,6 +62,8 @@
.append(mEncryption)
.append(", mAuthentication=")
.append(mAuthentication)
+ .append(", mAuthenticatedEncryption=")
+ .append(mAuthenticatedEncryption)
.append("}")
.toString();
}
@@ -118,6 +123,11 @@
mFlow[direction].mAuthentication = authentication;
}
+ /** Set the authenticated encryption algorithm for a given direction */
+ public void setAuthenticatedEncryption(int direction, IpSecAlgorithm authenticatedEncryption) {
+ mFlow[direction].mAuthenticatedEncryption = authenticatedEncryption;
+ }
+
public void setNetwork(Network network) {
mNetwork = network;
}
@@ -163,6 +173,10 @@
return mFlow[direction].mAuthentication;
}
+ public IpSecAlgorithm getAuthenticatedEncryption(int direction) {
+ return mFlow[direction].mAuthenticatedEncryption;
+ }
+
public Network getNetwork() {
return mNetwork;
}
@@ -199,9 +213,11 @@
out.writeInt(mFlow[IpSecTransform.DIRECTION_IN].mSpiResourceId);
out.writeParcelable(mFlow[IpSecTransform.DIRECTION_IN].mEncryption, flags);
out.writeParcelable(mFlow[IpSecTransform.DIRECTION_IN].mAuthentication, flags);
+ out.writeParcelable(mFlow[IpSecTransform.DIRECTION_IN].mAuthenticatedEncryption, flags);
out.writeInt(mFlow[IpSecTransform.DIRECTION_OUT].mSpiResourceId);
out.writeParcelable(mFlow[IpSecTransform.DIRECTION_OUT].mEncryption, flags);
out.writeParcelable(mFlow[IpSecTransform.DIRECTION_OUT].mAuthentication, flags);
+ out.writeParcelable(mFlow[IpSecTransform.DIRECTION_OUT].mAuthenticatedEncryption, flags);
out.writeInt(mEncapType);
out.writeInt(mEncapSocketResourceId);
out.writeInt(mEncapRemotePort);
@@ -221,11 +237,15 @@
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
mFlow[IpSecTransform.DIRECTION_IN].mAuthentication =
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
+ mFlow[IpSecTransform.DIRECTION_IN].mAuthenticatedEncryption =
+ (IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
mFlow[IpSecTransform.DIRECTION_OUT].mSpiResourceId = in.readInt();
mFlow[IpSecTransform.DIRECTION_OUT].mEncryption =
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
mFlow[IpSecTransform.DIRECTION_OUT].mAuthentication =
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
+ mFlow[IpSecTransform.DIRECTION_OUT].mAuthenticatedEncryption =
+ (IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
mEncapType = in.readInt();
mEncapSocketResourceId = in.readInt();
mEncapRemotePort = in.readInt();
diff --git a/core/java/android/net/IpSecTransform.java b/core/java/android/net/IpSecTransform.java
index e15a2c6..48b5bd5 100644
--- a/core/java/android/net/IpSecTransform.java
+++ b/core/java/android/net/IpSecTransform.java
@@ -281,6 +281,8 @@
* <p>If encryption is set for a given direction without also providing an SPI for that
* direction, creation of an IpSecTransform will fail upon calling a build() method.
*
+ * <p>Authenticated encryption is mutually exclusive with encryption and authentication.
+ *
* @param direction either {@link #DIRECTION_IN or #DIRECTION_OUT}
* @param algo {@link IpSecAlgorithm} specifying the encryption to be applied.
*/
@@ -296,6 +298,8 @@
* <p>If authentication is set for a given direction without also providing an SPI for that
* direction, creation of an IpSecTransform will fail upon calling a build() method.
*
+ * <p>Authenticated encryption is mutually exclusive with encryption and authentication.
+ *
* @param direction either {@link #DIRECTION_IN or #DIRECTION_OUT}
* @param algo {@link IpSecAlgorithm} specifying the authentication to be applied.
*/
@@ -306,6 +310,29 @@
}
/**
+ * Add an authenticated encryption algorithm to the transform for the given direction.
+ *
+ * <p>If an authenticated encryption algorithm is set for a given direction without also
+ * providing an SPI for that direction, creation of an IpSecTransform will fail upon calling
+ * a build() method.
+ *
+ * <p>The Authenticated Encryption (AE) class of algorithms are also known as Authenticated
+ * Encryption with Associated Data (AEAD) algorithms, or Combined mode algorithms (as
+ * referred to in RFC 4301)
+ *
+ * <p>Authenticated encryption is mutually exclusive with encryption and authentication.
+ *
+ * @param direction either {@link #DIRECTION_IN or #DIRECTION_OUT}
+ * @param algo {@link IpSecAlgorithm} specifying the authenticated encryption algorithm to
+ * be applied.
+ */
+ public IpSecTransform.Builder setAuthenticatedEncryption(
+ @TransformDirection int direction, IpSecAlgorithm algo) {
+ mConfig.setAuthenticatedEncryption(direction, algo);
+ return this;
+ }
+
+ /**
* Set the SPI, which uniquely identifies a particular IPsec session from others. Because
* IPsec operates at the IP layer, this 32-bit identifier uniquely identifies packets to a
* given destination address.
diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java
index 560b4b3..4f6d322 100644
--- a/core/java/android/os/SystemProperties.java
+++ b/core/java/android/os/SystemProperties.java
@@ -84,9 +84,6 @@
/**
* Get the String value for the given {@code key}.
*
- * <b>WARNING:</b> Do not use this method if the value may not be a valid UTF string! This
- * method will crash in native code.
- *
* @param key the key to lookup
* @return an empty string if the {@code key} isn't found
*/
@@ -99,9 +96,6 @@
/**
* Get the String value for the given {@code key}.
*
- * <b>WARNING:</b> Do not use this method if the value may not be a valid UTF string! This
- * method will crash in native code.
- *
* @param key the key to lookup
* @param def the default value in case the property is not set or empty
* @return if the {@code key} isn't found, return {@code def} if it isn't null, or an empty
@@ -163,7 +157,7 @@
* @throws IllegalArgumentException if the {@code val} exceeds 91 characters
*/
public static void set(@NonNull String key, @Nullable String val) {
- if (val != null && val.length() > PROP_VALUE_MAX) {
+ if (val != null && !val.startsWith("ro.") && val.length() > PROP_VALUE_MAX) {
throw new IllegalArgumentException("value of system property '" + key
+ "' is longer than " + PROP_VALUE_MAX + " characters: " + val);
}
diff --git a/core/java/android/util/MutableBoolean.java b/core/java/android/util/MutableBoolean.java
new file mode 100644
index 0000000..ed837ab
--- /dev/null
+++ b/core/java/android/util/MutableBoolean.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.util;
+
+/**
+ */
+public final class MutableBoolean {
+ public boolean value;
+
+ public MutableBoolean(boolean value) {
+ this.value = value;
+ }
+}
diff --git a/core/java/android/util/MutableByte.java b/core/java/android/util/MutableByte.java
new file mode 100644
index 0000000..cc6b00a
--- /dev/null
+++ b/core/java/android/util/MutableByte.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.util;
+
+/**
+ */
+public final class MutableByte {
+ public byte value;
+
+ public MutableByte(byte value) {
+ this.value = value;
+ }
+}
diff --git a/core/java/android/util/MutableChar.java b/core/java/android/util/MutableChar.java
new file mode 100644
index 0000000..9a2e2bc
--- /dev/null
+++ b/core/java/android/util/MutableChar.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.util;
+
+/**
+ */
+public final class MutableChar {
+ public char value;
+
+ public MutableChar(char value) {
+ this.value = value;
+ }
+}
diff --git a/core/java/android/util/MutableDouble.java b/core/java/android/util/MutableDouble.java
new file mode 100644
index 0000000..bd7329a
--- /dev/null
+++ b/core/java/android/util/MutableDouble.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.util;
+
+/**
+ */
+public final class MutableDouble {
+ public double value;
+
+ public MutableDouble(double value) {
+ this.value = value;
+ }
+}
diff --git a/core/java/android/util/MutableFloat.java b/core/java/android/util/MutableFloat.java
new file mode 100644
index 0000000..e6f2d7d
--- /dev/null
+++ b/core/java/android/util/MutableFloat.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.util;
+
+/**
+ */
+public final class MutableFloat {
+ public float value;
+
+ public MutableFloat(float value) {
+ this.value = value;
+ }
+}
diff --git a/core/java/android/util/MutableShort.java b/core/java/android/util/MutableShort.java
new file mode 100644
index 0000000..48fb232
--- /dev/null
+++ b/core/java/android/util/MutableShort.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.util;
+
+/**
+ */
+public final class MutableShort {
+ public short value;
+
+ public MutableShort(short value) {
+ this.value = value;
+ }
+}
diff --git a/core/java/android/util/apk/ApkSignatureSchemeV2Verifier.java b/core/java/android/util/apk/ApkSignatureSchemeV2Verifier.java
index 0216a07..a9ccae1 100644
--- a/core/java/android/util/apk/ApkSignatureSchemeV2Verifier.java
+++ b/core/java/android/util/apk/ApkSignatureSchemeV2Verifier.java
@@ -17,6 +17,7 @@
package android.util.apk;
import android.system.ErrnoException;
+import android.system.Os;
import android.system.OsConstants;
import android.util.ArrayMap;
import android.util.Pair;
@@ -59,9 +60,6 @@
import java.util.Map;
import java.util.Set;
-import libcore.io.Libcore;
-import libcore.io.Os;
-
/**
* APK Signature Scheme v2 verifier.
*
@@ -994,8 +992,7 @@
* {@link DataSource#feedIntoMessageDigests(MessageDigest[], long, int) feedIntoMessageDigests}.
*/
private static final class MemoryMappedFileDataSource implements DataSource {
- private static final Os OS = Libcore.os;
- private static final long MEMORY_PAGE_SIZE_BYTES = OS.sysconf(OsConstants._SC_PAGESIZE);
+ private static final long MEMORY_PAGE_SIZE_BYTES = Os.sysconf(OsConstants._SC_PAGESIZE);
private final FileDescriptor mFd;
private final long mFilePosition;
@@ -1041,7 +1038,7 @@
long mmapRegionSize = size + dataStartOffsetInMmapRegion;
long mmapPtr = 0;
try {
- mmapPtr = OS.mmap(
+ mmapPtr = Os.mmap(
0, // let the OS choose the start address of the region in memory
mmapRegionSize,
OsConstants.PROT_READ,
@@ -1066,7 +1063,7 @@
} finally {
if (mmapPtr != 0) {
try {
- OS.munmap(mmapPtr, mmapRegionSize);
+ Os.munmap(mmapPtr, mmapRegionSize);
} catch (ErrnoException ignored) {}
}
}
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index 04f7c76..a44fd67 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -130,7 +130,7 @@
long getAwakeTimePlugged();
void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized);
- void noteBleScanStopped(in WorkSource ws);
+ void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized);
void noteResetBleScan();
void noteBleScanResults(in WorkSource ws, int numNewResults);
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 235ebc8..4b582bf 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -4845,7 +4845,7 @@
}
}
- private void noteBluetoothScanStoppedLocked(int uid) {
+ private void noteBluetoothScanStoppedLocked(int uid, boolean isUnoptimized) {
uid = mapUid(uid);
final long elapsedRealtime = mClocks.elapsedRealtime();
final long uptime = mClocks.uptimeMillis();
@@ -4857,13 +4857,13 @@
addHistoryRecordLocked(elapsedRealtime, uptime);
mBluetoothScanTimer.stopRunningLocked(elapsedRealtime);
}
- getUidStatsLocked(uid).noteBluetoothScanStoppedLocked(elapsedRealtime);
+ getUidStatsLocked(uid).noteBluetoothScanStoppedLocked(elapsedRealtime, isUnoptimized);
}
- public void noteBluetoothScanStoppedFromSourceLocked(WorkSource ws) {
+ public void noteBluetoothScanStoppedFromSourceLocked(WorkSource ws, boolean isUnoptimized) {
final int N = ws.size();
for (int i = 0; i < N; i++) {
- noteBluetoothScanStoppedLocked(ws.get(i));
+ noteBluetoothScanStoppedLocked(ws.get(i), isUnoptimized);
}
}
@@ -6114,14 +6114,11 @@
}
}
- public void noteBluetoothScanStoppedLocked(long elapsedRealtimeMs) {
+ public void noteBluetoothScanStoppedLocked(long elapsedRealtimeMs, boolean isUnoptimized) {
if (mBluetoothScanTimer != null) {
mBluetoothScanTimer.stopRunningLocked(elapsedRealtimeMs);
}
- // In the ble code, a scan cannot change types and nested starts are not possible.
- // So if an unoptimizedScan is running, it is now being stopped.
- if (mBluetoothUnoptimizedScanTimer != null
- && mBluetoothUnoptimizedScanTimer.isRunningLocked()) {
+ if (isUnoptimized && mBluetoothUnoptimizedScanTimer != null) {
mBluetoothUnoptimizedScanTimer.stopRunningLocked(elapsedRealtimeMs);
}
}
diff --git a/core/java/com/android/internal/os/KernelCpuSpeedReader.java b/core/java/com/android/internal/os/KernelCpuSpeedReader.java
index 9c7debb..ae13ea4 100644
--- a/core/java/com/android/internal/os/KernelCpuSpeedReader.java
+++ b/core/java/com/android/internal/os/KernelCpuSpeedReader.java
@@ -15,13 +15,12 @@
*/
package com.android.internal.os;
+import android.system.Os;
import android.text.TextUtils;
import android.os.StrictMode;
import android.system.OsConstants;
import android.util.Slog;
-import libcore.io.Libcore;
-
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
@@ -53,7 +52,7 @@
cpuNumber);
mLastSpeedTimes = new long[numSpeedSteps];
mDeltaSpeedTimes = new long[numSpeedSteps];
- long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK);
+ long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK);
mJiffyMillis = 1000/jiffyHz;
}
diff --git a/core/java/com/android/internal/os/ProcessCpuTracker.java b/core/java/com/android/internal/os/ProcessCpuTracker.java
index e46dfc4..bf31c7d 100644
--- a/core/java/com/android/internal/os/ProcessCpuTracker.java
+++ b/core/java/com/android/internal/os/ProcessCpuTracker.java
@@ -22,6 +22,7 @@
import android.os.Process;
import android.os.StrictMode;
import android.os.SystemClock;
+import android.system.Os;
import android.system.OsConstants;
import android.util.Slog;
@@ -294,7 +295,7 @@
public ProcessCpuTracker(boolean includeThreads) {
mIncludeThreads = includeThreads;
- long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK);
+ long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK);
mJiffyMillis = 1000/jiffyHz;
}
diff --git a/core/tests/coretests/src/com/android/internal/os/BatteryStatsBackgroundStatsTest.java b/core/tests/coretests/src/com/android/internal/os/BatteryStatsBackgroundStatsTest.java
index c539f78..c21c3be 100644
--- a/core/tests/coretests/src/com/android/internal/os/BatteryStatsBackgroundStatsTest.java
+++ b/core/tests/coretests/src/com/android/internal/os/BatteryStatsBackgroundStatsTest.java
@@ -217,10 +217,6 @@
curr = 1000 * (clocks.realtime = clocks.uptime = 305);
bi.updateTimeBasesLocked(false, false, curr, curr); // off battery
- // Stop timer
- curr = 1000 * (clocks.realtime = clocks.uptime = 409);
- bi.noteBluetoothScanStoppedFromSourceLocked(ws);
-
// Start timer (unoptimized)
curr = 1000 * (clocks.realtime = clocks.uptime = 1000);
bi.noteBluetoothScanStartedFromSourceLocked(ws, true);
@@ -233,9 +229,13 @@
curr = 1000 * (clocks.realtime = clocks.uptime = 3004);
bi.noteUidProcessStateLocked(UID, ActivityManager.PROCESS_STATE_TOP);
- // Stop timer
+ // Stop timer (optimized)
+ curr = 1000 * (clocks.realtime = clocks.uptime = 3409);
+ bi.noteBluetoothScanStoppedFromSourceLocked(ws, false);
+
+ // Stop timer (unoptimized)
curr = 1000 * (clocks.realtime = clocks.uptime = 4008);
- bi.noteBluetoothScanStoppedFromSourceLocked(ws);
+ bi.noteBluetoothScanStoppedFromSourceLocked(ws, true);
// Test
curr = 1000 * (clocks.realtime = clocks.uptime = 5000);
diff --git a/core/tests/coretests/src/com/android/internal/os/BatteryStatsNoteTest.java b/core/tests/coretests/src/com/android/internal/os/BatteryStatsNoteTest.java
index 4e8ab31..ed54f53 100644
--- a/core/tests/coretests/src/com/android/internal/os/BatteryStatsNoteTest.java
+++ b/core/tests/coretests/src/com/android/internal/os/BatteryStatsNoteTest.java
@@ -44,8 +44,6 @@
assertEquals(101,
bi.getUidStats().get(UID).getBluetoothScanResultCounter()
.getCountLocked(STATS_SINCE_CHARGED));
- // TODO: remove next line when Counter misreporting values when plugged-in bug is fixed.
- bi.noteUidProcessStateLocked(UID, ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND);
BatteryStats.Counter bgCntr = bi.getUidStats().get(UID).getBluetoothScanResultBgCounter();
if (bgCntr != null) {
assertEquals(0, bgCntr.getCountLocked(STATS_SINCE_CHARGED));
diff --git a/graphics/java/android/graphics/pdf/PdfEditor.java b/graphics/java/android/graphics/pdf/PdfEditor.java
index cd1f8de..cb6b3a3 100644
--- a/graphics/java/android/graphics/pdf/PdfEditor.java
+++ b/graphics/java/android/graphics/pdf/PdfEditor.java
@@ -23,6 +23,7 @@
import android.graphics.Rect;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
+import android.system.Os;
import android.system.OsConstants;
import dalvik.system.CloseGuard;
import libcore.io.IoUtils;
@@ -72,8 +73,8 @@
final long size;
try {
- Libcore.os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
- size = Libcore.os.fstat(input.getFileDescriptor()).st_size;
+ Os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
+ size = Os.fstat(input.getFileDescriptor()).st_size;
} catch (ErrnoException ee) {
throw new IllegalArgumentException("file descriptor not seekable");
}
diff --git a/graphics/java/android/graphics/pdf/PdfRenderer.java b/graphics/java/android/graphics/pdf/PdfRenderer.java
index 7b7a290..b4630a4 100644
--- a/graphics/java/android/graphics/pdf/PdfRenderer.java
+++ b/graphics/java/android/graphics/pdf/PdfRenderer.java
@@ -26,10 +26,10 @@
import android.graphics.Rect;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
+import android.system.Os;
import android.system.OsConstants;
import com.android.internal.util.Preconditions;
import dalvik.system.CloseGuard;
-import libcore.io.Libcore;
import java.io.IOException;
import java.lang.annotation.Retention;
@@ -154,8 +154,8 @@
final long size;
try {
- Libcore.os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
- size = Libcore.os.fstat(input.getFileDescriptor()).st_size;
+ Os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
+ size = Os.fstat(input.getFileDescriptor()).st_size;
} catch (ErrnoException ee) {
throw new IllegalArgumentException("file descriptor not seekable");
}
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 5cbccea..28f3106 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -39,6 +39,7 @@
import android.os.SystemProperties;
import android.provider.Settings;
import android.system.ErrnoException;
+import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import android.util.Pair;
@@ -60,7 +61,6 @@
import com.android.internal.util.Preconditions;
import libcore.io.IoBridge;
-import libcore.io.Libcore;
import libcore.io.Streams;
import java.io.ByteArrayOutputStream;
@@ -2810,7 +2810,7 @@
final FileDescriptor dupedFd;
try {
- dupedFd = Libcore.os.dup(fd);
+ dupedFd = Os.dup(fd);
} catch (ErrnoException ex) {
Log.e(TAG, ex.getMessage(), ex);
throw new RuntimeException(ex);
@@ -2848,7 +2848,7 @@
private int addTrack() {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
- Libcore.os.lseek(dupedFd, offset2, OsConstants.SEEK_SET);
+ Os.lseek(dupedFd, offset2, OsConstants.SEEK_SET);
byte[] buffer = new byte[4096];
for (long total = 0; total < length2;) {
int bytesToRead = (int) Math.min(buffer.length, length2 - total);
@@ -2872,7 +2872,7 @@
return MEDIA_INFO_TIMED_TEXT_ERROR;
} finally {
try {
- Libcore.os.close(dupedFd);
+ Os.close(dupedFd);
} catch (ErrnoException e) {
Log.e(TAG, e.getMessage(), e);
}
diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java
index 8437d03..dd99a15 100755
--- a/media/java/android/mtp/MtpDatabase.java
+++ b/media/java/android/mtp/MtpDatabase.java
@@ -466,10 +466,14 @@
if (parent == 0xFFFFFFFF) {
// all objects in root of store
parent = 0;
+ where = STORAGE_PARENT_WHERE;
+ whereArgs = new String[]{Integer.toString(storageID),
+ Integer.toString(parent)};
+ } else {
+ // If a parent is specified, the storage is redundant
+ where = PARENT_WHERE;
+ whereArgs = new String[]{Integer.toString(parent)};
}
- where = STORAGE_PARENT_WHERE;
- whereArgs = new String[] { Integer.toString(storageID),
- Integer.toString(parent) };
}
} else {
// query specific format
@@ -482,11 +486,16 @@
if (parent == 0xFFFFFFFF) {
// all objects in root of store
parent = 0;
+ where = STORAGE_FORMAT_PARENT_WHERE;
+ whereArgs = new String[]{Integer.toString(storageID),
+ Integer.toString(format),
+ Integer.toString(parent)};
+ } else {
+ // If a parent is specified, the storage is redundant
+ where = FORMAT_PARENT_WHERE;
+ whereArgs = new String[]{Integer.toString(format),
+ Integer.toString(parent)};
}
- where = STORAGE_FORMAT_PARENT_WHERE;
- whereArgs = new String[] { Integer.toString(storageID),
- Integer.toString(format),
- Integer.toString(parent) };
}
}
}
@@ -838,7 +847,7 @@
return MtpConstants.RESPONSE_OK;
}
- private int moveObject(int handle, int newParent, String newPath) {
+ private int moveObject(int handle, int newParent, int newStorage, String newPath) {
String[] whereArgs = new String[] { Integer.toString(handle) };
// do not allow renaming any of the special subdirectories
@@ -850,6 +859,7 @@
ContentValues values = new ContentValues();
values.put(Files.FileColumns.DATA, newPath);
values.put(Files.FileColumns.PARENT, newParent);
+ values.put(Files.FileColumns.STORAGE_ID, newStorage);
int updated = 0;
try {
// note - we are relying on a special case in MediaProvider.update() to update
diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp
index b9d3d8f..0c946ba 100644
--- a/media/jni/android_mtp_MtpDatabase.cpp
+++ b/media/jni/android_mtp_MtpDatabase.cpp
@@ -180,7 +180,7 @@
virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property);
virtual MtpResponseCode moveObject(MtpObjectHandle handle, MtpObjectHandle newParent,
- MtpString& newPath);
+ MtpStorageID newStorage, MtpString& newPath);
virtual void sessionStarted();
@@ -998,11 +998,11 @@
}
MtpResponseCode MyMtpDatabase::moveObject(MtpObjectHandle handle, MtpObjectHandle newParent,
- MtpString &newPath) {
+ MtpStorageID newStorage, MtpString &newPath) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
jstring stringValue = env->NewStringUTF((const char *) newPath);
MtpResponseCode result = env->CallIntMethod(mDatabase, method_moveObject,
- (jint)handle, (jint)newParent, stringValue);
+ (jint)handle, (jint)newParent, (jint) newStorage, stringValue);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
env->DeleteLocalRef(stringValue);
@@ -1374,7 +1374,7 @@
ALOGE("Can't find deleteFile");
return -1;
}
- method_moveObject = env->GetMethodID(clazz, "moveObject", "(IILjava/lang/String;)I");
+ method_moveObject = env->GetMethodID(clazz, "moveObject", "(IIILjava/lang/String;)I");
if (method_moveObject == NULL) {
ALOGE("Can't find moveObject");
return -1;
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp
index e9e9309..6ce104d 100644
--- a/media/jni/android_mtp_MtpServer.cpp
+++ b/media/jni/android_mtp_MtpServer.cpp
@@ -72,7 +72,7 @@
const char *deviceInfoDeviceVersionStr = env->GetStringUTFChars(deviceInfoDeviceVersion, NULL);
const char *deviceInfoSerialNumberStr = env->GetStringUTFChars(deviceInfoSerialNumber, NULL);
MtpServer* server = new MtpServer(getMtpDatabase(env, javaDatabase),
- usePtp, AID_MEDIA_RW, 0664, 0775,
+ usePtp,
MtpString((deviceInfoManufacturerStr != NULL) ? deviceInfoManufacturerStr : ""),
MtpString((deviceInfoModelStr != NULL) ? deviceInfoModelStr : ""),
MtpString((deviceInfoDeviceVersionStr != NULL) ? deviceInfoDeviceVersionStr : ""),
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
index 80b943c..740ce43 100755
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
@@ -107,14 +107,16 @@
addHandler(Intent.ACTION_DOCK_EVENT, new DockEventHandler());
mContext.registerReceiver(mBroadcastReceiver, mAdapterIntentFilter, null, mReceiverHandler);
+ mContext.registerReceiver(mProfileBroadcastReceiver, mProfileIntentFilter, null, mReceiverHandler);
}
void registerProfileIntentReceiver() {
- mContext.registerReceiver(mBroadcastReceiver, mProfileIntentFilter, null, mReceiverHandler);
+ mContext.registerReceiver(mProfileBroadcastReceiver, mProfileIntentFilter, null, mReceiverHandler);
}
public void setReceiverHandler(android.os.Handler handler) {
mContext.unregisterReceiver(mBroadcastReceiver);
+ mContext.unregisterReceiver(mProfileBroadcastReceiver);
mReceiverHandler = handler;
mContext.registerReceiver(mBroadcastReceiver, mAdapterIntentFilter, null, mReceiverHandler);
registerProfileIntentReceiver();
@@ -148,11 +150,31 @@
}
};
+ private final BroadcastReceiver mProfileBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ BluetoothDevice device = intent
+ .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+
+ Handler handler = mHandlerMap.get(action);
+ if (handler != null) {
+ handler.onReceive(context, intent, device);
+ }
+ }
+ };
+
private class AdapterStateChangedHandler implements Handler {
public void onReceive(Context context, Intent intent,
BluetoothDevice device) {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
BluetoothAdapter.ERROR);
+ // Reregister Profile Broadcast Receiver as part of TURN OFF
+ if (state == BluetoothAdapter.STATE_OFF)
+ {
+ context.unregisterReceiver(mProfileBroadcastReceiver);
+ registerProfileIntentReceiver();
+ }
// update local profiles and get paired devices
mLocalAdapter.setBluetoothStateInt(state);
// send callback to update UI and possibly start scanning
diff --git a/packages/SystemUI/res-keyguard/values/strings.xml b/packages/SystemUI/res-keyguard/values/strings.xml
index 1efa3a8..af1ac33 100644
--- a/packages/SystemUI/res-keyguard/values/strings.xml
+++ b/packages/SystemUI/res-keyguard/values/strings.xml
@@ -48,6 +48,9 @@
to unlock the keyguard. Displayed in one line in a large font. -->
<string name="keyguard_password_wrong_pin_code">Incorrect PIN code.</string>
+ <!-- Shown in the lock screen when there is SIM card IO error. -->
+ <string name="keyguard_sim_error_message_short">Invalid Card.</string>
+
<!-- When the lock screen is showing, the phone is plugged in and the battery is fully
charged, say that it is charged. -->
<string name="keyguard_charged">Charged</string>
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierText.java b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
index 159ac4c..13c48d0 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierText.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
@@ -39,6 +39,7 @@
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.TelephonyIntents;
import com.android.settingslib.WirelessUtils;
+import android.telephony.TelephonyManager;
public class CarrierText extends TextView {
private static final boolean DEBUG = KeyguardConstants.DEBUG;
@@ -52,6 +53,8 @@
private WifiManager mWifiManager;
+ private boolean[] mSimErrorState = new boolean[TelephonyManager.getDefault().getPhoneCount()];
+
private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onRefreshCarrierInfo() {
@@ -65,6 +68,22 @@
public void onStartedWakingUp() {
setSelected(true);
};
+
+ public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) {
+ if (slotId < 0) {
+ Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId);
+ return;
+ }
+
+ if (DEBUG) Log.d(TAG,"onSimStateChanged: " + getStatusForIccState(simState));
+ if (getStatusForIccState(simState) == StatusMode.SimIoError) {
+ mSimErrorState[slotId] = true;
+ updateCarrierText();
+ } else if (mSimErrorState[slotId]) {
+ mSimErrorState[slotId] = false;
+ updateCarrierText();
+ }
+ };
};
/**
* The status of this lock screen. Primarily used for widgets on LockScreen.
@@ -77,7 +96,8 @@
SimPukLocked, // SIM card is PUK locked because SIM entered wrong too many times
SimLocked, // SIM card is currently locked
SimPermDisabled, // SIM card is permanently disabled due to PUK unlock failure
- SimNotReady; // SIM is not ready yet. May never be on devices w/o a SIM.
+ SimNotReady, // SIM is not ready yet. May never be on devices w/o a SIM.
+ SimIoError; // SIM card is faulty
}
public CarrierText(Context context) {
@@ -101,6 +121,35 @@
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
}
+ /**
+ * Checks if there are faulty cards. Adds the text depending on the slot of the card
+ * @param text: current carrier text based on the sim state
+ * @param noSims: whether a valid sim card is inserted
+ * @return text
+ */
+ private CharSequence updateCarrierTextWithSimIoError(CharSequence text, boolean noSims) {
+ final CharSequence carrier = "";
+ CharSequence carrierTextForSimIOError = getCarrierTextForSimState(
+ IccCardConstants.State.CARD_IO_ERROR, carrier);
+ for (int index = 0; index < mSimErrorState.length; index++) {
+ if (mSimErrorState[index]) {
+ // In the case when no sim cards are detected but a faulty card is inserted
+ // overwrite the text and only show "Invalid card"
+ if (noSims) {
+ return concatenate(carrierTextForSimIOError,
+ getContext().getText(com.android.internal.R.string.emergency_calls_only));
+ } else if (index == 0) {
+ // prepend "Invalid card" when faulty card is inserted in slot 0
+ text = concatenate(carrierTextForSimIOError, text);
+ } else {
+ // concatenate "Invalid card" when faulty card is inserted in slot 1
+ text = concatenate(text, carrierTextForSimIOError);
+ }
+ }
+ }
+ return text;
+ }
+
protected void updateCarrierText() {
boolean allSimsMissing = true;
boolean anySimReadyAndInService = false;
@@ -179,6 +228,7 @@
}
}
+ displayText = updateCarrierTextWithSimIoError(displayText, allSimsMissing);
// APM (airplane mode) != no carrier state. There are carrier services
// (e.g. WFC = Wi-Fi calling) which may operate in APM.
if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) {
@@ -270,6 +320,11 @@
getContext().getText(R.string.keyguard_sim_puk_locked_message),
text);
break;
+ case SimIoError:
+ carrierText = makeCarrierStringOnEmergencyCapable(
+ getContext().getText(R.string.keyguard_sim_error_message_short),
+ text);
+ break;
}
return carrierText;
@@ -319,6 +374,8 @@
return StatusMode.SimPermDisabled;
case UNKNOWN:
return StatusMode.SimMissing;
+ case CARD_IO_ERROR:
+ return StatusMode.SimIoError;
}
return StatusMode.SimMissing;
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index ad82840..34b8616 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -826,6 +826,8 @@
}
} else if (IccCardConstants.INTENT_VALUE_LOCKED_NETWORK.equals(stateExtra)) {
state = IccCardConstants.State.NETWORK_LOCKED;
+ } else if (IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR.equals(stateExtra)) {
+ state = IccCardConstants.State.CARD_IO_ERROR;
} else if (IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(stateExtra)
|| IccCardConstants.INTENT_VALUE_ICC_IMSI.equals(stateExtra)) {
// This is required because telephony doesn't return to "READY" after
diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java
index 2e1f142..cf1d33c 100644
--- a/services/core/java/com/android/server/IpSecService.java
+++ b/services/core/java/com/android/server/IpSecService.java
@@ -882,8 +882,14 @@
for (int direction : DIRECTIONS) {
IpSecAlgorithm crypt = config.getEncryption(direction);
IpSecAlgorithm auth = config.getAuthentication(direction);
- if (crypt == null && auth == null) {
- throw new IllegalArgumentException("Encryption and Authentication are both null");
+ IpSecAlgorithm authenticatedEncryption = config.getAuthenticatedEncryption(direction);
+ if (authenticatedEncryption == null && crypt == null && auth == null) {
+ throw new IllegalArgumentException(
+ "No Encryption or Authentication algorithms specified");
+ } else if (authenticatedEncryption != null && (auth != null || crypt != null)) {
+ throw new IllegalArgumentException(
+ "Authenticated Encryption is mutually"
+ + " exclusive with other Authentication or Encryption algorithms");
}
if (mSpiRecords.getAndCheckOwner(config.getSpiResourceId(direction)) == null) {
@@ -922,6 +928,7 @@
for (int direction : DIRECTIONS) {
IpSecAlgorithm auth = c.getAuthentication(direction);
IpSecAlgorithm crypt = c.getEncryption(direction);
+ IpSecAlgorithm authCrypt = c.getAuthenticatedEncryption(direction);
spis[direction] = mSpiRecords.getAndCheckOwner(c.getSpiResourceId(direction));
int spi = spis[direction].getSpi();
@@ -942,6 +949,9 @@
(crypt != null) ? crypt.getName() : "",
(crypt != null) ? crypt.getKey() : null,
(crypt != null) ? crypt.getTruncationLengthBits() : 0,
+ (authCrypt != null) ? authCrypt.getName() : "",
+ (authCrypt != null) ? authCrypt.getKey() : null,
+ (authCrypt != null) ? authCrypt.getTruncationLengthBits() : 0,
encapType,
encapLocalPort,
encapRemotePort);
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index c20221b..deaf3b8 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -962,10 +962,10 @@
}
@Override
- public void noteBleScanStopped(WorkSource ws) {
+ public void noteBleScanStopped(WorkSource ws, boolean isUnoptimized) {
enforceCallingPermission();
synchronized (mStats) {
- mStats.noteBluetoothScanStoppedFromSourceLocked(ws);
+ mStats.noteBluetoothScanStoppedFromSourceLocked(ws, isUnoptimized);
}
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index f111db1..89471bb 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -78,7 +78,6 @@
import com.android.server.pm.PackageInstallerService.PackageInstallObserverAdapter;
import libcore.io.IoUtils;
-import libcore.io.Libcore;
import java.io.File;
import java.io.FileDescriptor;
@@ -463,7 +462,7 @@
// TODO: this should delegate to DCS so the system process avoids
// holding open FDs into containers.
- final FileDescriptor targetFd = Libcore.os.open(target.getAbsolutePath(),
+ final FileDescriptor targetFd = Os.open(target.getAbsolutePath(),
O_CREAT | O_WRONLY, 0644);
Os.chmod(target.getAbsolutePath(), 0644);
@@ -475,7 +474,7 @@
}
if (offsetBytes > 0) {
- Libcore.os.lseek(targetFd, offsetBytes, OsConstants.SEEK_SET);
+ Os.lseek(targetFd, offsetBytes, OsConstants.SEEK_SET);
}
if (PackageInstaller.ENABLE_REVOCABLE_FD) {
@@ -510,7 +509,7 @@
}
final File target = new File(resolveStageDir(), name);
- final FileDescriptor targetFd = Libcore.os.open(target.getAbsolutePath(), O_RDONLY, 0);
+ final FileDescriptor targetFd = Os.open(target.getAbsolutePath(), O_RDONLY, 0);
return new ParcelFileDescriptor(targetFd);
} catch (ErrnoException e) {
@@ -856,15 +855,8 @@
mResolvedInstructionSets.add(archSubDir.getName());
List<File> oatFiles = Arrays.asList(archSubDir.listFiles());
-
- // Only add compiled files associated with the base.
- // Once b/62269291 is resolved, we can add all compiled files again.
- for (File oatFile : oatFiles) {
- if (oatFile.getName().equals("base.art")
- || oatFile.getName().equals("base.odex")
- || oatFile.getName().equals("base.vdex")) {
- mResolvedInheritedFiles.add(oatFile);
- }
+ if (!oatFiles.isEmpty()) {
+ mResolvedInheritedFiles.addAll(oatFiles);
}
}
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
index ec9aa63..eb1e7bd 100644
--- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
+++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
@@ -30,6 +30,7 @@
import android.os.RemoteException;
import android.os.UserHandle;
import android.system.ErrnoException;
+import android.system.Os;
import android.util.ArraySet;
import android.util.Log;
import android.util.Slog;
@@ -190,7 +191,7 @@
*/
public static String realpath(File path) throws IOException {
try {
- return Libcore.os.realpath(path.getAbsolutePath());
+ return Os.realpath(path.getAbsolutePath());
} catch (ErrnoException ee) {
throw ee.rethrowAsIOException();
}
diff --git a/services/net/java/android/net/netlink/NetlinkSocket.java b/services/net/java/android/net/netlink/NetlinkSocket.java
index a9e0cd9..f5f211d 100644
--- a/services/net/java/android/net/netlink/NetlinkSocket.java
+++ b/services/net/java/android/net/netlink/NetlinkSocket.java
@@ -96,7 +96,7 @@
mDescriptor = Os.socket(
OsConstants.AF_NETLINK, OsConstants.SOCK_DGRAM, nlProto);
- Libcore.os.setsockoptInt(
+ Os.setsockoptInt(
mDescriptor, OsConstants.SOL_SOCKET,
OsConstants.SO_RCVBUF, SOCKET_RECV_BUFSIZE);
}
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 7a6fbf3..7d939ac 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -1530,6 +1530,18 @@
public static final String KEY_DISABLE_CHARGE_INDICATION_BOOL =
"disable_charge_indication_bool";
+ /**
+ * Boolean indicating whether to skip the call forwarding (CF) fail-to-disable dialog.
+ * The logic used to determine whether we succeeded in disabling is carrier specific,
+ * so the dialog may not always be accurate.
+ * {@code false} - show CF fail-to-disable dialog.
+ * {@code true} - skip showing CF fail-to-disable dialog.
+ *
+ * @hide
+ */
+ public static final String KEY_SKIP_CF_FAIL_TO_DISABLE_DIALOG_BOOL =
+ "skip_cf_fail_to_disable_dialog_bool";
+
/** The default value for every variable. */
private final static PersistableBundle sDefaults;
@@ -1683,6 +1695,7 @@
sDefaults.putString(KEY_CARRIER_NAME_STRING, "");
sDefaults.putBoolean(KEY_SUPPORT_DIRECT_FDN_DIALING_BOOL, false);
sDefaults.putBoolean(KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL, false);
+ sDefaults.putBoolean(KEY_SKIP_CF_FAIL_TO_DISABLE_DIALOG_BOOL, false);
// MMS defaults
sDefaults.putBoolean(KEY_MMS_ALIAS_ENABLED_BOOL, false);
diff --git a/telephony/java/android/telephony/NetworkScanRequest.java b/telephony/java/android/telephony/NetworkScanRequest.java
index d2aef20..9674c93 100644
--- a/telephony/java/android/telephony/NetworkScanRequest.java
+++ b/telephony/java/android/telephony/NetworkScanRequest.java
@@ -19,6 +19,7 @@
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.ArrayList;
import java.util.Arrays;
/**
@@ -38,6 +39,20 @@
public static final int MAX_BANDS = 8;
/** @hide */
public static final int MAX_CHANNELS = 32;
+ /** @hide */
+ public static final int MAX_MCC_MNC_LIST_SIZE = 20;
+ /** @hide */
+ public static final int MIN_SEARCH_PERIODICITY_SEC = 5;
+ /** @hide */
+ public static final int MAX_SEARCH_PERIODICITY_SEC = 300;
+ /** @hide */
+ public static final int MIN_SEARCH_MAX_SEC = 60;
+ /** @hide */
+ public static final int MAX_SEARCH_MAX_SEC = 3600;
+ /** @hide */
+ public static final int MIN_INCREMENTAL_PERIODICITY_SEC = 1;
+ /** @hide */
+ public static final int MAX_INCREMENTAL_PERIODICITY_SEC = 10;
/** Performs the scan only once */
public static final int SCAN_TYPE_ONE_SHOT = 0;
@@ -46,24 +61,84 @@
*
* The modem will start new scans periodically, and the interval between two scans is usually
* multiple minutes.
- * */
+ */
public static final int SCAN_TYPE_PERIODIC = 1;
/** Defines the type of the scan. */
public int scanType;
+ /**
+ * Search periodicity (in seconds).
+ * Expected range for the input is [5s - 300s]
+ * This value must be less than or equal to maxSearchTime
+ */
+ public int searchPeriodicity;
+
+ /**
+ * Maximum duration of the periodic search (in seconds).
+ * Expected range for the input is [60s - 3600s]
+ * If the search lasts this long, it will be terminated.
+ */
+ public int maxSearchTime;
+
+ /**
+ * Indicates whether the modem should report incremental
+ * results of the network scan to the client.
+ * FALSE – Incremental results are not reported.
+ * TRUE (default) – Incremental results are reported
+ */
+ public boolean incrementalResults;
+
+ /**
+ * Indicates the periodicity with which the modem should
+ * report incremental results to the client (in seconds).
+ * Expected range for the input is [1s - 10s]
+ * This value must be less than or equal to maxSearchTime
+ */
+ public int incrementalResultsPeriodicity;
+
/** Describes the radio access technologies with bands or channels that need to be scanned. */
public RadioAccessSpecifier[] specifiers;
/**
+ * Describes the List of PLMN ids (MCC-MNC)
+ * If any PLMN of this list is found, search should end at that point and
+ * results with all PLMN found till that point should be sent as response.
+ * If list not sent, search to be completed till end and all PLMNs found to be reported.
+ * Max size of array is MAX_MCC_MNC_LIST_SIZE
+ */
+ public ArrayList<String> mccMncs;
+
+ /**
* Creates a new NetworkScanRequest with scanType and network specifiers
*
* @param scanType The type of the scan
* @param specifiers the radio network with bands / channels to be scanned
+ * @param searchPeriodicity Search periodicity (in seconds)
+ * @param maxSearchTime Maximum duration of the periodic search (in seconds)
+ * @param incrementalResults Indicates whether the modem should report incremental
+ * results of the network scan to the client
+ * @param incrementalResultsPeriodicity Indicates the periodicity with which the modem should
+ * report incremental results to the client (in seconds)
+ * @param mccMncs Describes the List of PLMN ids (MCC-MNC)
*/
- public NetworkScanRequest(int scanType, RadioAccessSpecifier[] specifiers) {
+ public NetworkScanRequest(int scanType, RadioAccessSpecifier[] specifiers,
+ int searchPeriodicity,
+ int maxSearchTime,
+ boolean incrementalResults,
+ int incrementalResultsPeriodicity,
+ ArrayList<String> mccMncs) {
this.scanType = scanType;
this.specifiers = specifiers;
+ this.searchPeriodicity = searchPeriodicity;
+ this.maxSearchTime = maxSearchTime;
+ this.incrementalResults = incrementalResults;
+ this.incrementalResultsPeriodicity = incrementalResultsPeriodicity;
+ if (mccMncs != null) {
+ this.mccMncs = mccMncs;
+ } else {
+ this.mccMncs = new ArrayList<>();
+ }
}
@Override
@@ -75,6 +150,11 @@
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(scanType);
dest.writeParcelableArray(specifiers, flags);
+ dest.writeInt(searchPeriodicity);
+ dest.writeInt(maxSearchTime);
+ dest.writeBoolean(incrementalResults);
+ dest.writeInt(incrementalResultsPeriodicity);
+ dest.writeStringList(mccMncs);
}
private NetworkScanRequest(Parcel in) {
@@ -82,6 +162,12 @@
specifiers = (RadioAccessSpecifier[]) in.readParcelableArray(
Object.class.getClassLoader(),
RadioAccessSpecifier.class);
+ searchPeriodicity = in.readInt();
+ maxSearchTime = in.readInt();
+ incrementalResults = in.readBoolean();
+ incrementalResultsPeriodicity = in.readInt();
+ mccMncs = new ArrayList<>();
+ in.readStringList(mccMncs);
}
@Override
@@ -99,13 +185,24 @@
}
return (scanType == nsr.scanType
- && Arrays.equals(specifiers, nsr.specifiers));
+ && Arrays.equals(specifiers, nsr.specifiers)
+ && searchPeriodicity == nsr.searchPeriodicity
+ && maxSearchTime == nsr.maxSearchTime
+ && incrementalResults == nsr.incrementalResults
+ && incrementalResultsPeriodicity == nsr.incrementalResultsPeriodicity
+ && (((mccMncs != null)
+ && mccMncs.equals(nsr.mccMncs))));
}
@Override
public int hashCode () {
return ((scanType * 31)
- + (Arrays.hashCode(specifiers)) * 37);
+ + (Arrays.hashCode(specifiers)) * 37
+ + (searchPeriodicity * 41)
+ + (maxSearchTime * 43)
+ + ((incrementalResults == true? 1 : 0) * 47)
+ + (incrementalResultsPeriodicity * 53)
+ + (mccMncs.hashCode() * 59));
}
public static final Creator<NetworkScanRequest> CREATOR =
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index e448fb2..116e711 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -1197,15 +1197,6 @@
}
}
- /**
- * @Deprecated to be removed Q3 2013 use {@link #getVoiceNetworkType}
- * @hide
- */
- public int getNetworkType() {
- Rlog.e(LOG_TAG, "ServiceState.getNetworkType() DEPRECATED will be removed *******");
- return rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology);
- }
-
/** @hide */
public int getDataNetworkType() {
return rilRadioTechnologyToNetworkType(mRilDataRadioTechnology);
diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java
index 2f85a1d..c3b2c48 100644
--- a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java
+++ b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java
@@ -113,6 +113,10 @@
@Override
public final int initialize(final int subscriptionId,
final IMbmsDownloadSessionCallback callback) throws RemoteException {
+ if (callback == null) {
+ throw new NullPointerException("Callback must not be null");
+ }
+
final int uid = Binder.getCallingUid();
callback.asBinder().linkToDeath(new DeathRecipient() {
@Override
@@ -240,6 +244,13 @@
public final int registerStateCallback(final DownloadRequest downloadRequest,
final IDownloadStateCallback callback, int flags) throws RemoteException {
final int uid = Binder.getCallingUid();
+ if (downloadRequest == null) {
+ throw new NullPointerException("Download request must not be null");
+ }
+ if (callback == null) {
+ throw new NullPointerException("Callback must not be null");
+ }
+
DeathRecipient deathRecipient = new DeathRecipient() {
@Override
public void binderDied() {
@@ -292,6 +303,13 @@
public final int unregisterStateCallback(
final DownloadRequest downloadRequest, final IDownloadStateCallback callback)
throws RemoteException {
+ if (downloadRequest == null) {
+ throw new NullPointerException("Download request must not be null");
+ }
+ if (callback == null) {
+ throw new NullPointerException("Callback must not be null");
+ }
+
DeathRecipient deathRecipient =
mDownloadCallbackDeathRecipients.remove(callback.asBinder());
if (deathRecipient == null) {
diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java
index f8f370a..65b726d 100644
--- a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java
+++ b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java
@@ -65,6 +65,10 @@
@Override
public final int initialize(final IMbmsStreamingSessionCallback callback,
final int subscriptionId) throws RemoteException {
+ if (callback == null) {
+ throw new NullPointerException("Callback must not be null");
+ }
+
final int uid = Binder.getCallingUid();
callback.asBinder().linkToDeath(new DeathRecipient() {
@Override
@@ -152,6 +156,10 @@
@Override
public int startStreaming(final int subscriptionId, String serviceId,
final IStreamingServiceCallback callback) throws RemoteException {
+ if (callback == null) {
+ throw new NullPointerException("Callback must not be null");
+ }
+
final int uid = Binder.getCallingUid();
callback.asBinder().linkToDeath(new DeathRecipient() {
@Override
diff --git a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
index 9057a10..b4b8094 100644
--- a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
+++ b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
@@ -17,10 +17,12 @@
package com.android.server;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -37,7 +39,6 @@
import android.os.Binder;
import android.os.ParcelFileDescriptor;
import android.support.test.filters.SmallTest;
-import android.system.OsConstants;
import java.net.Socket;
import java.util.Arrays;
@@ -53,8 +54,8 @@
@RunWith(Parameterized.class)
public class IpSecServiceParameterizedTest {
- private static final int DROID_SPI = 0xD1201D;
- private static final int DROID_SPI2 = DROID_SPI + 1;
+ private static final int TEST_SPI_OUT = 0xD1201D;
+ private static final int TEST_SPI_IN = TEST_SPI_OUT + 1;
private final String mRemoteAddr;
@@ -81,6 +82,16 @@
IpSecService.IpSecServiceConfiguration mMockIpSecSrvConfig;
IpSecService mIpSecService;
+ private static final IpSecAlgorithm AUTH_ALGO =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, AUTH_KEY, AUTH_KEY.length * 4);
+ private static final IpSecAlgorithm CRYPT_ALGO =
+ new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ private static final IpSecAlgorithm AEAD_ALGO =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, CRYPT_KEY, CRYPT_KEY.length * 4);
+
+ private static final int[] DIRECTIONS =
+ new int[] {IpSecTransform.DIRECTION_IN, IpSecTransform.DIRECTION_OUT};
+
public IpSecServiceParameterizedTest(String remoteAddr) {
mRemoteAddr = remoteAddr;
}
@@ -103,14 +114,14 @@
eq(IpSecTransform.DIRECTION_OUT),
anyString(),
eq(mRemoteAddr),
- eq(DROID_SPI)))
- .thenReturn(DROID_SPI);
+ eq(TEST_SPI_OUT)))
+ .thenReturn(TEST_SPI_OUT);
IpSecSpiResponse spiResp =
mIpSecService.reserveSecurityParameterIndex(
- IpSecTransform.DIRECTION_OUT, mRemoteAddr, DROID_SPI, new Binder());
+ IpSecTransform.DIRECTION_OUT, mRemoteAddr, TEST_SPI_OUT, new Binder());
assertEquals(IpSecManager.Status.OK, spiResp.status);
- assertEquals(DROID_SPI, spiResp.spi);
+ assertEquals(TEST_SPI_OUT, spiResp.spi);
}
@Test
@@ -120,56 +131,60 @@
eq(IpSecTransform.DIRECTION_OUT),
anyString(),
eq(mRemoteAddr),
- eq(DROID_SPI)))
- .thenReturn(DROID_SPI);
+ eq(TEST_SPI_OUT)))
+ .thenReturn(TEST_SPI_OUT);
IpSecSpiResponse spiResp =
mIpSecService.reserveSecurityParameterIndex(
- IpSecTransform.DIRECTION_OUT, mRemoteAddr, DROID_SPI, new Binder());
+ IpSecTransform.DIRECTION_OUT, mRemoteAddr, TEST_SPI_OUT, new Binder());
mIpSecService.releaseSecurityParameterIndex(spiResp.resourceId);
verify(mMockNetd)
.ipSecDeleteSecurityAssociation(
- eq(spiResp.resourceId), anyInt(), anyString(), anyString(), eq(DROID_SPI));
+ eq(spiResp.resourceId),
+ anyInt(),
+ anyString(),
+ anyString(),
+ eq(TEST_SPI_OUT));
}
- IpSecConfig buildIpSecConfig() throws Exception {
- IpSecManager ipSecManager = new IpSecManager(mIpSecService);
-
- // Mocking the netd to allocate SPI
+ private int getNewSpiResourceId(int direction, String remoteAddress, int returnSpi)
+ throws Exception {
when(mMockNetd.ipSecAllocateSpi(anyInt(), anyInt(), anyString(), anyString(), anyInt()))
- .thenReturn(DROID_SPI)
- .thenReturn(DROID_SPI2);
+ .thenReturn(returnSpi);
- IpSecAlgorithm encryptAlgo = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
- IpSecAlgorithm authAlgo =
- new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, AUTH_KEY, AUTH_KEY.length * 8);
+ IpSecSpiResponse spi =
+ mIpSecService.reserveSecurityParameterIndex(
+ direction,
+ NetworkUtils.numericToInetAddress(remoteAddress).getHostAddress(),
+ IpSecManager.INVALID_SECURITY_PARAMETER_INDEX,
+ new Binder());
+ return spi.resourceId;
+ }
- /** Allocate and add SPI records in the IpSecService through IpSecManager interface. */
- IpSecManager.SecurityParameterIndex outSpi =
- ipSecManager.reserveSecurityParameterIndex(
- IpSecTransform.DIRECTION_OUT,
- NetworkUtils.numericToInetAddress(mRemoteAddr));
- IpSecManager.SecurityParameterIndex inSpi =
- ipSecManager.reserveSecurityParameterIndex(
- IpSecTransform.DIRECTION_IN,
- NetworkUtils.numericToInetAddress(mRemoteAddr));
-
- IpSecConfig config = new IpSecConfig();
- config.setSpiResourceId(IpSecTransform.DIRECTION_IN, inSpi.getResourceId());
- config.setSpiResourceId(IpSecTransform.DIRECTION_OUT, outSpi.getResourceId());
- config.setEncryption(IpSecTransform.DIRECTION_OUT, encryptAlgo);
- config.setAuthentication(IpSecTransform.DIRECTION_OUT, authAlgo);
- config.setEncryption(IpSecTransform.DIRECTION_IN, encryptAlgo);
- config.setAuthentication(IpSecTransform.DIRECTION_IN, authAlgo);
+ private void addDefaultSpisAndRemoteAddrToIpSecConfig(IpSecConfig config) throws Exception {
+ config.setSpiResourceId(
+ IpSecTransform.DIRECTION_OUT,
+ getNewSpiResourceId(IpSecTransform.DIRECTION_OUT, mRemoteAddr, TEST_SPI_OUT));
+ config.setSpiResourceId(
+ IpSecTransform.DIRECTION_IN,
+ getNewSpiResourceId(IpSecTransform.DIRECTION_IN, mRemoteAddr, TEST_SPI_IN));
config.setRemoteAddress(mRemoteAddr);
- return config;
+ }
+
+ private void addAuthAndCryptToIpSecConfig(IpSecConfig config) throws Exception {
+ for (int direction : DIRECTIONS) {
+ config.setEncryption(direction, CRYPT_ALGO);
+ config.setAuthentication(direction, AUTH_ALGO);
+ }
}
@Test
public void testCreateTransportModeTransform() throws Exception {
- IpSecConfig ipSecConfig = buildIpSecConfig();
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+ addAuthAndCryptToIpSecConfig(ipSecConfig);
IpSecTransformResponse createTransformResp =
mIpSecService.createTransportModeTransform(ipSecConfig, new Binder());
@@ -183,13 +198,72 @@
anyString(),
anyString(),
anyLong(),
- eq(DROID_SPI),
+ eq(TEST_SPI_OUT),
eq(IpSecAlgorithm.AUTH_HMAC_SHA256),
eq(AUTH_KEY),
anyInt(),
eq(IpSecAlgorithm.CRYPT_AES_CBC),
eq(CRYPT_KEY),
anyInt(),
+ eq(""),
+ isNull(),
+ eq(0),
+ anyInt(),
+ anyInt(),
+ anyInt());
+ verify(mMockNetd)
+ .ipSecAddSecurityAssociation(
+ eq(createTransformResp.resourceId),
+ anyInt(),
+ eq(IpSecTransform.DIRECTION_IN),
+ anyString(),
+ anyString(),
+ anyLong(),
+ eq(TEST_SPI_IN),
+ eq(IpSecAlgorithm.AUTH_HMAC_SHA256),
+ eq(AUTH_KEY),
+ anyInt(),
+ eq(IpSecAlgorithm.CRYPT_AES_CBC),
+ eq(CRYPT_KEY),
+ anyInt(),
+ eq(""),
+ isNull(),
+ eq(0),
+ anyInt(),
+ anyInt(),
+ anyInt());
+ }
+
+ @Test
+ public void testCreateTransportModeTransformAead() throws Exception {
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+
+ ipSecConfig.setAuthenticatedEncryption(IpSecTransform.DIRECTION_OUT, AEAD_ALGO);
+ ipSecConfig.setAuthenticatedEncryption(IpSecTransform.DIRECTION_IN, AEAD_ALGO);
+
+ IpSecTransformResponse createTransformResp =
+ mIpSecService.createTransportModeTransform(ipSecConfig, new Binder());
+ assertEquals(IpSecManager.Status.OK, createTransformResp.status);
+
+ verify(mMockNetd)
+ .ipSecAddSecurityAssociation(
+ eq(createTransformResp.resourceId),
+ anyInt(),
+ eq(IpSecTransform.DIRECTION_OUT),
+ anyString(),
+ anyString(),
+ anyLong(),
+ eq(TEST_SPI_OUT),
+ eq(""),
+ isNull(),
+ eq(0),
+ eq(""),
+ isNull(),
+ eq(0),
+ eq(IpSecAlgorithm.AUTH_CRYPT_AES_GCM),
+ eq(CRYPT_KEY),
+ anyInt(),
anyInt(),
anyInt(),
anyInt());
@@ -201,11 +275,14 @@
anyString(),
anyString(),
anyLong(),
- eq(DROID_SPI2),
- eq(IpSecAlgorithm.AUTH_HMAC_SHA256),
- eq(AUTH_KEY),
- anyInt(),
- eq(IpSecAlgorithm.CRYPT_AES_CBC),
+ eq(TEST_SPI_IN),
+ eq(""),
+ isNull(),
+ eq(0),
+ eq(""),
+ isNull(),
+ eq(0),
+ eq(IpSecAlgorithm.AUTH_CRYPT_AES_GCM),
eq(CRYPT_KEY),
anyInt(),
anyInt(),
@@ -214,8 +291,68 @@
}
@Test
+ public void testCreateInvalidConfigAeadWithAuth() throws Exception {
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+
+ for (int direction : DIRECTIONS) {
+ ipSecConfig.setAuthentication(direction, AUTH_ALGO);
+ ipSecConfig.setAuthenticatedEncryption(direction, AEAD_ALGO);
+ }
+
+ try {
+ mIpSecService.createTransportModeTransform(ipSecConfig, new Binder());
+ fail(
+ "IpSecService should have thrown an error on authentication being"
+ + " enabled with authenticated encryption");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ @Test
+ public void testCreateInvalidConfigAeadWithCrypt() throws Exception {
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+
+ for (int direction : DIRECTIONS) {
+ ipSecConfig.setEncryption(direction, CRYPT_ALGO);
+ ipSecConfig.setAuthenticatedEncryption(direction, AEAD_ALGO);
+ }
+
+ try {
+ mIpSecService.createTransportModeTransform(ipSecConfig, new Binder());
+ fail(
+ "IpSecService should have thrown an error on encryption being"
+ + " enabled with authenticated encryption");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ @Test
+ public void testCreateInvalidConfigAeadWithAuthAndCrypt() throws Exception {
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+
+ for (int direction : DIRECTIONS) {
+ ipSecConfig.setAuthentication(direction, AUTH_ALGO);
+ ipSecConfig.setEncryption(direction, CRYPT_ALGO);
+ ipSecConfig.setAuthenticatedEncryption(direction, AEAD_ALGO);
+ }
+
+ try {
+ mIpSecService.createTransportModeTransform(ipSecConfig, new Binder());
+ fail(
+ "IpSecService should have thrown an error on authentication and encryption being"
+ + " enabled with authenticated encryption");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ @Test
public void testDeleteTransportModeTransform() throws Exception {
- IpSecConfig ipSecConfig = buildIpSecConfig();
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+ addAuthAndCryptToIpSecConfig(ipSecConfig);
IpSecTransformResponse createTransformResp =
mIpSecService.createTransportModeTransform(ipSecConfig, new Binder());
@@ -227,19 +364,21 @@
eq(IpSecTransform.DIRECTION_OUT),
anyString(),
anyString(),
- eq(DROID_SPI));
+ eq(TEST_SPI_OUT));
verify(mMockNetd)
.ipSecDeleteSecurityAssociation(
eq(createTransformResp.resourceId),
eq(IpSecTransform.DIRECTION_IN),
anyString(),
anyString(),
- eq(DROID_SPI2));
+ eq(TEST_SPI_IN));
}
@Test
public void testApplyTransportModeTransform() throws Exception {
- IpSecConfig ipSecConfig = buildIpSecConfig();
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+ addAuthAndCryptToIpSecConfig(ipSecConfig);
IpSecTransformResponse createTransformResp =
mIpSecService.createTransportModeTransform(ipSecConfig, new Binder());
@@ -255,7 +394,7 @@
eq(IpSecTransform.DIRECTION_OUT),
anyString(),
anyString(),
- eq(DROID_SPI));
+ eq(TEST_SPI_OUT));
verify(mMockNetd)
.ipSecApplyTransportModeTransform(
eq(pfd.getFileDescriptor()),
@@ -263,7 +402,7 @@
eq(IpSecTransform.DIRECTION_IN),
anyString(),
anyString(),
- eq(DROID_SPI2));
+ eq(TEST_SPI_IN));
}
@Test
diff --git a/tools/bit/Android.bp b/tools/bit/Android.bp
index 258e9b5..a806271 100644
--- a/tools/bit/Android.bp
+++ b/tools/bit/Android.bp
@@ -30,6 +30,11 @@
"util.cpp",
],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
static_libs: [
"libexpat",
"libinstrumentation",
diff --git a/tools/bit/adb.cpp b/tools/bit/adb.cpp
index 0c8424d..93fda54 100644
--- a/tools/bit/adb.cpp
+++ b/tools/bit/adb.cpp
@@ -293,7 +293,9 @@
print_command(cmd);
int fds[2];
- pipe(fds);
+ if (0 != pipe(fds)) {
+ return errno;
+ }
pid_t pid = fork();
diff --git a/tools/bit/command.cpp b/tools/bit/command.cpp
index 9a8449b..f95ea11 100644
--- a/tools/bit/command.cpp
+++ b/tools/bit/command.cpp
@@ -105,7 +105,9 @@
}
int fds[2];
- pipe(fds);
+ if (0 != pipe(fds)) {
+ return string();
+ }
pid_t pid = fork();
@@ -187,7 +189,7 @@
int
exec_with_path_search(const char* prog, char const* const* argv, char const* const* envp)
{
- if (prog[0] == '/') {
+ if (strchr(prog, '/') != NULL) {
return execve(prog, (char*const*)argv, (char*const*)envp);
} else {
char* pathEnv = strdup(getenv("PATH"));
diff --git a/tools/bit/main.cpp b/tools/bit/main.cpp
index d056ba5..e81898f 100644
--- a/tools/bit/main.cpp
+++ b/tools/bit/main.cpp
@@ -561,6 +561,15 @@
}
}
+static void
+chdir_or_exit(const char *path) {
+ // TODO: print_command("cd", path);
+ if (0 != chdir(path)) {
+ print_error("Error: Could not chdir: %s", path);
+ exit(1);
+ }
+}
+
/**
* Run the build, install, and test actions.
*/
@@ -579,12 +588,12 @@
const string buildProduct = get_required_env("TARGET_PRODUCT", false);
const string buildVariant = get_required_env("TARGET_BUILD_VARIANT", false);
const string buildType = get_required_env("TARGET_BUILD_TYPE", false);
- const string buildDevice = get_build_var(buildTop, "TARGET_DEVICE", false);
- const string buildId = get_build_var(buildTop, "BUILD_ID", false);
- const string buildOut = get_out_dir();
- // TODO: print_command("cd", buildTop.c_str());
- chdir(buildTop.c_str());
+ chdir_or_exit(buildTop.c_str());
+
+ const string buildDevice = get_build_var("TARGET_DEVICE", false);
+ const string buildId = get_build_var("BUILD_ID", false);
+ const string buildOut = get_out_dir();
// Get the modules for the targets
map<string,Module> modules;
@@ -952,7 +961,7 @@
const string buildProduct = get_required_env("TARGET_PRODUCT", false);
const string buildOut = get_out_dir();
- chdir(buildTop.c_str());
+ chdir_or_exit(buildTop.c_str());
string buildDevice = sniff_device_name(buildOut, buildProduct);
diff --git a/tools/bit/make.cpp b/tools/bit/make.cpp
index a800241..ef3ccc5 100644
--- a/tools/bit/make.cpp
+++ b/tools/bit/make.cpp
@@ -36,31 +36,16 @@
map<string,string> g_buildVars;
-static unsigned int
-get_thread_count()
-{
- unsigned int threads = std::thread::hardware_concurrency();
- // Guess if the value cannot be computed
- return threads == 0 ? 4 : static_cast<unsigned int>(threads * 1.3f);
-}
-
string
-get_build_var(const string& buildTop, const string& name, bool quiet)
+get_build_var(const string& name, bool quiet)
{
int err;
map<string,string>::iterator it = g_buildVars.find(name);
if (it == g_buildVars.end()) {
- Command cmd("make");
- cmd.AddArg("--no-print-directory");
- cmd.AddArg(string("-j") + std::to_string(get_thread_count()));
- cmd.AddArg("-C");
- cmd.AddArg(buildTop);
- cmd.AddArg("-f");
- cmd.AddArg("build/core/config.mk");
- cmd.AddArg(string("dumpvar-") + name);
- cmd.AddEnv("CALLED_FROM_SETUP", "true");
- cmd.AddEnv("BUILD_SYSTEM", "build/core");
+ Command cmd("build/soong/soong_ui.bash");
+ cmd.AddArg("--dumpvar-mode");
+ cmd.AddArg(name);
string output = trim(get_command_output(cmd, &err, quiet));
if (err == 0) {
@@ -208,10 +193,8 @@
int
build_goals(const vector<string>& goals)
{
- Command cmd("make");
- cmd.AddArg(string("-j") + std::to_string(get_thread_count()));
- cmd.AddArg("-f");
- cmd.AddArg("build/core/main.mk");
+ Command cmd("build/soong/soong_ui.bash");
+ cmd.AddArg("--make-mode");
for (size_t i=0; i<goals.size(); i++) {
cmd.AddArg(goals[i]);
}
diff --git a/tools/bit/make.h b/tools/bit/make.h
index bb83c6e..1c9504d 100644
--- a/tools/bit/make.h
+++ b/tools/bit/make.h
@@ -31,7 +31,7 @@
vector<string> installed;
};
-string get_build_var(const string& buildTop, const string& name, bool quiet);
+string get_build_var(const string& name, bool quiet);
/**
* Poke around in the out directory and try to find a device name that matches
diff --git a/tools/bit/util.cpp b/tools/bit/util.cpp
index fc93bcb..9223931 100644
--- a/tools/bit/util.cpp
+++ b/tools/bit/util.cpp
@@ -101,7 +101,6 @@
void
get_directory_contents(const string& name, map<string,FileInfo>* results)
{
- int err;
DIR* dir = opendir(name.c_str());
if (dir == NULL) {
return;
@@ -241,7 +240,9 @@
fseek(file, 0, SEEK_SET);
char* buf = (char*)malloc(size);
- fread(buf, 1, size, file);
+ if ((size_t) size != fread(buf, 1, size, file)) {
+ return string();
+ }
string result(buf, size);
diff --git a/tools/incident_report/Android.bp b/tools/incident_report/Android.bp
index ab55dbd..f2d0d0f 100644
--- a/tools/incident_report/Android.bp
+++ b/tools/incident_report/Android.bp
@@ -31,5 +31,5 @@
"libprotobuf-cpp-full",
],
- cflags: ["-Wno-unused-parameter"],
+ cflags: ["-Wall", "-Werror"],
}
diff --git a/tools/incident_report/printer.cpp b/tools/incident_report/printer.cpp
index bd660dd2..bff1025 100644
--- a/tools/incident_report/printer.cpp
+++ b/tools/incident_report/printer.cpp
@@ -70,7 +70,6 @@
len = vsnprintf(mBuf, mBufSize, format, args);
va_end(args);
- bool truncated = (len >= mBufSize) && (reallocate(len) < len);
va_start(args, format);
len = vsnprintf(mBuf, mBufSize, format, args);
diff --git a/tools/incident_section_gen/Android.bp b/tools/incident_section_gen/Android.bp
index 1756e06..f07445a 100644
--- a/tools/incident_section_gen/Android.bp
+++ b/tools/incident_section_gen/Android.bp
@@ -22,6 +22,8 @@
cflags: [
"-g",
"-O0",
+ "-Wall",
+ "-Werror",
],
srcs: ["main.cpp"],
shared_libs: [
diff --git a/tools/locked_region_code_injection/Android.mk b/tools/locked_region_code_injection/Android.mk
index 77d5163..bb5f4d6 100644
--- a/tools/locked_region_code_injection/Android.mk
+++ b/tools/locked_region_code_injection/Android.mk
@@ -6,10 +6,10 @@
LOCAL_MODULE := lockedregioncodeinjection
LOCAL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_STATIC_JAVA_LIBRARIES := \
- asm-5.2 \
- asm-commons-5.2 \
- asm-tree-5.2 \
- asm-analysis-5.2 \
+ asm-6.0_BETA \
+ asm-commons-6.0_BETA \
+ asm-tree-6.0_BETA \
+ asm-analysis-6.0_BETA \
guava-21.0 \
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/locked_region_code_injection/src/lockedregioncodeinjection/LockFindingClassVisitor.java b/tools/locked_region_code_injection/src/lockedregioncodeinjection/LockFindingClassVisitor.java
index 99ef8a7..a60f2a2 100644
--- a/tools/locked_region_code_injection/src/lockedregioncodeinjection/LockFindingClassVisitor.java
+++ b/tools/locked_region_code_injection/src/lockedregioncodeinjection/LockFindingClassVisitor.java
@@ -76,7 +76,7 @@
private MethodVisitor chain;
public LockFindingMethodVisitor(String owner, MethodNode mn, MethodVisitor chain) {
- super(Opcodes.ASM5, mn);
+ super(Opcodes.ASM6, mn);
assert owner != null;
this.owner = owner;
this.chain = chain;
diff --git a/tools/locked_region_code_injection/test/lockedregioncodeinjection/TestMain.java b/tools/locked_region_code_injection/test/lockedregioncodeinjection/TestMain.java
index b86954d..c408b9e 100644
--- a/tools/locked_region_code_injection/test/lockedregioncodeinjection/TestMain.java
+++ b/tools/locked_region_code_injection/test/lockedregioncodeinjection/TestMain.java
@@ -23,11 +23,14 @@
* <code>
* set -x
*
+ * croot frameworks/base/tools/locked_region_code_injection
+ *
* # Clean
+ * mkdir -p out
* rm -fr out/*
*
* # Make booster
- * javac -cp lib/asm-all-5.2.jar src/*/*.java -d out/
+ * javac -cp lib/asm-6.0_BETA.jar:lib/asm-commons-6.0_BETA.jar:lib/asm-tree-6.0_BETA.jar:lib/asm-analysis-6.0_BETA.jar:lib/guava-21.0.jar src/*/*.java -d out/
* pushd out
* jar cfe lockedregioncodeinjection.jar lockedregioncodeinjection.Main */*.class
* popd
@@ -40,7 +43,7 @@
* popd
*
* # Run tool on unit tests.
- * java -ea -cp lib/asm-all-5.2.jar:out/lockedregioncodeinjection.jar \
+ * java -ea -cp lib/asm-6.0_BETA.jar:lib/asm-commons-6.0_BETA.jar:lib/asm-tree-6.0_BETA.jar:lib/asm-analysis-6.0_BETA.jar:lib/guava-21.0.jar:out/lockedregioncodeinjection.jar \
* lockedregioncodeinjection.Main \
* -i out/test_input.jar -o out/test_output.jar \
* --targets 'Llockedregioncodeinjection/TestTarget;' \