diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-08-21 02:33:36 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-08-21 02:33:36 +0000 |
commit | d65de0ce5e6cd203a0da53867e8e45c14d3bce34 (patch) | |
tree | fa5e67364b97bca49424dd1a2680a7aafd41d19b | |
parent | 9d7a5eaa4dce3f51b8d1c33e220261d70c213d07 (diff) | |
parent | 776d0367b029e63f1030a9fec89ff3487cf68ce5 (diff) | |
download | base-d65de0ce5e6cd203a0da53867e8e45c14d3bce34.tar.gz |
Snap for 5817401 from 776d0367b029e63f1030a9fec89ff3487cf68ce5 to qt-c2f2-release
Change-Id: Ic72fbe830ed6b6e2f5f8819fa66166f9b21619bb
9 files changed, 153 insertions, 58 deletions
diff --git a/core/java/android/webkit/PermissionRequest.java b/core/java/android/webkit/PermissionRequest.java index 18ec334d0283..ac145b1d81a5 100644 --- a/core/java/android/webkit/PermissionRequest.java +++ b/core/java/android/webkit/PermissionRequest.java @@ -32,7 +32,7 @@ import android.net.Uri; * avoid unintentionally granting requests for new permissions, you should pass the * specific permissions you intend to grant to {@link #grant(String[]) grant()}, * and avoid writing code like this example: - * <pre> + * <pre class="prettyprint"> * permissionRequest.grant(permissionRequest.getResources()) // This is wrong!!! * </pre> * See the WebView's release notes for information about new protected resources. diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java index 95fe963d7891..4db630808ef1 100644 --- a/core/java/android/webkit/WebChromeClient.java +++ b/core/java/android/webkit/WebChromeClient.java @@ -519,15 +519,17 @@ public class WebChromeClient { * may not be supported and applications wishing to support these sources * or more advanced file operations should build their own Intent. * - * <pre> - * How to use: - * 1. Build an intent using {@link #createIntent} - * 2. Fire the intent using {@link android.app.Activity#startActivityForResult}. - * 3. Check for ActivityNotFoundException and take a user friendly action if thrown. - * 4. Listen the result using {@link android.app.Activity#onActivityResult} - * 5. Parse the result using {@link #parseResult} only if media capture was not requested. - * 6. Send the result using filePathCallback of {@link WebChromeClient#onShowFileChooser} - * </pre> + * <p>How to use: + * <ol> + * <li>Build an intent using {@link #createIntent}</li> + * <li>Fire the intent using {@link android.app.Activity#startActivityForResult}.</li> + * <li>Check for ActivityNotFoundException and take a user friendly action if thrown.</li> + * <li>Listen the result using {@link android.app.Activity#onActivityResult}</li> + * <li>Parse the result using {@link #parseResult} only if media capture was not + * requested.</li> + * <li>Send the result using filePathCallback of {@link + * WebChromeClient#onShowFileChooser}</li> + * </ol> * * @return an Intent that supports basic file chooser sources. */ diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 87963636a003..95fca00f2346 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -762,7 +762,7 @@ public class WebView extends AbsoluteLayout * encoded. If the data is base64 encoded, the value of the encoding * parameter must be {@code "base64"}. HTML can be encoded with {@link * android.util.Base64#encodeToString(byte[],int)} like so: - * <pre> + * <pre class="prettyprint"> * String unencodedHtml = * "<html><body>'%28' is the code for '('</body></html>"; * String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(), Base64.NO_PADDING); @@ -1854,7 +1854,7 @@ public class WebView extends AbsoluteLayout * important security note below for implications. * <p> Note that injected objects will not appear in JavaScript until the page is next * (re)loaded. JavaScript should be enabled before injecting the object. For example: - * <pre> + * <pre class="prettyprint"> * class JsObject { * {@literal @}JavascriptInterface * public String toString() { return "injectedObject"; } diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java index d74112608491..aac721e3cb56 100644 --- a/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java +++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java @@ -146,7 +146,13 @@ public class EglHelper { * @return true if EglSurface is ready. */ public boolean createEglSurface(SurfaceHolder surfaceHolder) { - mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, surfaceHolder, null, 0); + if (hasEglDisplay()) { + mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, surfaceHolder, null, 0); + } else { + Log.w(TAG, "mEglDisplay is null"); + return false; + } + if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) { Log.w(TAG, "createWindowSurface failed: " + GLUtils.getEGLErrorString(eglGetError())); return false; @@ -186,7 +192,13 @@ public class EglHelper { public boolean createEglContext() { int[] attrib_list = new int[] {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_LOW_IMG, EGL_NONE}; - mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT, attrib_list, 0); + if (hasEglDisplay()) { + mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT, attrib_list, 0); + } else { + Log.w(TAG, "mEglDisplay is null"); + return false; + } + if (mEglContext == EGL_NO_CONTEXT) { Log.w(TAG, "eglCreateContext failed: " + GLUtils.getEGLErrorString(eglGetError())); return false; @@ -213,6 +225,14 @@ public class EglHelper { } /** + * Check if we have EglDisplay. + * @return true if EglDisplay is ready. + */ + public boolean hasEglDisplay() { + return mEglDisplay != null; + } + + /** * Swap buffer to display. * @return true if swap successfully. */ @@ -235,7 +255,9 @@ public class EglHelper { if (hasEglContext()) { destroyEglContext(); } - eglTerminate(mEglDisplay); + if (hasEglDisplay()) { + eglTerminate(mEglDisplay); + } mEglReady = false; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/glwallpaper/EglHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/glwallpaper/EglHelperTest.java new file mode 100644 index 000000000000..b4a60d642cb0 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/glwallpaper/EglHelperTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.glwallpaper; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.RETURNS_DEFAULTS; +import static org.mockito.Mockito.mock; + +import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; +import android.view.SurfaceHolder; + +import androidx.test.filters.SmallTest; + +import com.android.systemui.SysuiTestCase; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; + + +@SmallTest +@RunWith(AndroidTestingRunner.class) +@TestableLooper.RunWithLooper +public class EglHelperTest extends SysuiTestCase { + + @Mock + private EglHelper mEglHelper; + @Mock + private SurfaceHolder mSurfaceHolder; + + @Before + public void setUp() throws Exception { + mEglHelper = mock(EglHelper.class, RETURNS_DEFAULTS); + mSurfaceHolder = mock(SurfaceHolder.class, RETURNS_DEFAULTS); + } + + @Test + public void testInit_finish() { + mEglHelper.init(mSurfaceHolder); + mEglHelper.finish(); + } + + @Test + public void testFinish_shouldNotCrash() { + assertFalse(mEglHelper.hasEglDisplay()); + assertFalse(mEglHelper.hasEglSurface()); + assertFalse(mEglHelper.hasEglContext()); + + mEglHelper.finish(); + } +} diff --git a/telephony/java/android/telephony/NetworkServiceCallback.java b/telephony/java/android/telephony/NetworkServiceCallback.java index 1c64bcd28966..89b96654451e 100644 --- a/telephony/java/android/telephony/NetworkServiceCallback.java +++ b/telephony/java/android/telephony/NetworkServiceCallback.java @@ -24,7 +24,6 @@ import android.telephony.NetworkService.NetworkServiceProvider; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.lang.ref.WeakReference; /** * Network service callback. Object of this class is passed to NetworkServiceProvider upon @@ -61,11 +60,11 @@ public class NetworkServiceCallback { /** Request failed */ public static final int RESULT_ERROR_FAILED = 5; - private final WeakReference<INetworkServiceCallback> mCallback; + private final INetworkServiceCallback mCallback; /** @hide */ public NetworkServiceCallback(INetworkServiceCallback callback) { - mCallback = new WeakReference<>(callback); + mCallback = callback; } /** @@ -78,15 +77,14 @@ public class NetworkServiceCallback { */ public void onRequestNetworkRegistrationInfoComplete(int result, @Nullable NetworkRegistrationInfo state) { - INetworkServiceCallback callback = mCallback.get(); - if (callback != null) { + if (mCallback != null) { try { - callback.onRequestNetworkRegistrationInfoComplete(result, state); + mCallback.onRequestNetworkRegistrationInfoComplete(result, state); } catch (RemoteException e) { Rlog.e(mTag, "Failed to onRequestNetworkRegistrationInfoComplete on the remote"); } } else { - Rlog.e(mTag, "Weak reference of callback is null."); + Rlog.e(mTag, "onRequestNetworkRegistrationInfoComplete callback is null."); } } }
\ No newline at end of file diff --git a/telephony/java/android/telephony/data/DataServiceCallback.java b/telephony/java/android/telephony/data/DataServiceCallback.java index 89d30c0d4373..11dc78a611ff 100644 --- a/telephony/java/android/telephony/data/DataServiceCallback.java +++ b/telephony/java/android/telephony/data/DataServiceCallback.java @@ -27,7 +27,6 @@ import android.telephony.data.DataService.DataServiceProvider; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.lang.ref.WeakReference; import java.util.List; /** @@ -64,11 +63,11 @@ public class DataServiceCallback { /** Request sent in illegal state */ public static final int RESULT_ERROR_ILLEGAL_STATE = 4; - private final WeakReference<IDataServiceCallback> mCallback; + private final IDataServiceCallback mCallback; /** @hide */ public DataServiceCallback(IDataServiceCallback callback) { - mCallback = new WeakReference<>(callback); + mCallback = callback; } /** @@ -80,14 +79,15 @@ public class DataServiceCallback { */ public void onSetupDataCallComplete(@ResultCode int result, @Nullable DataCallResponse response) { - IDataServiceCallback callback = mCallback.get(); - if (callback != null) { + if (mCallback != null) { try { if (DBG) Rlog.d(TAG, "onSetupDataCallComplete"); - callback.onSetupDataCallComplete(result, response); + mCallback.onSetupDataCallComplete(result, response); } catch (RemoteException e) { Rlog.e(TAG, "Failed to onSetupDataCallComplete on the remote"); } + } else { + Rlog.e(TAG, "onSetupDataCallComplete: callback is null!"); } } @@ -98,14 +98,15 @@ public class DataServiceCallback { * @param result The result code. Must be one of the {@link ResultCode}. */ public void onDeactivateDataCallComplete(@ResultCode int result) { - IDataServiceCallback callback = mCallback.get(); - if (callback != null) { + if (mCallback != null) { try { if (DBG) Rlog.d(TAG, "onDeactivateDataCallComplete"); - callback.onDeactivateDataCallComplete(result); + mCallback.onDeactivateDataCallComplete(result); } catch (RemoteException e) { Rlog.e(TAG, "Failed to onDeactivateDataCallComplete on the remote"); } + } else { + Rlog.e(TAG, "onDeactivateDataCallComplete: callback is null!"); } } @@ -116,13 +117,14 @@ public class DataServiceCallback { * @param result The result code. Must be one of the {@link ResultCode}. */ public void onSetInitialAttachApnComplete(@ResultCode int result) { - IDataServiceCallback callback = mCallback.get(); - if (callback != null) { + if (mCallback != null) { try { - callback.onSetInitialAttachApnComplete(result); + mCallback.onSetInitialAttachApnComplete(result); } catch (RemoteException e) { Rlog.e(TAG, "Failed to onSetInitialAttachApnComplete on the remote"); } + } else { + Rlog.e(TAG, "onSetInitialAttachApnComplete: callback is null!"); } } @@ -133,13 +135,14 @@ public class DataServiceCallback { * @param result The result code. Must be one of the {@link ResultCode}. */ public void onSetDataProfileComplete(@ResultCode int result) { - IDataServiceCallback callback = mCallback.get(); - if (callback != null) { + if (mCallback != null) { try { - callback.onSetDataProfileComplete(result); + mCallback.onSetDataProfileComplete(result); } catch (RemoteException e) { Rlog.e(TAG, "Failed to onSetDataProfileComplete on the remote"); } + } else { + Rlog.e(TAG, "onSetDataProfileComplete: callback is null!"); } } @@ -153,13 +156,14 @@ public class DataServiceCallback { */ public void onRequestDataCallListComplete(@ResultCode int result, @NonNull List<DataCallResponse> dataCallList) { - IDataServiceCallback callback = mCallback.get(); - if (callback != null) { + if (mCallback != null) { try { - callback.onRequestDataCallListComplete(result, dataCallList); + mCallback.onRequestDataCallListComplete(result, dataCallList); } catch (RemoteException e) { Rlog.e(TAG, "Failed to onRequestDataCallListComplete on the remote"); } + } else { + Rlog.e(TAG, "onRequestDataCallListComplete: callback is null!"); } } @@ -170,14 +174,15 @@ public class DataServiceCallback { * @param dataCallList List of the current active data connection. */ public void onDataCallListChanged(@NonNull List<DataCallResponse> dataCallList) { - IDataServiceCallback callback = mCallback.get(); - if (callback != null) { + if (mCallback != null) { try { if (DBG) Rlog.d(TAG, "onDataCallListChanged"); - callback.onDataCallListChanged(dataCallList); + mCallback.onDataCallListChanged(dataCallList); } catch (RemoteException e) { Rlog.e(TAG, "Failed to onDataCallListChanged on the remote"); } + } else { + Rlog.e(TAG, "onDataCallListChanged: callback is null!"); } } } diff --git a/wifi/java/android/net/wifi/rtt/ResponderLocation.java b/wifi/java/android/net/wifi/rtt/ResponderLocation.java index e1d82f8d3a09..970a75d7c418 100644 --- a/wifi/java/android/net/wifi/rtt/ResponderLocation.java +++ b/wifi/java/android/net/wifi/rtt/ResponderLocation.java @@ -605,11 +605,11 @@ public final class ResponderLocation implements Parcelable { // Negative 2's complement value // Note: The Math.pow(...) method cannot return a NaN value because the bitFieldSize // for Lat or Lng is limited to exactly 34 bits. - angle = Math.scalb(fields[offset] - Math.pow(2, bitFieldSizes[offset]), + angle = Math.scalb((double) fields[offset] - Math.pow(2, bitFieldSizes[offset]), -LATLNG_FRACTION_BITS); } else { // Positive 2's complement value - angle = Math.scalb(fields[offset], -LATLNG_FRACTION_BITS); + angle = Math.scalb((double) fields[offset], -LATLNG_FRACTION_BITS); } if (angle > limit) { angle = limit; @@ -732,10 +732,11 @@ public final class ResponderLocation implements Parcelable { int maxBssidIndicator = (int) buffer[SUBELEMENT_BSSID_MAX_INDICATOR_INDEX] & BYTE_MASK; int bssidListLength = (buffer.length - 1) / BYTES_IN_A_BSSID; - // Check the max number of BSSIDs agrees with the list length. - if (maxBssidIndicator != bssidListLength) { - return false; - } + // The maxBSSIDIndicator is ignored. Its use is still being clarified in 802.11REVmd, + // which is not published at this time. This field will be used in a future + // release of Android after 802.11REVmd is public. Here, we interpret the following + // params as an explicit list of BSSIDs. + int bssidOffset = SUBELEMENT_BSSID_LIST_INDEX; for (int i = 0; i < bssidListLength; i++) { diff --git a/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java b/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java index 47c304097372..b02eebbe9a01 100644 --- a/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java +++ b/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java @@ -37,7 +37,7 @@ import java.util.List; */ @RunWith(JUnit4.class) public class ResponderLocationTest { - private static final double LATLNG_TOLERANCE_DEGREES = 0.00001; + private static final double LATLNG_TOLERANCE_DEGREES = 0.000_000_05D; // 5E-8 = 6mm of meridian private static final double ALT_TOLERANCE_METERS = 0.01; private static final double HEIGHT_TOLERANCE_METERS = 0.01; private static final int INDEX_ELEMENT_TYPE = 2; @@ -103,7 +103,7 @@ public class ResponderLocationTest { private static final byte[] sTestBssidListSE = { (byte) 0x07, // Subelement BSSID list (byte) 13, // length dependent on number of BSSIDs in list - (byte) 0x02, // Number of BSSIDs in list + (byte) 0x00, // List is explicit; no expansion of list required (byte) 0x01, // BSSID #1 (MSB) (byte) 0x02, (byte) 0x03, @@ -266,11 +266,11 @@ public class ResponderLocationTest { assertTrue(valid); assertTrue(lciValid); assertFalse(zValid); - assertEquals(0.0009765625, responderLocation.getLatitudeUncertainty()); - assertEquals(-33.857009, responderLocation.getLatitude(), + assertEquals(0.0009765625D, responderLocation.getLatitudeUncertainty()); + assertEquals(-33.8570095D, responderLocation.getLatitude(), LATLNG_TOLERANCE_DEGREES); - assertEquals(0.0009765625, responderLocation.getLongitudeUncertainty()); - assertEquals(151.215200, responderLocation.getLongitude(), + assertEquals(0.0009765625D, responderLocation.getLongitudeUncertainty()); + assertEquals(151.2152005D, responderLocation.getLongitude(), LATLNG_TOLERANCE_DEGREES); assertEquals(1, responderLocation.getAltitudeType()); assertEquals(64.0, responderLocation.getAltitudeUncertainty()); @@ -282,11 +282,11 @@ public class ResponderLocationTest { assertEquals(1, responderLocation.getLciVersion()); // Testing Location Object - assertEquals(-33.857009, location.getLatitude(), + assertEquals(-33.8570095D, location.getLatitude(), LATLNG_TOLERANCE_DEGREES); - assertEquals(151.215200, location.getLongitude(), + assertEquals(151.2152005D, location.getLongitude(), LATLNG_TOLERANCE_DEGREES); - assertEquals((0.0009765625 + 0.0009765625) / 2, location.getAccuracy(), + assertEquals((0.0009765625D + 0.0009765625D) / 2, location.getAccuracy(), LATLNG_TOLERANCE_DEGREES); assertEquals(11.2, location.getAltitude(), ALT_TOLERANCE_METERS); assertEquals(64.0, location.getVerticalAccuracyMeters(), ALT_TOLERANCE_METERS); |