diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/AppOpsManager.java | 2 | ||||
-rw-r--r-- | core/java/android/app/FragmentManager.java | 4 | ||||
-rw-r--r-- | core/java/android/ddm/DdmHandleProfiling.java | 47 | ||||
-rw-r--r-- | core/java/android/inputmethodservice/IInputMethodSessionWrapper.java | 10 | ||||
-rw-r--r-- | core/java/android/net/SSLCertificateSocketFactory.java | 2 | ||||
-rw-r--r-- | core/java/android/net/arp/ArpPeer.java | 174 | ||||
-rw-r--r-- | core/java/android/os/BatteryStats.java | 16 | ||||
-rw-r--r-- | core/java/android/os/Bundle.java | 2 | ||||
-rw-r--r-- | core/java/android/os/Process.java | 4 | ||||
-rw-r--r-- | core/java/android/os/RecoverySystem.java | 24 | ||||
-rw-r--r-- | core/java/android/os/SELinux.java | 12 | ||||
-rw-r--r-- | core/java/android/text/MeasuredText.java | 2 | ||||
-rw-r--r-- | core/java/android/util/CharsetUtils.java | 198 | ||||
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 4 | ||||
-rw-r--r-- | core/java/com/android/internal/os/ZygoteConnection.java | 77 | ||||
-rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 9 |
16 files changed, 65 insertions, 522 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 183927b..aece462 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -369,8 +369,8 @@ public class AppOpsManager { android.Manifest.permission.WRITE_CALL_LOG, android.Manifest.permission.READ_CALENDAR, android.Manifest.permission.WRITE_CALENDAR, - null, // no permission required for notifications android.Manifest.permission.ACCESS_WIFI_STATE, + null, // no permission required for notifications null, // neighboring cells shares the coarse location perm android.Manifest.permission.CALL_PHONE, android.Manifest.permission.READ_SMS, diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 4371907..bf2a629 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -574,12 +574,12 @@ final class FragmentManagerImpl extends FragmentManager { return null; } if (index >= mActive.size()) { - throwException(new IllegalStateException("Fragement no longer exists for key " + throwException(new IllegalStateException("Fragment no longer exists for key " + key + ": index " + index)); } Fragment f = mActive.get(index); if (f == null) { - throwException(new IllegalStateException("Fragement no longer exists for key " + throwException(new IllegalStateException("Fragment no longer exists for key " + key + ": index " + index)); } return f; diff --git a/core/java/android/ddm/DdmHandleProfiling.java b/core/java/android/ddm/DdmHandleProfiling.java index ec08393..537763d 100644 --- a/core/java/android/ddm/DdmHandleProfiling.java +++ b/core/java/android/ddm/DdmHandleProfiling.java @@ -37,6 +37,7 @@ public class DdmHandleProfiling extends ChunkHandler { public static final int CHUNK_SPSS = type("SPSS"); public static final int CHUNK_SPSE = type("SPSE"); + private static final boolean DEBUG = false; private static DdmHandleProfiling mInstance = new DdmHandleProfiling(); @@ -72,7 +73,7 @@ public class DdmHandleProfiling extends ChunkHandler { * Handle a chunk of data. */ public Chunk handleChunk(Chunk request) { - if (false) + if (DEBUG) Log.v("ddm-heap", "Handling " + name(request.type) + " chunk"); int type = request.type; @@ -83,13 +84,13 @@ public class DdmHandleProfiling extends ChunkHandler { } else if (type == CHUNK_MPSS) { return handleMPSS(request); } else if (type == CHUNK_MPSE) { - return handleMPSE(request); + return handleMPSEOrSPSE(request, "Method"); } else if (type == CHUNK_MPRQ) { return handleMPRQ(request); } else if (type == CHUNK_SPSS) { return handleSPSS(request); } else if (type == CHUNK_SPSE) { - return handleSPSE(request); + return handleMPSEOrSPSE(request, "Sample"); } else { throw new RuntimeException("Unknown packet " + ChunkHandler.name(type)); @@ -106,7 +107,7 @@ public class DdmHandleProfiling extends ChunkHandler { int flags = in.getInt(); int len = in.getInt(); String fileName = getString(in, len); - if (false) + if (DEBUG) Log.v("ddm-heap", "Method profiling start: filename='" + fileName + "', size=" + bufferSize + ", flags=" + flags); @@ -146,7 +147,7 @@ public class DdmHandleProfiling extends ChunkHandler { int bufferSize = in.getInt(); int flags = in.getInt(); - if (false) { + if (DEBUG) { Log.v("ddm-heap", "Method prof stream start: size=" + bufferSize + ", flags=" + flags); } @@ -160,20 +161,18 @@ public class DdmHandleProfiling extends ChunkHandler { } /* - * Handle a "Method Profiling w/Streaming End" request. + * Handle a "Method Profiling w/Streaming End" request or a + * "Sample Profiling w/Streaming End" request. */ - private Chunk handleMPSE(Chunk request) { - byte result; - - if (false) { - Log.v("ddm-heap", "Method prof stream end"); + private Chunk handleMPSEOrSPSE(Chunk request, String type) { + if (DEBUG) { + Log.v("ddm-heap", type + " prof stream end"); } try { Debug.stopMethodTracing(); - result = 0; } catch (RuntimeException re) { - Log.w("ddm-heap", "Method prof stream end failed: " + Log.w("ddm-heap", type + " prof stream end failed: " + re.getMessage()); return createFailChunk(1, re.getMessage()); } @@ -202,7 +201,7 @@ public class DdmHandleProfiling extends ChunkHandler { int bufferSize = in.getInt(); int flags = in.getInt(); int interval = in.getInt(); - if (false) { + if (DEBUG) { Log.v("ddm-heap", "Sample prof stream start: size=" + bufferSize + ", flags=" + flags + ", interval=" + interval); } @@ -214,25 +213,5 @@ public class DdmHandleProfiling extends ChunkHandler { return createFailChunk(1, re.getMessage()); } } - - /* - * Handle a "Sample Profiling w/Streaming End" request. - */ - private Chunk handleSPSE(Chunk request) { - if (false) { - Log.v("ddm-heap", "Sample prof stream end"); - } - - try { - Debug.stopMethodTracing(); - } catch (RuntimeException re) { - Log.w("ddm-heap", "Sample prof stream end failed: " - + re.getMessage()); - return createFailChunk(1, re.getMessage()); - } - - /* VM sent the (perhaps very large) response directly */ - return null; - } } diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java index 726dcec..bbea8ff 100644 --- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java +++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java @@ -75,7 +75,15 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub @Override public void executeMessage(Message msg) { if (mInputMethodSession == null) { - // The session has been finished. + // The session has been finished. Args needs to be recycled + // for cases below. + switch (msg.what) { + case DO_UPDATE_SELECTION: + case DO_APP_PRIVATE_COMMAND: { + SomeArgs args = (SomeArgs)msg.obj; + args.recycle(); + } + } return; } diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java index 208b212..b0278d3 100644 --- a/core/java/android/net/SSLCertificateSocketFactory.java +++ b/core/java/android/net/SSLCertificateSocketFactory.java @@ -533,7 +533,7 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { @Override public String[] getDefaultCipherSuites() { - return getDelegate().getSupportedCipherSuites(); + return getDelegate().getDefaultCipherSuites(); } @Override diff --git a/core/java/android/net/arp/ArpPeer.java b/core/java/android/net/arp/ArpPeer.java deleted file mode 100644 index 2013b11..0000000 --- a/core/java/android/net/arp/ArpPeer.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2012 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.arp; - -import android.net.LinkAddress; -import android.net.LinkProperties; -import android.net.RouteInfo; -import android.os.SystemClock; -import android.util.Log; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.Inet6Address; -import java.net.SocketException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; - -import libcore.net.RawSocket; - -/** - * This class allows simple ARP exchanges over an uninitialized network - * interface. - * - * @hide - */ -public class ArpPeer { - private static final boolean DBG = false; - private static final String TAG = "ArpPeer"; - private String mInterfaceName; - private final InetAddress mMyAddr; - private final byte[] mMyMac = new byte[6]; - private final InetAddress mPeer; - private final RawSocket mSocket; - private final byte[] L2_BROADCAST; // TODO: refactor from DhcpClient.java - private static final int MAX_LENGTH = 1500; // refactor from DhcpPacket.java - private static final int ETHERNET_TYPE = 1; - private static final int ARP_LENGTH = 28; - private static final int MAC_ADDR_LENGTH = 6; - private static final int IPV4_LENGTH = 4; - - public ArpPeer(String interfaceName, InetAddress myAddr, String mac, - InetAddress peer) throws SocketException { - mInterfaceName = interfaceName; - mMyAddr = myAddr; - - if (mac != null) { - for (int i = 0; i < MAC_ADDR_LENGTH; i++) { - mMyMac[i] = (byte) Integer.parseInt(mac.substring( - i*3, (i*3) + 2), 16); - } - } - - if (myAddr instanceof Inet6Address || peer instanceof Inet6Address) { - throw new IllegalArgumentException("IPv6 unsupported"); - } - - mPeer = peer; - L2_BROADCAST = new byte[MAC_ADDR_LENGTH]; - Arrays.fill(L2_BROADCAST, (byte) 0xFF); - - mSocket = new RawSocket(mInterfaceName, RawSocket.ETH_P_ARP); - } - - /** - * Returns the MAC address (or null if timeout) for the requested - * peer. - */ - public byte[] doArp(int timeoutMillis) { - ByteBuffer buf = ByteBuffer.allocate(MAX_LENGTH); - byte[] desiredIp = mPeer.getAddress(); - long timeout = SystemClock.elapsedRealtime() + timeoutMillis; - - // construct ARP request packet, using a ByteBuffer as a - // convenient container - buf.clear(); - buf.order(ByteOrder.BIG_ENDIAN); - - buf.putShort((short) ETHERNET_TYPE); // Ethernet type, 16 bits - buf.putShort(RawSocket.ETH_P_IP); // Protocol type IP, 16 bits - buf.put((byte)MAC_ADDR_LENGTH); // MAC address length, 6 bytes - buf.put((byte)IPV4_LENGTH); // IPv4 protocol size - buf.putShort((short) 1); // ARP opcode 1: 'request' - buf.put(mMyMac); // six bytes: sender MAC - buf.put(mMyAddr.getAddress()); // four bytes: sender IP address - buf.put(new byte[MAC_ADDR_LENGTH]); // target MAC address: unknown - buf.put(desiredIp); // target IP address, 4 bytes - buf.flip(); - mSocket.write(L2_BROADCAST, buf.array(), 0, buf.limit()); - - byte[] recvBuf = new byte[MAX_LENGTH]; - - while (SystemClock.elapsedRealtime() < timeout) { - long duration = (long) timeout - SystemClock.elapsedRealtime(); - int readLen = mSocket.read(recvBuf, 0, recvBuf.length, -1, - (int) duration); - - // Verify packet details. see RFC 826 - if ((readLen >= ARP_LENGTH) // trailing bytes at times - && (recvBuf[0] == 0) && (recvBuf[1] == ETHERNET_TYPE) // type Ethernet - && (recvBuf[2] == 8) && (recvBuf[3] == 0) // protocol IP - && (recvBuf[4] == MAC_ADDR_LENGTH) // mac length - && (recvBuf[5] == IPV4_LENGTH) // IPv4 protocol size - && (recvBuf[6] == 0) && (recvBuf[7] == 2) // ARP reply - // verify desired IP address - && (recvBuf[14] == desiredIp[0]) && (recvBuf[15] == desiredIp[1]) - && (recvBuf[16] == desiredIp[2]) && (recvBuf[17] == desiredIp[3])) - { - // looks good. copy out the MAC - byte[] result = new byte[MAC_ADDR_LENGTH]; - System.arraycopy(recvBuf, 8, result, 0, MAC_ADDR_LENGTH); - return result; - } - } - - return null; - } - - public static boolean doArp(String myMacAddress, LinkProperties linkProperties, - int timeoutMillis, int numArpPings, int minArpResponses) { - String interfaceName = linkProperties.getInterfaceName(); - InetAddress inetAddress = null; - InetAddress gateway = null; - boolean success; - - for (LinkAddress la : linkProperties.getLinkAddresses()) { - inetAddress = la.getAddress(); - break; - } - - for (RouteInfo route : linkProperties.getRoutes()) { - gateway = route.getGateway(); - break; - } - - try { - ArpPeer peer = new ArpPeer(interfaceName, inetAddress, myMacAddress, gateway); - int responses = 0; - for (int i=0; i < numArpPings; i++) { - if(peer.doArp(timeoutMillis) != null) responses++; - } - if (DBG) Log.d(TAG, "ARP test result: " + responses + "/" + numArpPings); - success = (responses >= minArpResponses); - peer.close(); - } catch (SocketException se) { - //Consider an Arp socket creation issue as a successful Arp - //test to avoid any wifi connectivity issues - Log.e(TAG, "ARP test initiation failure: " + se); - success = true; - } - return success; - } - - public void close() { - try { - mSocket.close(); - } catch (IOException ex) { - } - } -} diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index 9ada6e6..b1a9ea3 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -460,7 +460,7 @@ public abstract class BatteryStats implements Parcelable { public byte batteryHealth; public byte batteryPlugType; - public char batteryTemperature; + public short batteryTemperature; public char batteryVoltage; // Constants from SCREEN_BRIGHTNESS_* @@ -537,7 +537,7 @@ public abstract class BatteryStats implements Parcelable { batteryHealth = (byte)((bat>>20)&0xf); batteryPlugType = (byte)((bat>>24)&0xf); bat = src.readInt(); - batteryTemperature = (char)(bat&0xffff); + batteryTemperature = (short)(bat&0xffff); batteryVoltage = (char)((bat>>16)&0xffff); states = src.readInt(); } @@ -606,7 +606,7 @@ public abstract class BatteryStats implements Parcelable { if (DEBUG) Slog.i(TAG, "WRITE DELTA: batteryToken=0x" + Integer.toHexString(batteryLevelInt) + " batteryLevel=" + batteryLevel - + " batteryTemp=" + (int)batteryTemperature + + " batteryTemp=" + batteryTemperature + " batteryVolt=" + (int)batteryVoltage); } if (stateIntChanged) { @@ -621,8 +621,8 @@ public abstract class BatteryStats implements Parcelable { } private int buildBatteryLevelInt() { - return ((((int)batteryLevel)<<24)&0xff000000) - | ((((int)batteryTemperature)<<14)&0x00ffc000) + return ((((int)batteryLevel)<<25)&0xfe000000) + | ((((int)batteryTemperature)<<14)&0x01ffc000) | (((int)batteryVoltage)&0x00003fff); } @@ -658,13 +658,13 @@ public abstract class BatteryStats implements Parcelable { if ((firstToken&DELTA_BATTERY_LEVEL_FLAG) != 0) { int batteryLevelInt = src.readInt(); - batteryLevel = (byte)((batteryLevelInt>>24)&0xff); - batteryTemperature = (char)((batteryLevelInt>>14)&0x3ff); + batteryLevel = (byte)((batteryLevelInt>>25)&0x7f); + batteryTemperature = (short)((batteryLevelInt<<7)>>21); batteryVoltage = (char)(batteryLevelInt&0x3fff); if (DEBUG) Slog.i(TAG, "READ DELTA: batteryToken=0x" + Integer.toHexString(batteryLevelInt) + " batteryLevel=" + batteryLevel - + " batteryTemp=" + (int)batteryTemperature + + " batteryTemp=" + batteryTemperature + " batteryVolt=" + (int)batteryVoltage); } diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java index f9c1d31..af57507 100644 --- a/core/java/android/os/Bundle.java +++ b/core/java/android/os/Bundle.java @@ -380,7 +380,7 @@ public final class Bundle implements Parcelable, Cloneable { SparseArray<? extends Parcelable> array = (SparseArray<? extends Parcelable>) obj; for (int n = array.size() - 1; n >= 0; n--) { - if ((array.get(n).describeContents() + if ((array.valueAt(n).describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) { fdFound = true; break; diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index cf9ddb3..631edd6 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -377,7 +377,7 @@ public class Process { * @param gids Additional group-ids associated with the process. * @param debugFlags Additional flags. * @param targetSdkVersion The target SDK version for the app. - * @param seInfo null-ok SE Android information for the new process. + * @param seInfo null-ok SELinux information for the new process. * @param zygoteArgs Additional arguments to supply to the zygote process. * * @return An object that describes the result of the attempt to start the process. @@ -557,7 +557,7 @@ public class Process { * new process should setgroup() to. * @param debugFlags Additional flags. * @param targetSdkVersion The target SDK version for the app. - * @param seInfo null-ok SE Android information for the new process. + * @param seInfo null-ok SELinux information for the new process. * @param extraArgs Additional arguments to supply to the zygote process. * @return An object that describes the result of the attempt to start the process. * @throws ZygoteStartFailedEx if process start failed for any reason diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 5e20dec..b692ffd 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -32,10 +32,8 @@ import java.security.GeneralSecurityException; import java.security.PublicKey; import java.security.Signature; import java.security.SignatureException; -import java.security.cert.Certificate; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; -import java.util.Collection; import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; @@ -48,7 +46,7 @@ import org.apache.harmony.security.asn1.BerInputStream; import org.apache.harmony.security.pkcs7.ContentInfo; import org.apache.harmony.security.pkcs7.SignedData; import org.apache.harmony.security.pkcs7.SignerInfo; -import org.apache.harmony.security.provider.cert.X509CertImpl; +import org.apache.harmony.security.x509.Certificate; /** * RecoverySystem contains methods for interacting with the Android @@ -93,9 +91,9 @@ public class RecoverySystem { } /** @return the set of certs that can be used to sign an OTA package. */ - private static HashSet<Certificate> getTrustedCerts(File keystore) + private static HashSet<X509Certificate> getTrustedCerts(File keystore) throws IOException, GeneralSecurityException { - HashSet<Certificate> trusted = new HashSet<Certificate>(); + HashSet<X509Certificate> trusted = new HashSet<X509Certificate>(); if (keystore == null) { keystore = DEFAULT_KEYSTORE; } @@ -107,7 +105,7 @@ public class RecoverySystem { ZipEntry entry = entries.nextElement(); InputStream is = zip.getInputStream(entry); try { - trusted.add(cf.generateCertificate(is)); + trusted.add((X509Certificate) cf.generateCertificate(is)); } finally { is.close(); } @@ -201,21 +199,23 @@ public class RecoverySystem { if (signedData == null) { throw new IOException("signedData is null"); } - Collection encCerts = signedData.getCertificates(); + List<Certificate> encCerts = signedData.getCertificates(); if (encCerts.isEmpty()) { throw new IOException("encCerts is empty"); } // Take the first certificate from the signature (packages // should contain only one). - Iterator it = encCerts.iterator(); + Iterator<Certificate> it = encCerts.iterator(); X509Certificate cert = null; if (it.hasNext()) { - cert = new X509CertImpl((org.apache.harmony.security.x509.Certificate)it.next()); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + InputStream is = new ByteArrayInputStream(it.next().getEncoded()); + cert = (X509Certificate) cf.generateCertificate(is); } else { throw new SignatureException("signature contains no certificates"); } - List sigInfos = signedData.getSignerInfos(); + List<SignerInfo> sigInfos = signedData.getSignerInfos(); SignerInfo sigInfo; if (!sigInfos.isEmpty()) { sigInfo = (SignerInfo)sigInfos.get(0); @@ -226,12 +226,12 @@ public class RecoverySystem { // Check that the public key of the certificate contained // in the package equals one of our trusted public keys. - HashSet<Certificate> trusted = getTrustedCerts( + HashSet<X509Certificate> trusted = getTrustedCerts( deviceCertsZipFile == null ? DEFAULT_KEYSTORE : deviceCertsZipFile); PublicKey signatureKey = cert.getPublicKey(); boolean verified = false; - for (Certificate c : trusted) { + for (X509Certificate c : trusted) { if (c.getPublicKey().equals(signatureKey)) { verified = true; break; diff --git a/core/java/android/os/SELinux.java b/core/java/android/os/SELinux.java index c05a974..c9dd5d7 100644 --- a/core/java/android/os/SELinux.java +++ b/core/java/android/os/SELinux.java @@ -45,7 +45,7 @@ public class SELinux { /** * Set whether SELinux is permissive or enforcing. - * @param boolean representing whether to set SELinux to enforcing + * @param value representing whether to set SELinux to enforcing * @return a boolean representing whether the desired mode was set */ public static final native boolean setSELinuxEnforce(boolean value); @@ -60,7 +60,7 @@ public class SELinux { /** * Change the security context of an existing file object. * @param path representing the path of file object to relabel. - * @param con new security context given as a String. + * @param context new security context given as a String. * @return a boolean indicating whether the operation succeeded. */ public static final native boolean setFileContext(String path, String context); @@ -87,8 +87,6 @@ public class SELinux { /** * Gets the security context of a given process id. - * Use of this function is discouraged for Binder transactions. - * Use Binder.getCallingSecctx() instead. * @param pid an int representing the process id to check. * @return a String representing the security context of the given pid. */ @@ -102,15 +100,15 @@ public class SELinux { /** * Gets the value for the given SELinux boolean name. - * @param String The name of the SELinux boolean. + * @param name The name of the SELinux boolean. * @return a boolean indicating whether the SELinux boolean is set. */ public static final native boolean getBooleanValue(String name); /** * Sets the value for the given SELinux boolean name. - * @param String The name of the SELinux boolean. - * @param Boolean The new value of the SELinux boolean. + * @param name The name of the SELinux boolean. + * @param value The new value of the SELinux boolean. * @return a boolean indicating whether or not the operation succeeded. */ public static final native boolean setBooleanValue(String name, boolean value); diff --git a/core/java/android/text/MeasuredText.java b/core/java/android/text/MeasuredText.java index bd9310c..101d6a2 100644 --- a/core/java/android/text/MeasuredText.java +++ b/core/java/android/text/MeasuredText.java @@ -46,7 +46,7 @@ class MeasuredText { } private static final Object[] sLock = new Object[0]; - private static MeasuredText[] sCached = new MeasuredText[3]; + private static final MeasuredText[] sCached = new MeasuredText[3]; static MeasuredText obtain() { MeasuredText mt; diff --git a/core/java/android/util/CharsetUtils.java b/core/java/android/util/CharsetUtils.java deleted file mode 100644 index a763a69..0000000 --- a/core/java/android/util/CharsetUtils.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2009 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; - -import android.os.Build; -import android.text.TextUtils; - -import java.nio.charset.Charset; -import java.nio.charset.IllegalCharsetNameException; -import java.nio.charset.UnsupportedCharsetException; -import java.util.HashMap; -import java.util.Map; - -/** - * <p> - * A class containing utility methods related to character sets. This - * class is primarily useful for code that wishes to be vendor-aware - * in its interpretation of Japanese charset names (used in DoCoMo, - * KDDI, and SoftBank). - * </p> - * - * <p> - * <b>Note:</b> Developers will need to add an appropriate mapping for - * each vendor-specific charset. You may need to modify the C libraries - * like icu4c in order to let Android support an additional charset. - * </p> - * - * @hide - */ -public final class CharsetUtils { - /** - * name of the vendor "DoCoMo". <b>Note:</b> This isn't a public - * constant, in order to keep this class from becoming a de facto - * reference list of vendor names. - */ - private static final String VENDOR_DOCOMO = "docomo"; - /** - * Name of the vendor "KDDI". - */ - private static final String VENDOR_KDDI = "kddi"; - /** - * Name of the vendor "SoftBank". - */ - private static final String VENDOR_SOFTBANK = "softbank"; - - /** - * Represents one-to-one mapping from a vendor name to a charset specific to the vendor. - */ - private static final Map<String, String> sVendorShiftJisMap = new HashMap<String, String>(); - - static { - // These variants of Shift_JIS come from icu's mapping data (convrtrs.txt) - sVendorShiftJisMap.put(VENDOR_DOCOMO, "docomo-shift_jis-2007"); - sVendorShiftJisMap.put(VENDOR_KDDI, "kddi-shift_jis-2007"); - sVendorShiftJisMap.put(VENDOR_SOFTBANK, "softbank-shift_jis-2007"); - } - - /** - * This class is uninstantiable. - */ - private CharsetUtils() { - // This space intentionally left blank. - } - - /** - * Returns the name of the vendor-specific character set - * corresponding to the given original character set name and - * vendor. If there is no vendor-specific character set for the - * given name/vendor pair, this returns the original character set name. - * - * @param charsetName the base character set name - * @param vendor the vendor to specialize for. All characters should be lower-cased. - * @return the specialized character set name, or {@code charsetName} if - * there is no specialized name - */ - public static String nameForVendor(String charsetName, String vendor) { - if (!TextUtils.isEmpty(charsetName) && !TextUtils.isEmpty(vendor)) { - // You can add your own mapping here. - if (isShiftJis(charsetName)) { - final String vendorShiftJis = sVendorShiftJisMap.get(vendor); - if (vendorShiftJis != null) { - return vendorShiftJis; - } - } - } - - return charsetName; - } - - /** - * Returns the name of the vendor-specific character set - * corresponding to the given original character set name and the - * default vendor (that is, the targeted vendor of the device this - * code is running on). This method merely calls through to - * {@link #nameForVendor(String,String)}, passing the default vendor - * as the second argument. - * - * @param charsetName the base character set name - * @return the specialized character set name, or {@code charsetName} if - * there is no specialized name - */ - public static String nameForDefaultVendor(String charsetName) { - return nameForVendor(charsetName, getDefaultVendor()); - } - - /** - * Returns the vendor-specific character set corresponding to the - * given original character set name and vendor. If there is no - * vendor-specific character set for the given name/vendor pair, - * this returns the character set corresponding to the original - * name. The vendor name is matched case-insensitively. This - * method merely calls {@code Charset.forName()} on a name - * transformed by a call to {@link #nameForVendor(String,String)}. - * - * @param charsetName the base character set name - * @param vendor the vendor to specialize for - * @return the specialized character set, or the one corresponding - * directly to {@code charsetName} if there is no specialized - * variant - * @throws UnsupportedCharsetException thrown if the named character - * set is not supported by the system - * @throws IllegalCharsetNameException thrown if {@code charsetName} - * has invalid syntax - */ - public static Charset charsetForVendor(String charsetName, String vendor) - throws UnsupportedCharsetException, IllegalCharsetNameException { - charsetName = nameForVendor(charsetName, vendor); - return Charset.forName(charsetName); - } - - /** - * Returns the vendor-specific character set corresponding to the - * given original character set name and default vendor (that is, - * the targeted vendor of the device this code is running on). - * This method merely calls through to {@link - * #charsetForVendor(String,String)}, passing the default vendor - * as the second argument. - * - * @param charsetName the base character set name - * @return the specialized character set, or the one corresponding - * directly to {@code charsetName} if there is no specialized - * variant - * @throws UnsupportedCharsetException thrown if the named character - * set is not supported by the system - * @throws IllegalCharsetNameException thrown if {@code charsetName} - * has invalid syntax - */ - public static Charset charsetForVendor(String charsetName) - throws UnsupportedCharsetException, IllegalCharsetNameException { - return charsetForVendor(charsetName, getDefaultVendor()); - } - - /** - * Returns whether the given character set name indicates the Shift-JIS - * encoding. Returns false if the name is null. - * - * @param charsetName the character set name - * @return {@code true} if the name corresponds to Shift-JIS or - * {@code false} if not - */ - private static boolean isShiftJis(String charsetName) { - // Bail quickly if the length doesn't match. - if (charsetName == null) { - return false; - } - int length = charsetName.length(); - if (length != 4 && length != 9) { - return false; - } - - return charsetName.equalsIgnoreCase("shift_jis") - || charsetName.equalsIgnoreCase("shift-jis") - || charsetName.equalsIgnoreCase("sjis"); - } - - /** - * Gets the default vendor for this build. - * - * @return the default vendor name - */ - private static String getDefaultVendor() { - return Build.BRAND; - } -} diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 0a702ff..2e5fcec 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -4839,7 +4839,7 @@ public final class BatteryStatsImpl extends BatteryStats { mHistoryCur.batteryStatus = (byte)status; mHistoryCur.batteryHealth = (byte)health; mHistoryCur.batteryPlugType = (byte)plugType; - mHistoryCur.batteryTemperature = (char)temp; + mHistoryCur.batteryTemperature = (short)temp; mHistoryCur.batteryVoltage = (char)volt; setOnBatteryLocked(onBattery, oldStatus, level); } else { @@ -4862,7 +4862,7 @@ public final class BatteryStatsImpl extends BatteryStats { } if (temp >= (mHistoryCur.batteryTemperature+10) || temp <= (mHistoryCur.batteryTemperature-10)) { - mHistoryCur.batteryTemperature = (char)temp; + mHistoryCur.batteryTemperature = (short)temp; changed = true; } if (volt > (mHistoryCur.batteryVoltage+20) diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index fd7e3b0..4f3b5b3 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -197,10 +197,14 @@ class ZygoteConnection { try { parsedArgs = new Arguments(args); + if (parsedArgs.permittedCapabilities != 0 || parsedArgs.effectiveCapabilities != 0) { + throw new ZygoteSecurityException("Client may not specify capabilities: " + + "permitted=0x" + Long.toHexString(parsedArgs.permittedCapabilities) + + ", effective=0x" + Long.toHexString(parsedArgs.effectiveCapabilities)); + } applyUidSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyRlimitSecurityPolicy(parsedArgs, peer, peerSecurityContext); - applyCapabilitiesSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyInvokeWithSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyseInfoSecurityPolicy(parsedArgs, peer, peerSecurityContext); @@ -703,71 +707,6 @@ class ZygoteConnection { } /** - * Applies zygote security policy per bug #1042973. A root peer may - * spawn an instance with any capabilities. All other uids may spawn - * instances with any of the capabilities in the peer's permitted set - * but no more. - * - * @param args non-null; zygote spawner arguments - * @param peer non-null; peer credentials - * @throws ZygoteSecurityException - */ - private static void applyCapabilitiesSecurityPolicy( - Arguments args, Credentials peer, String peerSecurityContext) - throws ZygoteSecurityException { - - if (args.permittedCapabilities == 0 - && args.effectiveCapabilities == 0) { - // nothing to check - return; - } - - boolean allowed = SELinux.checkSELinuxAccess(peerSecurityContext, - peerSecurityContext, - "zygote", - "specifycapabilities"); - if (!allowed) { - throw new ZygoteSecurityException( - "Peer may not specify capabilities"); - } - - if (peer.getUid() == 0) { - // root may specify anything - return; - } - - long permittedCaps; - - try { - permittedCaps = ZygoteInit.capgetPermitted(peer.getPid()); - } catch (IOException ex) { - throw new ZygoteSecurityException( - "Error retrieving peer's capabilities."); - } - - /* - * Ensure that the client did not specify an effective set larger - * than the permitted set. The kernel will enforce this too, but we - * do it here to make the following check easier. - */ - if (((~args.permittedCapabilities) & args.effectiveCapabilities) != 0) { - throw new ZygoteSecurityException( - "Effective capabilities cannot be superset of " - + " permitted capabilities" ); - } - - /* - * Ensure that the new permitted (and thus the new effective) set is - * a subset of the peer process's permitted set - */ - - if (((~permittedCaps) & args.permittedCapabilities) != 0) { - throw new ZygoteSecurityException( - "Peer specified unpermitted capabilities" ); - } - } - - /** * Applies zygote security policy. * Based on the credentials of the process issuing a zygote command: * <ol> @@ -803,7 +742,7 @@ class ZygoteConnection { } /** - * Applies zygote security policy for SEAndroid information. + * Applies zygote security policy for SELinux information. * * @param args non-null; zygote spawner arguments * @param peer non-null; peer credentials @@ -822,7 +761,7 @@ class ZygoteConnection { if (!(peerUid == 0 || peerUid == Process.SYSTEM_UID)) { // All peers with UID other than root or SYSTEM_UID throw new ZygoteSecurityException( - "This UID may not specify SEAndroid info."); + "This UID may not specify SELinux info."); } boolean allowed = SELinux.checkSELinuxAccess(peerSecurityContext, @@ -831,7 +770,7 @@ class ZygoteConnection { "specifyseinfo"); if (!allowed) { throw new ZygoteSecurityException( - "Peer may not specify SEAndroid info"); + "Peer may not specify SELinux info"); } return; diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index c44afae..25118e8 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -722,15 +722,6 @@ public class ZygoteInit { throws IOException; /** - * Retrieves the permitted capability set from another process. - * - * @param pid >=0 process ID or 0 for this process - * @throws IOException on error - */ - static native long capgetPermitted(int pid) - throws IOException; - - /** * Invokes select() on the provider array of file descriptors (selecting * for readability only). Array elements of null are ignored. * |