diff options
Diffstat (limited to 'core/java')
18 files changed, 518 insertions, 66 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index d3080e5..b103e71 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -68,6 +68,7 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; +import android.provider.Settings; import android.util.AndroidRuntimeException; import android.util.ArrayMap; import android.util.DisplayMetrics; @@ -106,6 +107,7 @@ import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.net.InetAddress; import java.security.Security; +import java.text.DateFormat; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -742,8 +744,42 @@ public final class ActivityThread { setCoreSettings(coreSettings); - // Tell the VMRuntime about the application. - VMRuntime.registerAppInfo(appInfo.dataDir, appInfo.processName); + /* + * Two possible indications that this package could be + * sharing its runtime with other packages: + * + * 1.) the sharedUserId attribute is set in the manifest, + * indicating a request to share a VM with other + * packages with the same sharedUserId. + * + * 2.) the application element of the manifest has an + * attribute specifying a non-default process name, + * indicating the desire to run in another packages VM. + * + * If sharing is enabled we do not have a unique application + * in a process and therefore cannot rely on the package + * name inside the runtime. + */ + IPackageManager pm = getPackageManager(); + android.content.pm.PackageInfo pi = null; + try { + pi = pm.getPackageInfo(appInfo.packageName, 0, UserHandle.myUserId()); + } catch (RemoteException e) { + } + if (pi != null) { + boolean sharedUserIdSet = (pi.sharedUserId != null); + boolean processNameNotDefault = + (pi.applicationInfo != null && + !appInfo.packageName.equals(pi.applicationInfo.processName)); + boolean sharable = (sharedUserIdSet || processNameNotDefault); + + // Tell the VMRuntime about the application, unless it is shared + // inside a process. + if (!sharable) { + VMRuntime.registerAppInfo(appInfo.packageName, appInfo.dataDir, + appInfo.processName); + } + } AppBindData data = new AppBindData(); data.processName = processName; @@ -1095,6 +1131,11 @@ public final class ActivityThread { public void scheduleInstallProvider(ProviderInfo provider) { sendMessage(H.INSTALL_PROVIDER, provider); } + + @Override + public final void updateTimePrefs(boolean is24Hour) { + DateFormat.set24HourTimePref(is24Hour); + } } private class H extends Handler { @@ -1144,6 +1185,7 @@ public final class ActivityThread { public static final int REQUEST_ASSIST_CONTEXT_EXTRAS = 143; public static final int TRANSLUCENT_CONVERSION_COMPLETE = 144; public static final int INSTALL_PROVIDER = 145; + String codeToString(int code) { if (DEBUG_MESSAGES) { switch (code) { @@ -4189,6 +4231,11 @@ public final class ActivityThread { Log.e(TAG, "Unable to setupGraphicsSupport due to missing cache directory"); } } + + + final boolean is24Hr = "24".equals(mCoreSettings.getString(Settings.System.TIME_12_24)); + DateFormat.set24HourTimePref(is24Hr); + /** * For system applications on userdebug/eng builds, log stack * traces of disk and network access to dropbox for analysis. diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index 347d43f..cb453e2 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -627,6 +627,15 @@ public abstract class ApplicationThreadNative extends Binder reply.writeNoException(); return true; } + + case UPDATE_TIME_PREFS_TRANSACTION: + { + data.enforceInterface(IApplicationThread.descriptor); + byte is24Hour = data.readByte(); + updateTimePrefs(is24Hour == (byte) 1); + reply.writeNoException(); + return true; + } } return super.onTransact(code, data, reply, flags); @@ -1266,4 +1275,13 @@ class ApplicationThreadProxy implements IApplicationThread { mRemote.transact(SCHEDULE_INSTALL_PROVIDER_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); } + + @Override + public void updateTimePrefs(boolean is24Hour) throws RemoteException { + Parcel data = Parcel.obtain(); + data.writeInterfaceToken(IApplicationThread.descriptor); + data.writeByte(is24Hour ? (byte) 1 : (byte) 0); + mRemote.transact(UPDATE_TIME_PREFS_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); + data.recycle(); + } } diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java index d0cc1bb..3aceff9 100644 --- a/core/java/android/app/IApplicationThread.java +++ b/core/java/android/app/IApplicationThread.java @@ -138,6 +138,7 @@ public interface IApplicationThread extends IInterface { throws RemoteException; void setProcessState(int state) throws RemoteException; void scheduleInstallProvider(ProviderInfo provider) throws RemoteException; + void updateTimePrefs(boolean is24Hour) throws RemoteException; String descriptor = "android.app.IApplicationThread"; @@ -191,4 +192,5 @@ public interface IApplicationThread extends IInterface { int SCHEDULE_TRANSLUCENT_CONVERSION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+48; int SET_PROCESS_STATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+49; int SCHEDULE_INSTALL_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+50; + int UPDATE_TIME_PREFS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+51; } diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index ddde3fb..44831fc 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -987,7 +987,7 @@ public abstract class ContentProvider implements ComponentCallbacks2 { * Implement this to handle requests to delete one or more rows. * The implementation should apply the selection clause when performing * deletion, allowing the operation to affect multiple rows in a directory. - * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyDelete()} + * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()} * after deleting. * This method can be called from multiple threads, as described in * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index a289649..2e2d4b8 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3331,6 +3331,15 @@ public class Intent implements Parcelable, Cloneable { public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; + /** + * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the + * user has set their time format preferences to the 24 hour format. + * + * @hide for internal use only. + */ + public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = + "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; + // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Intent flags (see mFlags variable). diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 418bdda..9ce17e4 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -537,7 +537,7 @@ public final class AssetManager { public final class AssetInputStream extends InputStream { public final int getAssetInt() { - return (int) mAsset; + throw new UnsupportedOperationException(); } /** * @hide diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java index b931313..ac9189d 100644 --- a/core/java/android/hardware/SensorManager.java +++ b/core/java/android/hardware/SensorManager.java @@ -1359,7 +1359,7 @@ public abstract class SensorManager { float q2 = rotationVector[1]; float q3 = rotationVector[2]; - if (rotationVector.length == 4) { + if (rotationVector.length >= 4) { q0 = rotationVector[3]; } else { q0 = 1 - q1*q1 - q2*q2 - q3*q3; @@ -1416,7 +1416,7 @@ public abstract class SensorManager { * @param Q an array of floats in which to store the computed quaternion */ public static void getQuaternionFromVector(float[] Q, float[] rv) { - if (rv.length == 4) { + if (rv.length >= 4) { Q[0] = rv[3]; } else { Q[0] = 1 - rv[0]*rv[0] - rv[1]*rv[1] - rv[2]*rv[2]; diff --git a/core/java/android/net/LocalSocketImpl.java b/core/java/android/net/LocalSocketImpl.java index b2ee50a..119e533 100644 --- a/core/java/android/net/LocalSocketImpl.java +++ b/core/java/android/net/LocalSocketImpl.java @@ -326,6 +326,7 @@ class LocalSocketImpl } s.fd = accept(fd, s); + s.mFdCreatedInternally = true; } /** @@ -536,4 +537,3 @@ class LocalSocketImpl close(); } } - diff --git a/core/java/android/net/http/CertificateChainValidator.java b/core/java/android/net/http/CertificateChainValidator.java index 3652a4c..d06355d 100644 --- a/core/java/android/net/http/CertificateChainValidator.java +++ b/core/java/android/net/http/CertificateChainValidator.java @@ -16,22 +16,28 @@ package android.net.http; -import com.android.org.conscrypt.SSLParametersImpl; -import com.android.org.conscrypt.TrustManagerImpl; +import android.util.Slog; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.lang.reflect.Method; import java.security.GeneralSecurityException; -import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; -import javax.net.ssl.DefaultHostnameVerifier; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; -import javax.net.ssl.X509TrustManager; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509ExtendedTrustManager; /** * Class responsible for all server certificate validation functionality @@ -39,28 +45,54 @@ import javax.net.ssl.X509TrustManager; * {@hide} */ public class CertificateChainValidator { + private static final String TAG = "CertificateChainValidator"; - /** - * The singleton instance of the certificate chain validator - */ - private static final CertificateChainValidator sInstance - = new CertificateChainValidator(); + private static class NoPreloadHolder { + /** + * The singleton instance of the certificate chain validator. + */ + private static final CertificateChainValidator sInstance = new CertificateChainValidator(); + + /** + * The singleton instance of the hostname verifier. + */ + private static final HostnameVerifier sVerifier = HttpsURLConnection + .getDefaultHostnameVerifier(); + } - private static final DefaultHostnameVerifier sVerifier - = new DefaultHostnameVerifier(); + private X509ExtendedTrustManager mTrustManager; /** * @return The singleton instance of the certificates chain validator */ public static CertificateChainValidator getInstance() { - return sInstance; + return NoPreloadHolder.sInstance; } /** * Creates a new certificate chain validator. This is a private constructor. * If you need a Certificate chain validator, call getInstance(). */ - private CertificateChainValidator() {} + private CertificateChainValidator() { + try { + TrustManagerFactory tmf = TrustManagerFactory.getInstance("X.509"); + tmf.init((KeyStore) null); + for (TrustManager tm : tmf.getTrustManagers()) { + if (tm instanceof X509ExtendedTrustManager) { + mTrustManager = (X509ExtendedTrustManager) tm; + } + } + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("X.509 TrustManagerFactory must be available", e); + } catch (KeyStoreException e) { + throw new RuntimeException("X.509 TrustManagerFactory cannot be initialized", e); + } + + if (mTrustManager == null) { + throw new RuntimeException( + "None of the X.509 TrustManagers are X509ExtendedTrustManager"); + } + } /** * Performs the handshake and server certificates validation @@ -136,14 +168,31 @@ public class CertificateChainValidator { * Handles updates to credential storage. */ public static void handleTrustStorageUpdate() { - + TrustManagerFactory tmf; try { - X509TrustManager x509TrustManager = SSLParametersImpl.getDefaultTrustManager(); - if( x509TrustManager instanceof TrustManagerImpl ) { - TrustManagerImpl trustManager = (TrustManagerImpl) x509TrustManager; - trustManager.handleTrustStorageUpdate(); + tmf = TrustManagerFactory.getInstance("X.509"); + tmf.init((KeyStore) null); + } catch (NoSuchAlgorithmException e) { + Slog.w(TAG, "Couldn't find default X.509 TrustManagerFactory"); + return; + } catch (KeyStoreException e) { + Slog.w(TAG, "Couldn't initialize default X.509 TrustManagerFactory", e); + return; + } + + TrustManager[] tms = tmf.getTrustManagers(); + boolean sentUpdate = false; + for (TrustManager tm : tms) { + try { + Method updateMethod = tm.getClass().getDeclaredMethod("handleTrustStorageUpdate"); + updateMethod.setAccessible(true); + updateMethod.invoke(tm); + sentUpdate = true; + } catch (Exception e) { } - } catch (KeyManagementException ignored) { + } + if (!sentUpdate) { + Slog.w(TAG, "Didn't find a TrustManager to handle CA list update"); } } @@ -166,7 +215,8 @@ public class CertificateChainValidator { boolean valid = domain != null && !domain.isEmpty() - && sVerifier.verify(domain, currCertificate); + && NoPreloadHolder.sVerifier.verify(domain, + new DelegatingSSLSession.CertificateWrap(currCertificate)); if (!valid) { if (HttpLog.LOGV) { HttpLog.v("certificate not for this host: " + domain); @@ -175,13 +225,8 @@ public class CertificateChainValidator { } try { - X509TrustManager x509TrustManager = SSLParametersImpl.getDefaultTrustManager(); - if (x509TrustManager instanceof TrustManagerImpl) { - TrustManagerImpl trustManager = (TrustManagerImpl) x509TrustManager; - trustManager.checkServerTrusted(chain, authType, domain); - } else { - x509TrustManager.checkServerTrusted(chain, authType); - } + getInstance().getTrustManager().checkServerTrusted(chain, authType, + new DelegatingSocketWrapper(domain)); return null; // No errors. } catch (GeneralSecurityException e) { if (HttpLog.LOGV) { @@ -192,6 +237,12 @@ public class CertificateChainValidator { } } + /** + * Returns the platform default {@link X509ExtendedTrustManager}. + */ + private X509ExtendedTrustManager getTrustManager() { + return mTrustManager; + } private void closeSocketThrowException( SSLSocket socket, String errorMessage, String defaultErrorMessage) @@ -217,4 +268,4 @@ public class CertificateChainValidator { throw new SSLHandshakeException(errorMessage); } -} +}
\ No newline at end of file diff --git a/core/java/android/net/http/DelegatingSSLSession.java b/core/java/android/net/http/DelegatingSSLSession.java new file mode 100644 index 0000000..ff75b24 --- /dev/null +++ b/core/java/android/net/http/DelegatingSSLSession.java @@ -0,0 +1,172 @@ +/* + * Copyright 2014 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.http; + +import java.security.Principal; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; + +import javax.net.ssl.SSLPeerUnverifiedException; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSessionContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.X509ExtendedTrustManager; + +/** + * This is used when only a {@code hostname} is available but usage of the new API + * {@link X509ExtendedTrustManager#checkServerTrusted(X509Certificate[], String, Socket)} + * requires a {@link SSLSocket}. + * + * @hide + */ +public class DelegatingSSLSession implements SSLSession { + protected DelegatingSSLSession() { + } + + public static class HostnameWrap extends DelegatingSSLSession { + private final String mHostname; + + public HostnameWrap(String hostname) { + mHostname = hostname; + } + + @Override + public String getPeerHost() { + return mHostname; + } + } + + public static class CertificateWrap extends DelegatingSSLSession { + private final Certificate mCertificate; + + public CertificateWrap(Certificate certificate) { + mCertificate = certificate; + } + + @Override + public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException { + return new Certificate[] { mCertificate }; + } + } + + + @Override + public int getApplicationBufferSize() { + throw new UnsupportedOperationException(); + } + + @Override + public String getCipherSuite() { + throw new UnsupportedOperationException(); + } + + @Override + public long getCreationTime() { + throw new UnsupportedOperationException(); + } + + @Override + public byte[] getId() { + throw new UnsupportedOperationException(); + } + + @Override + public long getLastAccessedTime() { + throw new UnsupportedOperationException(); + } + + @Override + public Certificate[] getLocalCertificates() { + throw new UnsupportedOperationException(); + } + + @Override + public Principal getLocalPrincipal() { + throw new UnsupportedOperationException(); + } + + @Override + public int getPacketBufferSize() { + throw new UnsupportedOperationException(); + } + + @Override + public javax.security.cert.X509Certificate[] getPeerCertificateChain() + throws SSLPeerUnverifiedException { + throw new UnsupportedOperationException(); + } + + @Override + public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException { + throw new UnsupportedOperationException(); + } + + @Override + public String getPeerHost() { + throw new UnsupportedOperationException(); + } + + @Override + public int getPeerPort() { + throw new UnsupportedOperationException(); + } + + @Override + public Principal getPeerPrincipal() throws SSLPeerUnverifiedException { + throw new UnsupportedOperationException(); + } + + @Override + public String getProtocol() { + throw new UnsupportedOperationException(); + } + + @Override + public SSLSessionContext getSessionContext() { + throw new UnsupportedOperationException(); + } + + @Override + public Object getValue(String name) { + throw new UnsupportedOperationException(); + } + + @Override + public String[] getValueNames() { + throw new UnsupportedOperationException(); + } + + @Override + public void invalidate() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isValid() { + throw new UnsupportedOperationException(); + } + + @Override + public void putValue(String name, Object value) { + throw new UnsupportedOperationException(); + } + + @Override + public void removeValue(String name) { + throw new UnsupportedOperationException(); + } +}
\ No newline at end of file diff --git a/core/java/android/net/http/DelegatingSocketWrapper.java b/core/java/android/net/http/DelegatingSocketWrapper.java new file mode 100644 index 0000000..230d017 --- /dev/null +++ b/core/java/android/net/http/DelegatingSocketWrapper.java @@ -0,0 +1,127 @@ +/* + * Copyright 2014 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.http; + +import java.io.IOException; + +import javax.net.ssl.HandshakeCompletedListener; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.X509ExtendedTrustManager; + +/** + * This is used when only a {@code hostname} is available for + * {@link X509ExtendedTrustManager#checkServerTrusted(java.security.cert.X509Certificate[], String, Socket)} + * but we want to use the new API that requires a {@link SSLSocket}. + */ +class DelegatingSocketWrapper extends SSLSocket { + private String hostname; + + public DelegatingSocketWrapper(String hostname) { + this.hostname = hostname; + } + + @Override + public String[] getSupportedCipherSuites() { + throw new UnsupportedOperationException(); + } + + @Override + public String[] getEnabledCipherSuites() { + throw new UnsupportedOperationException(); + } + + @Override + public void setEnabledCipherSuites(String[] suites) { + throw new UnsupportedOperationException(); + } + + @Override + public String[] getSupportedProtocols() { + throw new UnsupportedOperationException(); + } + + @Override + public String[] getEnabledProtocols() { + throw new UnsupportedOperationException(); + } + + @Override + public void setEnabledProtocols(String[] protocols) { + throw new UnsupportedOperationException(); + } + + @Override + public SSLSession getSession() { + return new DelegatingSSLSession.HostnameWrap(hostname); + } + + @Override + public void addHandshakeCompletedListener(HandshakeCompletedListener listener) { + throw new UnsupportedOperationException(); + } + + @Override + public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) { + throw new UnsupportedOperationException(); + } + + @Override + public void startHandshake() throws IOException { + throw new UnsupportedOperationException(); + } + + @Override + public void setUseClientMode(boolean mode) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean getUseClientMode() { + throw new UnsupportedOperationException(); + } + + @Override + public void setNeedClientAuth(boolean need) { + throw new UnsupportedOperationException(); + } + + @Override + public void setWantClientAuth(boolean want) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean getNeedClientAuth() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean getWantClientAuth() { + throw new UnsupportedOperationException(); + } + + @Override + public void setEnableSessionCreation(boolean flag) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean getEnableSessionCreation() { + throw new UnsupportedOperationException(); + } +}
\ No newline at end of file diff --git a/core/java/android/net/http/X509TrustManagerExtensions.java b/core/java/android/net/http/X509TrustManagerExtensions.java index cfe5f27..666832a 100644 --- a/core/java/android/net/http/X509TrustManagerExtensions.java +++ b/core/java/android/net/http/X509TrustManagerExtensions.java @@ -22,14 +22,25 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.List; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.X509ExtendedTrustManager; import javax.net.ssl.X509TrustManager; /** * X509TrustManager wrapper exposing Android-added features. - * - * <p> The checkServerTrusted method allows callers to perform additional - * verification of certificate chains after they have been successfully - * verified by the platform.</p> + * <p> + * The checkServerTrusted method allows callers to perform additional + * verification of certificate chains after they have been successfully verified + * by the platform. + * </p> + * <p> + * If the returned certificate list is not needed, see also + * {@code X509ExtendedTrustManager#checkServerTrusted(X509Certificate[], String, java.net.Socket)} + * where an {@link SSLSocket} can be used to verify the given hostname during + * handshake using + * {@code SSLParameters#setEndpointIdentificationAlgorithm(String)}. + * </p> */ public class X509TrustManagerExtensions { @@ -61,6 +72,7 @@ public class X509TrustManagerExtensions { */ public List<X509Certificate> checkServerTrusted(X509Certificate[] chain, String authType, String host) throws CertificateException { - return mDelegate.checkServerTrusted(chain, authType, host); + return mDelegate.checkServerTrusted(chain, authType, + new DelegatingSSLSession.HostnameWrap(host)); } } diff --git a/core/java/android/net/nsd/NsdManager.java b/core/java/android/net/nsd/NsdManager.java index 9c3e405..7b2c623 100644 --- a/core/java/android/net/nsd/NsdManager.java +++ b/core/java/android/net/nsd/NsdManager.java @@ -301,27 +301,36 @@ public final class NsdManager { @Override public void handleMessage(Message message) { - Object listener = getListener(message.arg2); - boolean listenerRemove = true; switch (message.what) { case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: mAsyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION); - break; + return; case AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED: mConnected.countDown(); - break; + return; case AsyncChannel.CMD_CHANNEL_DISCONNECTED: Log.e(TAG, "Channel lost"); + return; + default: break; + } + Object listener = getListener(message.arg2); + if (listener == null) { + Log.d(TAG, "Stale key " + message.arg2); + return; + } + boolean listenerRemove = true; + NsdServiceInfo ns = getNsdService(message.arg2); + switch (message.what) { case DISCOVER_SERVICES_STARTED: - String s = ((NsdServiceInfo) message.obj).getServiceType(); + String s = getNsdServiceInfoType((NsdServiceInfo) message.obj); ((DiscoveryListener) listener).onDiscoveryStarted(s); // Keep listener until stop discovery listenerRemove = false; break; case DISCOVER_SERVICES_FAILED: - ((DiscoveryListener) listener).onStartDiscoveryFailed( - getNsdService(message.arg2).getServiceType(), message.arg1); + ((DiscoveryListener) listener).onStartDiscoveryFailed(getNsdServiceInfoType(ns), + message.arg1); break; case SERVICE_FOUND: ((DiscoveryListener) listener).onServiceFound((NsdServiceInfo) message.obj); @@ -334,16 +343,14 @@ public final class NsdManager { listenerRemove = false; break; case STOP_DISCOVERY_FAILED: - ((DiscoveryListener) listener).onStopDiscoveryFailed( - getNsdService(message.arg2).getServiceType(), message.arg1); + ((DiscoveryListener) listener).onStopDiscoveryFailed(getNsdServiceInfoType(ns), + message.arg1); break; case STOP_DISCOVERY_SUCCEEDED: - ((DiscoveryListener) listener).onDiscoveryStopped( - getNsdService(message.arg2).getServiceType()); + ((DiscoveryListener) listener).onDiscoveryStopped(getNsdServiceInfoType(ns)); break; case REGISTER_SERVICE_FAILED: - ((RegistrationListener) listener).onRegistrationFailed( - getNsdService(message.arg2), message.arg1); + ((RegistrationListener) listener).onRegistrationFailed(ns, message.arg1); break; case REGISTER_SERVICE_SUCCEEDED: ((RegistrationListener) listener).onServiceRegistered( @@ -352,16 +359,13 @@ public final class NsdManager { listenerRemove = false; break; case UNREGISTER_SERVICE_FAILED: - ((RegistrationListener) listener).onUnregistrationFailed( - getNsdService(message.arg2), message.arg1); + ((RegistrationListener) listener).onUnregistrationFailed(ns, message.arg1); break; case UNREGISTER_SERVICE_SUCCEEDED: - ((RegistrationListener) listener).onServiceUnregistered( - getNsdService(message.arg2)); + ((RegistrationListener) listener).onServiceUnregistered(ns); break; case RESOLVE_SERVICE_FAILED: - ((ResolveListener) listener).onResolveFailed( - getNsdService(message.arg2), message.arg1); + ((ResolveListener) listener).onResolveFailed(ns, message.arg1); break; case RESOLVE_SERVICE_SUCCEEDED: ((ResolveListener) listener).onServiceResolved((NsdServiceInfo) message.obj); @@ -421,6 +425,11 @@ public final class NsdManager { } + private String getNsdServiceInfoType(NsdServiceInfo s) { + if (s == null) return "?"; + return s.getServiceType(); + } + /** * Initialize AsyncChannel */ diff --git a/core/java/android/nfc/tech/Ndef.java b/core/java/android/nfc/tech/Ndef.java index 64aa299..f16dc3b 100644 --- a/core/java/android/nfc/tech/Ndef.java +++ b/core/java/android/nfc/tech/Ndef.java @@ -278,6 +278,8 @@ public final class Ndef extends BasicTagTechnology { throw new TagLostException(); } return msg; + } else if (!tagService.isPresent(serviceHandle)) { + throw new TagLostException(); } else { return null; } diff --git a/core/java/android/util/Patterns.java b/core/java/android/util/Patterns.java index 9522112..0f8da44 100644 --- a/core/java/android/util/Patterns.java +++ b/core/java/android/util/Patterns.java @@ -191,8 +191,6 @@ public class Patterns { for (int i = 1; i <= numGroups; i++) { String s = matcher.group(i); - System.err.println("Group(" + i + ") : " + s); - if (s != null) { b.append(s); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 83610c3..bdf4141 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -10098,7 +10098,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * by the layout system and should not generally be called otherwise, because the property * may be changed at any time by the layout. * - * @param left The bottom of this view, in pixels. + * @param left The left of this view, in pixels. */ public final void setLeft(int left) { if (left != mLeft) { @@ -10165,7 +10165,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * by the layout system and should not generally be called otherwise, because the property * may be changed at any time by the layout. * - * @param right The bottom of this view, in pixels. + * @param right The right of this view, in pixels. */ public final void setRight(int right) { if (right != mRight) { diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index 7674837..fe2fc96 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -292,7 +292,7 @@ public abstract class AbsSeekBar extends ProgressBar { // The extra space for the thumb to move on the track available += mThumbOffset * 2; - int thumbPos = (int) (scale * available); + int thumbPos = (int) (scale * available + 0.5f); int topBound, bottomBound; if (gap == Integer.MIN_VALUE) { diff --git a/core/java/com/android/internal/util/FileRotator.java b/core/java/com/android/internal/util/FileRotator.java index 26235f1..71550be 100644 --- a/core/java/com/android/internal/util/FileRotator.java +++ b/core/java/com/android/internal/util/FileRotator.java @@ -336,7 +336,12 @@ public class FileRotator { final long deleteBefore = currentTimeMillis - mDeleteAgeMillis; final FileInfo info = new FileInfo(mPrefix); - for (String name : mBasePath.list()) { + String[] baseFiles = mBasePath.list(); + if (baseFiles == null) { + return; + } + + for (String name : baseFiles) { if (!info.parse(name)) continue; if (info.isActive()) { |
