diff options
11 files changed, 131 insertions, 52 deletions
diff --git a/api/current.txt b/api/current.txt index e2d31d90ff3a..84f5fcf0c0d6 100755 --- a/api/current.txt +++ b/api/current.txt @@ -24465,6 +24465,7 @@ package android.media { } public static final class MediaExtractor.CasInfo { + method public byte[] getPrivateData(); method public android.media.MediaCas.Session getSession(); method public int getSystemId(); } diff --git a/api/system-current.txt b/api/system-current.txt index 8eb55074e6af..da460157e9d4 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3640,6 +3640,7 @@ package android.net.wifi { public class WifiManager { method public void connect(android.net.wifi.WifiConfiguration, android.net.wifi.WifiManager.ActionListener); + method public java.util.List<android.net.wifi.WifiConfiguration> getAllMatchingWifiConfigs(java.util.List<android.net.wifi.ScanResult>); method public java.util.List<android.net.wifi.WifiConfiguration> getPrivilegedConfiguredNetworks(); method public android.net.wifi.WifiConfiguration getWifiApConfiguration(); method public int getWifiApState(); diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java index 4919eeb4dacb..c203fa9ca71b 100644 --- a/media/java/android/media/MediaExtractor.java +++ b/media/java/android/media/MediaExtractor.java @@ -272,10 +272,12 @@ final public class MediaExtractor { public static final class CasInfo { private final int mSystemId; private final MediaCas.Session mSession; + private final byte[] mPrivateData; - CasInfo(int systemId, @Nullable MediaCas.Session session) { + CasInfo(int systemId, @Nullable MediaCas.Session session, @Nullable byte[] privateData) { mSystemId = systemId; mSession = session; + mPrivateData = privateData; } /** @@ -288,10 +290,30 @@ final public class MediaExtractor { } /** + * Retrieves the private data in the CA_Descriptor associated with a track. + * Some CAS systems may need this to initialize the CAS plugin object. This + * private data can only be retrieved before a valid {@link MediaCas} object + * is set on the extractor. + * <p> + * @see MediaExtractor#setMediaCas + * <p> + * @return a byte array containing the private data. A null return value + * indicates that the private data is unavailable. An empty array, + * on the other hand, indicates that the private data is empty + * (zero in length). + */ + @Nullable + public byte[] getPrivateData() { + return mPrivateData; + } + + /** * Retrieves the {@link MediaCas.Session} associated with a track. The * session is needed to initialize a descrambler in order to decode the - * scrambled track. + * scrambled track. The session object can only be retrieved after a valid + * {@link MediaCas} object is set on the extractor. * <p> + * @see MediaExtractor#setMediaCas * @see MediaDescrambler#setMediaCasSession * <p> * @return a {@link MediaCas.Session} object associated with a track. @@ -321,6 +343,13 @@ final public class MediaExtractor { if (formatMap.containsKey(MediaFormat.KEY_CA_SYSTEM_ID)) { int systemId = ((Integer)formatMap.get(MediaFormat.KEY_CA_SYSTEM_ID)).intValue(); MediaCas.Session session = null; + byte[] privateData = null; + if (formatMap.containsKey(MediaFormat.KEY_CA_PRIVATE_DATA)) { + ByteBuffer buf = (ByteBuffer) formatMap.get(MediaFormat.KEY_CA_PRIVATE_DATA); + buf.rewind(); + privateData = new byte[buf.remaining()]; + buf.get(privateData); + } if (mMediaCas != null && formatMap.containsKey(MediaFormat.KEY_CA_SESSION_ID)) { ByteBuffer buf = (ByteBuffer) formatMap.get(MediaFormat.KEY_CA_SESSION_ID); buf.rewind(); @@ -328,7 +357,7 @@ final public class MediaExtractor { buf.get(sessionId); session = mMediaCas.createFromSessionId(toByteArray(sessionId)); } - return new CasInfo(systemId, session); + return new CasInfo(systemId, session, privateData); } return null; } diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java index d10cbbc295c7..5dee16e03542 100644 --- a/media/java/android/media/MediaFormat.java +++ b/media/java/android/media/MediaFormat.java @@ -919,7 +919,7 @@ public final class MediaFormat { * a media track. * <p> * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional - * access system. + * access system, regardless of the presence of a valid {@link MediaCas} object. * <p> * The associated value is an integer. * @hide @@ -930,13 +930,25 @@ public final class MediaFormat { * A key describing the {@link MediaCas.Session} object associated with a media track. * <p> * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional - * access system. + * access system, after it receives a valid {@link MediaCas} object. * <p> * The associated value is a ByteBuffer. * @hide */ public static final String KEY_CA_SESSION_ID = "ca-session-id"; + + /** + * A key describing the private data in the CA_descriptor associated with a media track. + * <p> + * This key is set by {@link MediaExtractor} if the track is scrambled with a conditional + * access system, before it receives a valid {@link MediaCas} object. + * <p> + * The associated value is a ByteBuffer. + * @hide + */ + public static final String KEY_CA_PRIVATE_DATA = "ca-private-data"; + /* package private */ MediaFormat(Map<String, Object> map) { mMap = map; } diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index e3584cf7493e..36664004a4a6 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -88,8 +88,6 @@ public class SwipeHelper implements Gefingerpoken { private Runnable mWatchLongPress; private final long mLongPressTimeout; - protected boolean mSwipingInProgress; - final private int[] mTmpPos = new int[2]; private final int mFalsingThreshold; private boolean mTouchAboveFalsingThreshold; @@ -130,10 +128,6 @@ public class SwipeHelper implements Gefingerpoken { mDisableHwLayers = disableHwLayers; } - public boolean isSwipingInProgress() { - return mSwipingInProgress; - } - private float getPos(MotionEvent ev) { return mSwipeDirection == X ? ev.getX() : ev.getY(); } @@ -325,7 +319,6 @@ public class SwipeHelper implements Gefingerpoken { if (Math.abs(delta) > mPagingTouchSlop && Math.abs(delta) > Math.abs(deltaPerpendicular)) { if (mCallback.canChildBeDragged(mCurrView)) { - mSwipingInProgress = true; mCallback.onBeginDrag(mCurrView); mDragging = true; mInitialTouchPos = getPos(ev); @@ -445,7 +438,6 @@ public class SwipeHelper implements Gefingerpoken { wasRemoved = row.isRemoved(); } if (!mCancelled || wasRemoved) { - mSwipingInProgress = false; mCallback.onChildDismissed(animView); } if (endAction != null) { @@ -637,7 +629,6 @@ public class SwipeHelper implements Gefingerpoken { !swipedFastEnough() /* useAccelerateInterpolator */); } else { // snappity - mSwipingInProgress = false; mCallback.onDragCancelled(mCurrView); snapChild(mCurrView, 0 /* leftTarget */, velocity); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index a7329b0f181a..ff31b261eb85 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -401,6 +401,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd */ private float mBackgroundXFactor = 1f; + private boolean mSwipingInProgress; + private boolean mUsingLightTheme; private boolean mQsExpanded; private boolean mForwardScrollable; @@ -3286,7 +3288,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd || ev.getActionMasked() == MotionEvent.ACTION_UP; handleEmptySpaceClick(ev); boolean expandWantsIt = false; - boolean swipingInProgress = mSwipeHelper.isSwipingInProgress(); + boolean swipingInProgress = mSwipingInProgress; if (mIsExpanded && !swipingInProgress && !mOnlyScrollingInThisMotion) { if (isCancelOrUp) { mExpandHelper.onlyObserveMovements(false); @@ -3341,7 +3343,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd @Override @ShadeViewRefactor(RefactorComponent.INPUT) public boolean onGenericMotionEvent(MotionEvent event) { - if (!isScrollingEnabled() || !mIsExpanded || mSwipeHelper.isSwipingInProgress() || mExpandingNotification + if (!isScrollingEnabled() || !mIsExpanded || mSwipingInProgress || mExpandingNotification || mDisallowScrollingInThisMotion) { return false; } @@ -3568,7 +3570,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd initDownStates(ev); handleEmptySpaceClick(ev); boolean expandWantsIt = false; - boolean swipingInProgress = mSwipeHelper.isSwipingInProgress(); + boolean swipingInProgress = mSwipingInProgress; if (!swipingInProgress && !mOnlyScrollingInThisMotion) { expandWantsIt = mExpandHelper.onInterceptTouchEvent(ev); } @@ -3847,6 +3849,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd } } + @ShadeViewRefactor(RefactorComponent.INPUT) + private void setSwipingInProgress(boolean swiping) { + mSwipingInProgress = swiping; + if (swiping) { + requestDisallowInterceptTouchEvent(true); + } + } + @Override @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void onWindowFocusChanged(boolean hasWindowFocus) { @@ -5642,6 +5652,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd @Override public void onDragCancelled(View v) { + setSwipingInProgress(false); mFalsingManager.onNotificatonStopDismissing(); } @@ -5669,6 +5680,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd */ public void handleChildViewDismissed(View view) { + setSwipingInProgress(false); if (mDismissAllInProgress) { return; } @@ -5737,6 +5749,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd @Override public void onBeginDrag(View v) { mFalsingManager.onNotificatonStartDismissing(); + setSwipingInProgress(true); mAmbientState.onBeginDrag(v); updateContinuousShadowDrawing(); if (mAnimationsEnabled && (mIsExpanded || !isPinnedHeadsUp(v))) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java index 599da3b280be..a4909c77af8c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java @@ -227,7 +227,6 @@ class NotificationSwipeHelper extends SwipeHelper if (mCallback.isExpanded()) { // We don't want to quick-dismiss when it's a heads up as this might lead to closing // of the panel early. - mSwipingInProgress = false; mCallback.handleChildViewDismissed(view); } mCallback.onDismiss(); @@ -247,7 +246,6 @@ class NotificationSwipeHelper extends SwipeHelper @Override public void snapChild(final View animView, final float targetLeft, float velocity) { superSnapChild(animView, targetLeft, velocity); - mSwipingInProgress = false; mCallback.onDragCancelled(animView); if (targetLeft == 0) { handleMenuCoveredOrDismissed(); @@ -354,7 +352,6 @@ class NotificationSwipeHelper extends SwipeHelper public void onMenuShown(View animView) { setExposedMenuView(getTranslatingParentView()); - mSwipingInProgress = false; mCallback.onDragCancelled(animView); Handler handler = getHandler(); diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 1fd68ec1df70..7ca3c53154aa 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -61,9 +61,7 @@ interface IWifiManager ParceledListSlice getPrivilegedConfiguredNetworks(); - WifiConfiguration getMatchingWifiConfig(in ScanResult scanResult); - - List<WifiConfiguration> getAllMatchingWifiConfigs(in ScanResult scanResult); + List<WifiConfiguration> getAllMatchingWifiConfigs(in List<ScanResult> scanResult); List<OsuProvider> getMatchingOsuProviders(in ScanResult scanResult); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 7919074c5a2b..4b6f5fac408a 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1073,42 +1073,27 @@ public class WifiManager { } /** - * Returns a WifiConfiguration matching this ScanResult - * - * @param scanResult scanResult that represents the BSSID - * @return {@link WifiConfiguration} that matches this BSSID or null - * @throws UnsupportedOperationException if Passpoint is not enabled on the device. - * @hide - */ - @UnsupportedAppUsage - public WifiConfiguration getMatchingWifiConfig(ScanResult scanResult) { - try { - return mService.getMatchingWifiConfig(scanResult); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - - /** - * Return all matching WifiConfigurations for this ScanResult. + * Returns all matching WifiConfigurations for a given list of ScanResult. * * An empty list will be returned when no configurations are installed or if no configurations * match the ScanResult. - * - * @param scanResult scanResult that represents the BSSID - * @return A list of {@link WifiConfiguration} + + * @param scanResults a list of scanResult that represents the BSSID + * @return A list of {@link WifiConfiguration} that can have duplicate entries. * @throws UnsupportedOperationException if Passpoint is not enabled on the device. * @hide */ - public List<WifiConfiguration> getAllMatchingWifiConfigs(ScanResult scanResult) { + @SystemApi + @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) + public List<WifiConfiguration> getAllMatchingWifiConfigs( + @NonNull List<ScanResult> scanResults) { try { - return mService.getAllMatchingWifiConfigs(scanResult); + return mService.getAllMatchingWifiConfigs(scanResults); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } - /** * Returns a list of Hotspot 2.0 OSU (Online Sign-Up) providers associated with the given AP. * @@ -1119,6 +1104,7 @@ public class WifiManager { * @throws UnsupportedOperationException if Passpoint is not enabled on the device. * @hide */ + @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public List<OsuProvider> getMatchingOsuProviders(ScanResult scanResult) { try { return mService.getMatchingOsuProviders(scanResult); diff --git a/wifi/java/com/android/server/wifi/AbstractWifiService.java b/wifi/java/com/android/server/wifi/AbstractWifiService.java index eede23b22387..6cdef5051524 100644 --- a/wifi/java/com/android/server/wifi/AbstractWifiService.java +++ b/wifi/java/com/android/server/wifi/AbstractWifiService.java @@ -25,7 +25,6 @@ import android.net.wifi.INetworkRequestMatchCallback; import android.net.wifi.ISoftApCallback; import android.net.wifi.ITrafficStateCallback; import android.net.wifi.IWifiManager; -import android.net.wifi.PasspointManagementObjectDefinition; import android.net.wifi.ScanResult; import android.net.wifi.WifiActivityEnergyInfo; import android.net.wifi.WifiConfiguration; @@ -37,7 +36,6 @@ import android.os.IBinder; import android.os.Messenger; import android.os.ResultReceiver; import android.os.WorkSource; -import android.util.Slog; import java.util.List; @@ -83,17 +81,34 @@ public abstract class AbstractWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } - @Override + /** + * Returns a WifiConfiguration matching this ScanResult + * @param scanResult a single ScanResult Object + * @return + * @deprecated use {@link #getAllMatchingWifiConfigs(List)} instead. + */ + @Deprecated public WifiConfiguration getMatchingWifiConfig(ScanResult scanResult) { throw new UnsupportedOperationException(); } - @Override + /** + * Returns all matching WifiConfigurations for this ScanResult. + * @param scanResult a single ScanResult Object + * @return + * @deprecated use {@link #getAllMatchingWifiConfigs(List)} instead. + */ + @Deprecated public List<WifiConfiguration> getAllMatchingWifiConfigs(ScanResult scanResult) { throw new UnsupportedOperationException(); } @Override + public List<WifiConfiguration> getAllMatchingWifiConfigs(List<ScanResult> scanResults) { + throw new UnsupportedOperationException(); + } + + @Override public List<OsuProvider> getMatchingOsuProviders(ScanResult scanResult) { throw new UnsupportedOperationException(); } diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java index ea41bb39c4d5..ecf65c9d2905 100644 --- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java +++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java @@ -35,7 +35,20 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.anyList; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -62,6 +75,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.ArrayList; +import java.util.List; /** * Unit tests for {@link android.net.wifi.WifiManager}. @@ -1250,4 +1264,26 @@ i * Verify that a call to cancel WPS immediately returns a failure. userSelectionCallbackCaptor.getValue().reject(); verify(iUserSelectionCallback).reject(); } + + /** + * Check the call to getAllMatchingWifiConfigs calls getAllMatchingWifiConfigs of WifiService + * with the provided a list of ScanResult. + */ + @Test + public void testGetAllMatchingWifiConfigs() throws Exception { + mWifiManager.getAllMatchingWifiConfigs(new ArrayList<>()); + + verify(mWifiService).getAllMatchingWifiConfigs(any(List.class)); + } + + /** + * Check the call to getMatchingOsuProviders calls getMatchingOsuProviders of WifiService + * with the provided a single ScanResult. + */ + @Test + public void testGetMatchingOsuProviders() throws Exception { + mWifiManager.getMatchingOsuProviders(new ScanResult()); + + verify(mWifiService).getMatchingOsuProviders(any(ScanResult.class)); + } } |