Skip to content

Commit

Permalink
Merge cherrypicks of [6716922, 6716923, 6716413, 6717023, 6717024, 67…
Browse files Browse the repository at this point in the history
…16716, 6715859, 6717160, 6717161, 6717162, 6717163, 6716295, 6717141, 6717181, 6717183, 6717184, 6717185, 6714937, 6717028, 6716717, 6716927, 6717200, 6717029, 6717030, 6717031, 6717032, 6717033, 6716928, 6717034, 6717035, 6716929, 6717201, 6716930, 6712377, 6712378, 6716643, 6717164, 6712379] into pi-qpr3-release

Change-Id: Ia3d03b5e53706f20e820855188ce81adb6b8aa97
  • Loading branch information
android-build-team Robot committed Mar 13, 2019
2 parents a84433b + 6457240 commit 2a21bea
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 216 deletions.
Expand Up @@ -121,8 +121,8 @@ public class GpsNetInitiatedHandler {
static private boolean mIsHexInput = true;

// End time of emergency call, and extension, if set
private long mCallEndElapsedRealtimeMillis = 0;
private long mEmergencyExtensionMillis = 0;
private volatile long mCallEndElapsedRealtimeMillis = 0;
private volatile long mEmergencyExtensionMillis = 0;

public static class GpsNiNotification
{
Expand Down Expand Up @@ -245,8 +245,9 @@ public boolean getLocationEnabled() {
*/
public boolean getInEmergency() {
boolean isInEmergencyExtension =
(SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis) <
mEmergencyExtensionMillis;
(mCallEndElapsedRealtimeMillis > 0)
&& ((SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis)
< mEmergencyExtensionMillis);
boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode();
return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension;
}
Expand Down
55 changes: 5 additions & 50 deletions services/core/java/com/android/server/ConnectivityService.java
Expand Up @@ -867,20 +867,15 @@ protected ConnectivityService(Context context, INetworkManagementService netMana

mPermissionMonitor = new PermissionMonitor(mContext, mNetd);

// Set up the listener for user state for creating user VPNs.
// Should run on mHandler to avoid any races.
//set up the listener for user state for creating user VPNs
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_USER_STARTED);
intentFilter.addAction(Intent.ACTION_USER_STOPPED);
intentFilter.addAction(Intent.ACTION_USER_ADDED);
intentFilter.addAction(Intent.ACTION_USER_REMOVED);
intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
mContext.registerReceiverAsUser(
mUserIntentReceiver,
UserHandle.ALL,
intentFilter,
null /* broadcastPermission */,
mHandler);
mUserIntentReceiver, UserHandle.ALL, intentFilter, null, null);
mContext.registerReceiverAsUser(mUserPresentReceiver, UserHandle.SYSTEM,
new IntentFilter(Intent.ACTION_USER_PRESENT), null, null);

Expand Down Expand Up @@ -3820,27 +3815,17 @@ public VpnConfig getVpnConfig(int userId) {
* handler thread through their agent, this is asynchronous. When the capabilities objects
* are computed they will be up-to-date as they are computed synchronously from here and
* this is running on the ConnectivityService thread.
* TODO : Fix this and call updateCapabilities inline to remove out-of-order events.
*/
private void updateAllVpnsCapabilities() {
Network defaultNetwork = getNetwork(getDefaultNetwork());
synchronized (mVpns) {
for (int i = 0; i < mVpns.size(); i++) {
final Vpn vpn = mVpns.valueAt(i);
NetworkCapabilities nc = vpn.updateCapabilities(defaultNetwork);
updateVpnCapabilities(vpn, nc);
vpn.updateCapabilities();
}
}
}

private void updateVpnCapabilities(Vpn vpn, @Nullable NetworkCapabilities nc) {
ensureRunningOnConnectivityServiceThread();
NetworkAgentInfo vpnNai = getNetworkAgentInfoForNetId(vpn.getNetId());
if (vpnNai == null || nc == null) {
return;
}
updateCapabilities(vpnNai.getCurrentScore(), vpnNai, nc);
}

@Override
public boolean updateLockdownVpn() {
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
Expand Down Expand Up @@ -4147,27 +4132,21 @@ private void onUserStop(int userId) {
}

private void onUserAdded(int userId) {
Network defaultNetwork = getNetwork(getDefaultNetwork());
synchronized (mVpns) {
final int vpnsSize = mVpns.size();
for (int i = 0; i < vpnsSize; i++) {
Vpn vpn = mVpns.valueAt(i);
vpn.onUserAdded(userId);
NetworkCapabilities nc = vpn.updateCapabilities(defaultNetwork);
updateVpnCapabilities(vpn, nc);
}
}
}

private void onUserRemoved(int userId) {
Network defaultNetwork = getNetwork(getDefaultNetwork());
synchronized (mVpns) {
final int vpnsSize = mVpns.size();
for (int i = 0; i < vpnsSize; i++) {
Vpn vpn = mVpns.valueAt(i);
vpn.onUserRemoved(userId);
NetworkCapabilities nc = vpn.updateCapabilities(defaultNetwork);
updateVpnCapabilities(vpn, nc);
}
}
}
Expand All @@ -4186,7 +4165,6 @@ private void onUserUnlocked(int userId) {
private BroadcastReceiver mUserIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
ensureRunningOnConnectivityServiceThread();
final String action = intent.getAction();
final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
if (userId == UserHandle.USER_NULL) return;
Expand Down Expand Up @@ -4672,19 +4650,6 @@ private NetworkAgentInfo getDefaultNetwork() {
return getNetworkForRequest(mDefaultRequest.requestId);
}

@Nullable
private Network getNetwork(@Nullable NetworkAgentInfo nai) {
return nai != null ? nai.network : null;
}

private void ensureRunningOnConnectivityServiceThread() {
if (mHandler.getLooper().getThread() != Thread.currentThread()) {
throw new IllegalStateException(
"Not running on ConnectivityService thread: "
+ Thread.currentThread().getName());
}
}

private boolean isDefaultNetwork(NetworkAgentInfo nai) {
return nai == getDefaultNetwork();
}
Expand Down Expand Up @@ -5232,8 +5197,6 @@ private void makeDefault(NetworkAgentInfo newNetwork) {
updateTcpBufferSizes(newNetwork);
mDnsManager.setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers());
notifyIfacesChangedForNetworkStats();
// Fix up the NetworkCapabilities of any VPNs that don't specify underlying networks.
updateAllVpnsCapabilities();
}

private void processListenRequests(NetworkAgentInfo nai, boolean capabilitiesChanged) {
Expand Down Expand Up @@ -5667,10 +5630,6 @@ private void updateNetworkInfo(NetworkAgentInfo networkAgent, NetworkInfo newInf
// doing.
updateSignalStrengthThresholds(networkAgent, "CONNECT", null);

if (networkAgent.isVPN()) {
updateAllVpnsCapabilities();
}

// Consider network even though it is not yet validated.
final long now = SystemClock.elapsedRealtime();
rematchNetworkAndRequests(networkAgent, ReapUnvalidatedNetworks.REAP, now);
Expand Down Expand Up @@ -5864,11 +5823,7 @@ public boolean setUnderlyingNetworksForVpn(Network[] networks) {
success = mVpns.get(user).setUnderlyingNetworks(networks);
}
if (success) {
mHandler.post(() -> {
// Update VPN's capabilities based on updated underlying network set.
updateAllVpnsCapabilities();
notifyIfacesChangedForNetworkStats();
});
mHandler.post(() -> notifyIfacesChangedForNetworkStats());
}
return success;
}
Expand Down
4 changes: 3 additions & 1 deletion services/core/java/com/android/server/am/ActivityStack.java
Expand Up @@ -2494,7 +2494,9 @@ private boolean resumeTopActivityInnerLocked(ActivityRecord prev, ActivityOption

if (prev != null && prev != next) {
if (!mStackSupervisor.mActivitiesWaitingForVisibleActivity.contains(prev)
&& next != null && !next.nowVisible) {
&& next != null && !next.nowVisible
&& checkKeyguardVisibility(next, true /* shouldBeVisible */,
next.isTopRunningActivity())) {
mStackSupervisor.mActivitiesWaitingForVisibleActivity.add(prev);
if (DEBUG_SWITCH) Slog.v(TAG_SWITCH,
"Resuming top, waiting visible to hide: " + prev);
Expand Down
66 changes: 14 additions & 52 deletions services/core/java/com/android/server/connectivity/Vpn.java
Expand Up @@ -273,7 +273,7 @@ protected Vpn(Looper looper, Context context, INetworkManagementService netServi
mNetworkCapabilities = new NetworkCapabilities();
mNetworkCapabilities.addTransportType(NetworkCapabilities.TRANSPORT_VPN);
mNetworkCapabilities.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN);
updateCapabilities(null /* defaultNetwork */);
updateCapabilities();

loadAlwaysOnPackage();
}
Expand All @@ -300,39 +300,18 @@ protected void updateState(DetailedState detailedState, String reason) {
updateAlwaysOnNotification(detailedState);
}

/**
* Updates {@link #mNetworkCapabilities} based on current underlying networks and returns a
* defensive copy.
*
* <p>Does not propagate updated capabilities to apps.
*
* @param defaultNetwork underlying network for VPNs following platform's default
*/
public synchronized NetworkCapabilities updateCapabilities(
@Nullable Network defaultNetwork) {
if (mConfig == null) {
// VPN is not running.
return null;
}

Network[] underlyingNetworks = mConfig.underlyingNetworks;
if (underlyingNetworks == null && defaultNetwork != null) {
// null underlying networks means to track the default.
underlyingNetworks = new Network[] { defaultNetwork };
}

applyUnderlyingCapabilities(
mContext.getSystemService(ConnectivityManager.class),
underlyingNetworks,
public void updateCapabilities() {
final Network[] underlyingNetworks = (mConfig != null) ? mConfig.underlyingNetworks : null;
updateCapabilities(mContext.getSystemService(ConnectivityManager.class), underlyingNetworks,
mNetworkCapabilities);

return new NetworkCapabilities(mNetworkCapabilities);
if (mNetworkAgent != null) {
mNetworkAgent.sendNetworkCapabilities(mNetworkCapabilities);
}
}

@VisibleForTesting
public static void applyUnderlyingCapabilities(
ConnectivityManager cm,
Network[] underlyingNetworks,
public static void updateCapabilities(ConnectivityManager cm, Network[] underlyingNetworks,
NetworkCapabilities caps) {
int[] transportTypes = new int[] { NetworkCapabilities.TRANSPORT_VPN };
int downKbps = NetworkCapabilities.LINK_BANDWIDTH_UNSPECIFIED;
Expand All @@ -344,7 +323,6 @@ public static void applyUnderlyingCapabilities(
boolean hadUnderlyingNetworks = false;
if (null != underlyingNetworks) {
for (Network underlying : underlyingNetworks) {
// TODO(b/124469351): Get capabilities directly from ConnectivityService instead.
final NetworkCapabilities underlyingCaps = cm.getNetworkCapabilities(underlying);
if (underlyingCaps == null) continue;
hadUnderlyingNetworks = true;
Expand Down Expand Up @@ -1015,8 +993,9 @@ private void agentDisconnect() {
}

/**
* Establish a VPN network and return the file descriptor of the VPN interface. This methods
* returns {@code null} if the application is revoked or not prepared.
* Establish a VPN network and return the file descriptor of the VPN
* interface. This methods returns {@code null} if the application is
* revoked or not prepared.
*
* @param config The parameters to configure the network.
* @return The file descriptor of the VPN interface.
Expand Down Expand Up @@ -1263,11 +1242,6 @@ static private List<UidRange> uidRangesForUser(int userHandle, Set<UidRange> exi
return ranges;
}

/**
* Updates UID ranges for this VPN and also updates its internal capabilities.
*
* <p>Should be called on primary ConnectivityService thread.
*/
public void onUserAdded(int userHandle) {
// If the user is restricted tie them to the parent user's VPN
UserInfo user = UserManager.get(mContext).getUserInfo(userHandle);
Expand All @@ -1278,9 +1252,8 @@ public void onUserAdded(int userHandle) {
try {
addUserToRanges(existingRanges, userHandle, mConfig.allowedApplications,
mConfig.disallowedApplications);
// ConnectivityService will call {@link #updateCapabilities} and apply
// those for VPN network.
mNetworkCapabilities.setUids(existingRanges);
updateCapabilities();
} catch (Exception e) {
Log.wtf(TAG, "Failed to add restricted user to owner", e);
}
Expand All @@ -1290,11 +1263,6 @@ public void onUserAdded(int userHandle) {
}
}

/**
* Updates UID ranges for this VPN and also updates its capabilities.
*
* <p>Should be called on primary ConnectivityService thread.
*/
public void onUserRemoved(int userHandle) {
// clean up if restricted
UserInfo user = UserManager.get(mContext).getUserInfo(userHandle);
Expand All @@ -1306,9 +1274,8 @@ public void onUserRemoved(int userHandle) {
final List<UidRange> removedRanges =
uidRangesForUser(userHandle, existingRanges);
existingRanges.removeAll(removedRanges);
// ConnectivityService will call {@link #updateCapabilities} and
// apply those for VPN network.
mNetworkCapabilities.setUids(existingRanges);
updateCapabilities();
} catch (Exception e) {
Log.wtf(TAG, "Failed to remove restricted user to owner", e);
}
Expand Down Expand Up @@ -1516,12 +1483,6 @@ public synchronized boolean removeAddress(String address, int prefixLength) {
return success;
}

/**
* Updates underlying network set.
*
* <p>Note: Does not updates capabilities. Call {@link #updateCapabilities} from
* ConnectivityService thread to get updated capabilities.
*/
public synchronized boolean setUnderlyingNetworks(Network[] networks) {
if (!isCallerEstablishedOwnerLocked()) {
return false;
Expand All @@ -1538,6 +1499,7 @@ public synchronized boolean setUnderlyingNetworks(Network[] networks) {
}
}
}
updateCapabilities();
return true;
}

Expand Down
Expand Up @@ -810,12 +810,11 @@ public GnssLocationProvider(Context context, ILocationManager ilocationManager,
// while IO initialization and registration is delegated to our internal handler
// this approach is just fine because events are posted to our handler anyway
mProperties = new Properties();
sendMessage(INITIALIZE_HANDLER, 0, null);

// Create a GPS net-initiated handler.
// Create a GPS net-initiated handler (also needed by handleInitialize)
mNIHandler = new GpsNetInitiatedHandler(context,
mNetInitiatedListener,
mSuplEsEnabled);
sendMessage(INITIALIZE_HANDLER, 0, null);

mListenerHelper = new GnssStatusListenerHelper(mHandler) {
@Override
Expand Down
8 changes: 8 additions & 0 deletions telephony/java/android/telephony/CarrierConfigManager.java
Expand Up @@ -2070,6 +2070,13 @@ public CarrierConfigManager() {
public static final String KEY_UNDELIVERED_SMS_MESSAGE_EXPIRATION_TIME =
"undelivered_sms_message_expiration_time";

/**
* Indicates use 3GPP application to replace 3GPP2 application even if it's a CDMA/CDMA-LTE
* phone, becasue some carriers's CSIM application is present but not supported.
* @hide
*/
public static final String KEY_USE_USIM_BOOL = "use_usim_bool";

/** The default value for every variable. */
private final static PersistableBundle sDefaults;

Expand Down Expand Up @@ -2402,6 +2409,7 @@ public CarrierConfigManager() {
-85 /* SIGNAL_STRENGTH_GREAT */
});
sDefaults.putString(KEY_WCDMA_DEFAULT_SIGNAL_STRENGTH_MEASUREMENT_STRING, "");
sDefaults.putBoolean(KEY_USE_USIM_BOOL, false);
}

/**
Expand Down

0 comments on commit 2a21bea

Please sign in to comment.