diff options
5 files changed, 186 insertions, 88 deletions
diff --git a/core/java/Android.bp b/core/java/Android.bp index a643c29b1da1..303b3e80404c 100644 --- a/core/java/Android.bp +++ b/core/java/Android.bp @@ -170,8 +170,6 @@ filegroup { "com/android/internal/util/IndentingPrintWriter.java", "com/android/internal/util/MessageUtils.java", "com/android/internal/util/WakeupMessage.java", - // TODO: delete as soon as NetworkStatsFactory stops using - "com/android/internal/util/ProcFileReader.java", ], } diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index ee32ce43821c..617c9c2e1513 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -84,12 +84,12 @@ import java.util.function.Consumer; /** * An active voice interaction session, providing a facility for the implementation - * to interact with the user in the voice interaction layer. The user interface is - * initially shown by default, and can be created be overriding {@link #onCreateContentView()} + * to interact with the user in the voice interaction layer. The user interface is + * initially shown by default, and can be created by overriding {@link #onCreateContentView()} * in which the UI can be built. * * <p>A voice interaction session can be self-contained, ultimately calling {@link #finish} - * when done. It can also initiate voice interactions with applications by calling + * when done. It can also initiate voice interactions with applications by calling * {@link #startVoiceActivity}</p>. */ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCallbacks2 { diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index 58f74a0d2a02..dccd392b72ea 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -363,11 +363,13 @@ public class VolumeDialogImpl implements VolumeDialog, // The ringer and rows container has extra height at the top to fit the expanded ringer // drawer. This area should not be touchable unless the ringer drawer is open. + // In landscape the ringer expands to the left and it has to be ensured that if there + // are multiple rows they are touchable. if (view == mTopContainer && !mIsRingerDrawerOpen) { if (!isLandscape()) { y += getRingerDrawerOpenExtraSize(); - } else { - x += getRingerDrawerOpenExtraSize(); + } else if (getRingerDrawerOpenExtraSize() > getVisibleRowsExtraSize()) { + x += (getRingerDrawerOpenExtraSize() - getVisibleRowsExtraSize()); } } @@ -1926,6 +1928,21 @@ public class VolumeDialogImpl implements VolumeDialog, return (mRingerCount - 1) * mRingerDrawerItemSize; } + /** + * Return the size of the additionally visible rows next to the default stream. + * An additional row is visible for example while receiving a voice call. + */ + private int getVisibleRowsExtraSize() { + VolumeRow activeRow = getActiveRow(); + int visibleRows = 0; + for (final VolumeRow row : mRows) { + if (shouldBeVisibleH(row, activeRow)) { + visibleRows++; + } + } + return (visibleRows - 1) * (mDialogWidth + mRingerRowsPadding); + } + private void updateBackgroundForDrawerClosedAmount() { if (mRingerAndDrawerContainerBackground == null) { return; diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 774fe5bc862c..16a060af66ad 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -222,6 +222,11 @@ public class Vpn { */ private static final int VPN_DEFAULT_SCORE = 101; + /** + * The initial token value of IKE session. + */ + private static final int STARTING_TOKEN = -1; + // TODO: create separate trackers for each unique VPN to support // automated reconnection @@ -514,12 +519,8 @@ public class Vpn { @NonNull NetworkScore score, @NonNull NetworkAgentConfig config, @Nullable NetworkProvider provider) { - return new NetworkAgent(context, looper, logTag, nc, lp, score, config, provider) { - @Override - public void onNetworkUnwanted() { - // We are user controlled, not driven by NetworkRequest. - } - }; + return new VpnNetworkAgentWrapper( + context, looper, logTag, nc, lp, score, config, provider); } } @@ -785,7 +786,7 @@ public class Vpn { } } - private boolean isVpnApp(String packageName) { + private static boolean isVpnApp(String packageName) { return packageName != null && !VpnConfig.LEGACY_VPN.equals(packageName); } @@ -1813,7 +1814,7 @@ public class Vpn { Log.wtf(TAG, "Failed to add restricted user to owner", e); } if (mNetworkAgent != null) { - mNetworkAgent.sendNetworkCapabilities(mNetworkCapabilities); + doSendNetworkCapabilities(mNetworkAgent, mNetworkCapabilities); } } setVpnForcedLocked(mLockdown); @@ -1843,7 +1844,7 @@ public class Vpn { Log.wtf(TAG, "Failed to remove restricted user to owner", e); } if (mNetworkAgent != null) { - mNetworkAgent.sendNetworkCapabilities(mNetworkCapabilities); + doSendNetworkCapabilities(mNetworkAgent, mNetworkCapabilities); } } setVpnForcedLocked(mLockdown); @@ -2077,7 +2078,7 @@ public class Vpn { return false; } boolean success = jniAddAddress(mInterface, address, prefixLength); - mNetworkAgent.sendLinkProperties(makeLinkProperties()); + doSendLinkProperties(mNetworkAgent, makeLinkProperties()); return success; } @@ -2086,7 +2087,7 @@ public class Vpn { return false; } boolean success = jniDelAddress(mInterface, address, prefixLength); - mNetworkAgent.sendLinkProperties(makeLinkProperties()); + doSendLinkProperties(mNetworkAgent, makeLinkProperties()); return success; } @@ -2100,8 +2101,11 @@ public class Vpn { // Make defensive copy since the content of array might be altered by the caller. mConfig.underlyingNetworks = (networks != null) ? Arrays.copyOf(networks, networks.length) : null; - mNetworkAgent.setUnderlyingNetworks((mConfig.underlyingNetworks != null) - ? Arrays.asList(mConfig.underlyingNetworks) : null); + doSetUnderlyingNetworks( + mNetworkAgent, + (mConfig.underlyingNetworks != null) + ? Arrays.asList(mConfig.underlyingNetworks) + : null); return true; } @@ -2589,7 +2593,7 @@ public class Vpn { } @Nullable - protected synchronized NetworkCapabilities getRedactedNetworkCapabilitiesOfUnderlyingNetwork( + private synchronized NetworkCapabilities getRedactedNetworkCapabilities( NetworkCapabilities nc) { if (nc == null) return null; return mConnectivityManager.getRedactedNetworkCapabilitiesForPackage( @@ -2597,8 +2601,7 @@ public class Vpn { } @Nullable - protected synchronized LinkProperties getRedactedLinkPropertiesOfUnderlyingNetwork( - LinkProperties lp) { + private synchronized LinkProperties getRedactedLinkProperties(LinkProperties lp) { if (lp == null) return null; return mConnectivityManager.getRedactedLinkPropertiesForPackage(lp, mOwnerUID, mPackage); } @@ -2712,11 +2715,13 @@ public class Vpn { private boolean mIsRunning = true; /** - * The token used by the primary/current/active IKE session. + * The token that identifies the most recently created IKE session. * - * <p>This token MUST be updated when the VPN switches to use a new IKE session. + * <p>This token is monotonically increasing and will never be reset in the lifetime of this + * Ikev2VpnRunner, but it does get reset across runs. It also MUST be accessed on the + * executor thread and updated when a new IKE session is created. */ - private int mCurrentToken = -1; + private int mCurrentToken = STARTING_TOKEN; @Nullable private IpSecTunnelInterface mTunnelIface; @Nullable private Network mActiveNetwork; @@ -2910,7 +2915,7 @@ public class Vpn { return; // Link properties are already sent. } else { // Underlying networks also set in agentConnect() - networkAgent.setUnderlyingNetworks(Collections.singletonList(network)); + doSetUnderlyingNetworks(networkAgent, Collections.singletonList(network)); mNetworkCapabilities = new NetworkCapabilities.Builder(mNetworkCapabilities) .setUnderlyingNetworks(Collections.singletonList(network)) @@ -2920,7 +2925,7 @@ public class Vpn { lp = makeLinkProperties(); // Accesses VPN instance fields; must be locked } - networkAgent.sendLinkProperties(lp); + doSendLinkProperties(networkAgent, lp); } catch (Exception e) { Log.d(TAG, "Error in ChildOpened for token " + token, e); onSessionLost(token, e); @@ -2987,7 +2992,7 @@ public class Vpn { new NetworkCapabilities.Builder(mNetworkCapabilities) .setUnderlyingNetworks(Collections.singletonList(network)) .build(); - mNetworkAgent.setUnderlyingNetworks(Collections.singletonList(network)); + doSetUnderlyingNetworks(mNetworkAgent, Collections.singletonList(network)); } mTunnelIface.setUnderlyingNetwork(network); @@ -3208,7 +3213,7 @@ public class Vpn { mExecutor.schedule( () -> { if (isActiveToken(token)) { - handleSessionLost(null, network); + handleSessionLost(null /* exception */, network); } else { Log.d( TAG, @@ -3225,7 +3230,7 @@ public class Vpn { TimeUnit.MILLISECONDS); } else { Log.d(TAG, "Call handleSessionLost for losing network " + network); - handleSessionLost(null, network); + handleSessionLost(null /* exception */, network); } } @@ -3293,70 +3298,69 @@ public class Vpn { // already terminated due to other failures. cancelHandleNetworkLostTimeout(); - synchronized (Vpn.this) { - String category = null; - int errorClass = -1; - int errorCode = -1; - if (exception instanceof IkeProtocolException) { - final IkeProtocolException ikeException = (IkeProtocolException) exception; - category = VpnManager.CATEGORY_EVENT_IKE_ERROR; - errorCode = ikeException.getErrorType(); - - switch (ikeException.getErrorType()) { - case IkeProtocolException.ERROR_TYPE_NO_PROPOSAL_CHOSEN: // Fallthrough - case IkeProtocolException.ERROR_TYPE_INVALID_KE_PAYLOAD: // Fallthrough - case IkeProtocolException.ERROR_TYPE_AUTHENTICATION_FAILED: // Fallthrough - case IkeProtocolException.ERROR_TYPE_SINGLE_PAIR_REQUIRED: // Fallthrough - case IkeProtocolException.ERROR_TYPE_FAILED_CP_REQUIRED: // Fallthrough - case IkeProtocolException.ERROR_TYPE_TS_UNACCEPTABLE: - // All the above failures are configuration errors, and are terminal - errorClass = VpnManager.ERROR_CLASS_NOT_RECOVERABLE; - break; - // All other cases possibly recoverable. - default: - // All the above failures are configuration errors, and are terminal - errorClass = VpnManager.ERROR_CLASS_RECOVERABLE; - } - } else if (exception instanceof IllegalArgumentException) { - // Failed to build IKE/ChildSessionParams; fatal profile configuration error - markFailedAndDisconnect(exception); - return; - } else if (exception instanceof IkeNetworkLostException) { - category = VpnManager.CATEGORY_EVENT_NETWORK_ERROR; - errorClass = VpnManager.ERROR_CLASS_RECOVERABLE; - errorCode = VpnManager.ERROR_CODE_NETWORK_LOST; - } else if (exception instanceof IkeNonProtocolException) { - category = VpnManager.CATEGORY_EVENT_NETWORK_ERROR; - errorClass = VpnManager.ERROR_CLASS_RECOVERABLE; - if (exception.getCause() instanceof UnknownHostException) { - errorCode = VpnManager.ERROR_CODE_NETWORK_UNKNOWN_HOST; - } else if (exception.getCause() instanceof IkeTimeoutException) { - errorCode = VpnManager.ERROR_CODE_NETWORK_PROTOCOL_TIMEOUT; - } else if (exception.getCause() instanceof IOException) { - errorCode = VpnManager.ERROR_CODE_NETWORK_IO; - } - } else if (exception != null) { - Log.wtf(TAG, "onSessionLost: exception = " + exception); + String category = null; + int errorClass = -1; + int errorCode = -1; + if (exception instanceof IllegalArgumentException) { + // Failed to build IKE/ChildSessionParams; fatal profile configuration error + markFailedAndDisconnect(exception); + return; + } + + if (exception instanceof IkeProtocolException) { + final IkeProtocolException ikeException = (IkeProtocolException) exception; + category = VpnManager.CATEGORY_EVENT_IKE_ERROR; + errorCode = ikeException.getErrorType(); + + switch (ikeException.getErrorType()) { + case IkeProtocolException.ERROR_TYPE_NO_PROPOSAL_CHOSEN: // Fallthrough + case IkeProtocolException.ERROR_TYPE_INVALID_KE_PAYLOAD: // Fallthrough + case IkeProtocolException.ERROR_TYPE_AUTHENTICATION_FAILED: // Fallthrough + case IkeProtocolException.ERROR_TYPE_SINGLE_PAIR_REQUIRED: // Fallthrough + case IkeProtocolException.ERROR_TYPE_FAILED_CP_REQUIRED: // Fallthrough + case IkeProtocolException.ERROR_TYPE_TS_UNACCEPTABLE: + // All the above failures are configuration errors, and are terminal + errorClass = VpnManager.ERROR_CLASS_NOT_RECOVERABLE; + break; + // All other cases possibly recoverable. + default: + errorClass = VpnManager.ERROR_CLASS_RECOVERABLE; } + } else if (exception instanceof IkeNetworkLostException) { + category = VpnManager.CATEGORY_EVENT_NETWORK_ERROR; + errorClass = VpnManager.ERROR_CLASS_RECOVERABLE; + errorCode = VpnManager.ERROR_CODE_NETWORK_LOST; + } else if (exception instanceof IkeNonProtocolException) { + category = VpnManager.CATEGORY_EVENT_NETWORK_ERROR; + errorClass = VpnManager.ERROR_CLASS_RECOVERABLE; + if (exception.getCause() instanceof UnknownHostException) { + errorCode = VpnManager.ERROR_CODE_NETWORK_UNKNOWN_HOST; + } else if (exception.getCause() instanceof IkeTimeoutException) { + errorCode = VpnManager.ERROR_CODE_NETWORK_PROTOCOL_TIMEOUT; + } else if (exception.getCause() instanceof IOException) { + errorCode = VpnManager.ERROR_CODE_NETWORK_IO; + } + } else if (exception != null) { + Log.wtf(TAG, "onSessionLost: exception = " + exception); + } + synchronized (Vpn.this) { // TODO(b/230548427): Remove SDK check once VPN related stuff are // decoupled from ConnectivityServiceTest. if (SdkLevel.isAtLeastT() && category != null && isVpnApp(mPackage)) { sendEventToVpnManagerApp(category, errorClass, errorCode, getPackage(), mSessionKey, makeVpnProfileStateLocked(), mActiveNetwork, - getRedactedNetworkCapabilitiesOfUnderlyingNetwork( - mUnderlyingNetworkCapabilities), - getRedactedLinkPropertiesOfUnderlyingNetwork( - mUnderlyingLinkProperties)); + getRedactedNetworkCapabilities(mUnderlyingNetworkCapabilities), + getRedactedLinkProperties(mUnderlyingLinkProperties)); } + } - if (errorClass == VpnManager.ERROR_CLASS_NOT_RECOVERABLE) { - markFailedAndDisconnect(exception); - return; - } else { - scheduleRetryNewIkeSession(); - } + if (errorClass == VpnManager.ERROR_CLASS_NOT_RECOVERABLE) { + markFailedAndDisconnect(exception); + return; + } else { + scheduleRetryNewIkeSession(); } mUnderlyingNetworkCapabilities = null; @@ -3384,7 +3388,7 @@ public class Vpn { null /*gateway*/, null /*iface*/, RTN_UNREACHABLE)); } if (mNetworkAgent != null) { - mNetworkAgent.sendLinkProperties(makeLinkProperties()); + doSendLinkProperties(mNetworkAgent, makeLinkProperties()); } } } @@ -4121,7 +4125,7 @@ public class Vpn { .setUids(createUserAndRestrictedProfilesRanges( mUserId, null /* allowedApplications */, excludedApps)) .build(); - mNetworkAgent.sendNetworkCapabilities(mNetworkCapabilities); + doSendNetworkCapabilities(mNetworkAgent, mNetworkCapabilities); } } } @@ -4198,6 +4202,85 @@ public class Vpn { return isCurrentIkev2VpnLocked(packageName) ? makeVpnProfileStateLocked() : null; } + /** Proxy to allow different testing setups */ + // TODO: b/240492694 Remove VpnNetworkAgentWrapper and this method when + // NetworkAgent#sendLinkProperties can be un-finalized. + private static void doSendLinkProperties( + @NonNull NetworkAgent agent, @NonNull LinkProperties lp) { + if (agent instanceof VpnNetworkAgentWrapper) { + ((VpnNetworkAgentWrapper) agent).doSendLinkProperties(lp); + } else { + agent.sendLinkProperties(lp); + } + } + + /** Proxy to allow different testing setups */ + // TODO: b/240492694 Remove VpnNetworkAgentWrapper and this method when + // NetworkAgent#sendNetworkCapabilities can be un-finalized. + private static void doSendNetworkCapabilities( + @NonNull NetworkAgent agent, @NonNull NetworkCapabilities nc) { + if (agent instanceof VpnNetworkAgentWrapper) { + ((VpnNetworkAgentWrapper) agent).doSendNetworkCapabilities(nc); + } else { + agent.sendNetworkCapabilities(nc); + } + } + + /** Proxy to allow different testing setups */ + // TODO: b/240492694 Remove VpnNetworkAgentWrapper and this method when + // NetworkAgent#setUnderlyingNetworks can be un-finalized. + private static void doSetUnderlyingNetworks( + @NonNull NetworkAgent agent, @NonNull List<Network> networks) { + if (agent instanceof VpnNetworkAgentWrapper) { + ((VpnNetworkAgentWrapper) agent).doSetUnderlyingNetworks(networks); + } else { + agent.setUnderlyingNetworks(networks); + } + } + + /** + * Proxy to allow testing + * + * @hide + */ + // TODO: b/240492694 Remove VpnNetworkAgentWrapper when NetworkAgent's methods can be + // un-finalized. + @VisibleForTesting + public static class VpnNetworkAgentWrapper extends NetworkAgent { + /** Create an VpnNetworkAgentWrapper */ + public VpnNetworkAgentWrapper( + @NonNull Context context, + @NonNull Looper looper, + @NonNull String logTag, + @NonNull NetworkCapabilities nc, + @NonNull LinkProperties lp, + @NonNull NetworkScore score, + @NonNull NetworkAgentConfig config, + @Nullable NetworkProvider provider) { + super(context, looper, logTag, nc, lp, score, config, provider); + } + + /** Update the LinkProperties */ + public void doSendLinkProperties(@NonNull LinkProperties lp) { + sendLinkProperties(lp); + } + + /** Update the NetworkCapabilities */ + public void doSendNetworkCapabilities(@NonNull NetworkCapabilities nc) { + sendNetworkCapabilities(nc); + } + + /** Set the underlying networks */ + public void doSetUnderlyingNetworks(@NonNull List<Network> networks) { + setUnderlyingNetworks(networks); + } + + @Override + public void onNetworkUnwanted() { + // We are user controlled, not driven by NetworkRequest. + } + } + /** * Proxy to allow testing * diff --git a/startop/view_compiler/dex_builder_test/AndroidTest.xml b/startop/view_compiler/dex_builder_test/AndroidTest.xml index 82509b960f24..59093c79bd0d 100644 --- a/startop/view_compiler/dex_builder_test/AndroidTest.xml +++ b/startop/view_compiler/dex_builder_test/AndroidTest.xml @@ -21,7 +21,7 @@ <option name="test-file-name" value="dex-builder-test.apk" /> </target_preparer> - <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher"> + <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> <option name="cleanup" value="true" /> <option name="push" value="trivial.dex->/data/local/tmp/dex-builder-test/trivial.dex" /> <option name="push" value="simple.dex->/data/local/tmp/dex-builder-test/simple.dex" /> |