summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/ConnectivityService.java55
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java4
-rw-r--r--services/java/com/android/server/am/ActivityStack.java17
-rw-r--r--services/java/com/android/server/am/ActivityStackSupervisor.java27
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java2
5 files changed, 63 insertions, 42 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 70418e8..b5f0697 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -4247,27 +4247,35 @@ public class ConnectivityService extends IConnectivityManager.Stub {
log("isMobileOk: linkHasIpv4=" + linkHasIpv4
+ " linkHasIpv6=" + linkHasIpv6);
- // Loop through at most 3 valid addresses or all of the address or until
- // we run out of time
- int loops = Math.min(3, addresses.length);
- for(int validAddr=0, addrTried=0;
- (validAddr < loops) && (addrTried < addresses.length)
- && (SystemClock.elapsedRealtime() < endTime);
- addrTried ++) {
-
- // Choose the address at random but make sure its type is supported
- // TODO: This doesn't work 100% of the time, because we may end up
- // trying the same invalid address more than once and ignoring one
- // of the valid addresses.
- InetAddress hostAddr = addresses[rand.nextInt(addresses.length)];
- if (((hostAddr instanceof Inet4Address) && linkHasIpv4)
- || ((hostAddr instanceof Inet6Address) && linkHasIpv6)) {
- // Valid address, so use it
- validAddr += 1;
- } else {
- // Invalid address so try next address
- continue;
+ final ArrayList<InetAddress> validAddresses =
+ new ArrayList<InetAddress>(addresses.length);
+
+ for (InetAddress addr : addresses) {
+ if (((addr instanceof Inet4Address) && linkHasIpv4) ||
+ ((addr instanceof Inet6Address) && linkHasIpv6)) {
+ validAddresses.add(addr);
+ }
+ }
+
+ if (validAddresses.size() == 0) {
+ return CMP_RESULT_CODE_NO_CONNECTION;
+ }
+
+ int addrTried = 0;
+ while (true) {
+ // Loop through at most 3 valid addresses or until
+ // we run out of time
+ if (addrTried++ >= 3) {
+ log("too many loops tried - giving up");
+ break;
}
+ if (SystemClock.elapsedRealtime() >= endTime) {
+ log("spend too much time - giving up");
+ break;
+ }
+
+ InetAddress hostAddr = validAddresses.get(rand.nextInt(
+ validAddresses.size()));
// Make a route to host so we check the specific interface.
if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI,
@@ -4283,8 +4291,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
// Rewrite the url to have numeric address to use the specific route.
+ // Add a pointless random query param to fool proxies into not caching.
URL newUrl = new URL(orgUri.getScheme(),
- hostAddr.getHostAddress(), orgUri.getPath());
+ hostAddr.getHostAddress(),
+ orgUri.getPath() + "?q=" + rand.nextInt(Integer.MAX_VALUE));
log("isMobileOk: newUrl=" + newUrl);
HttpURLConnection urlConn = null;
@@ -4321,6 +4331,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// occasions where a server returned 200 even though
// the device didn't have a "warm" sim.
log("isMobileOk: not expected responseCode=" + responseCode);
+ // TODO - it would be nice in the single-address case to do
+ // another DNS resolve here, but flushing the cache is a bit
+ // heavy-handed.
result = CMP_RESULT_CODE_REDIRECTED;
}
} catch (Exception e) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index f1c2025..085f9af 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -226,7 +226,7 @@ public final class ActivityManagerService extends ActivityManagerNative
static final boolean DEBUG_RESULTS = localLOGV || false;
static final boolean DEBUG_SERVICE = localLOGV || false;
static final boolean DEBUG_SERVICE_EXECUTING = localLOGV || false;
- static final boolean DEBUG_STACK = localLOGV || true;
+ static final boolean DEBUG_STACK = localLOGV || false;
static final boolean DEBUG_SWITCH = localLOGV || false;
static final boolean DEBUG_TASKS = localLOGV || false;
static final boolean DEBUG_THUMBNAILS = localLOGV || false;
@@ -236,7 +236,7 @@ public final class ActivityManagerService extends ActivityManagerNative
static final boolean DEBUG_VISBILITY = localLOGV || false;
static final boolean DEBUG_PSS = localLOGV || false;
static final boolean DEBUG_LOCKSCREEN = localLOGV || false;
- static final boolean VALIDATE_TOKENS = true;
+ static final boolean VALIDATE_TOKENS = false;
static final boolean SHOW_ACTIVITY_START_TIME = true;
// Control over CPU and battery monitoring.
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 77f874f..26d9bcf 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -551,9 +551,6 @@ final class ActivityStack {
* Move the activities around in the stack to bring a user to the foreground.
*/
final void switchUserLocked(int userId) {
- if (VALIDATE_TOKENS) {
- validateAppTokensLocked();
- }
if (mCurrentUser == userId) {
return;
}
@@ -564,11 +561,16 @@ final class ActivityStack {
for (int i = 0; i < index; ++i) {
TaskRecord task = mTaskHistory.get(i);
if (task.userId == userId) {
+ if (DEBUG_TASKS) Slog.d(TAG, "switchUserLocked: stack=" + getStackId() +
+ " moving " + task + " to top");
mTaskHistory.remove(i);
mTaskHistory.add(task);
--index;
}
}
+ if (VALIDATE_TOKENS) {
+ validateAppTokensLocked();
+ }
}
void minimalResumeActivityLocked(ActivityRecord r) {
@@ -986,7 +988,7 @@ final class ActivityStack {
*/
final boolean ensureActivitiesVisibleLocked(ActivityRecord top, ActivityRecord starting,
String onlyThisProcess, int configChanges, boolean forceHomeShown) {
- if (true || DEBUG_VISBILITY) Slog.v(
+ if (DEBUG_VISBILITY) Slog.v(
TAG, "ensureActivitiesVisible behind " + top
+ " configChanges=0x" + Integer.toHexString(configChanges));
@@ -1042,7 +1044,7 @@ final class ActivityStack {
r.startFreezingScreenLocked(r.app, configChanges);
}
if (!r.visible) {
- if (true || DEBUG_VISBILITY) Slog.v(
+ if (DEBUG_VISBILITY) Slog.v(
TAG, "Starting and making visible: " + r);
mWindowManager.setAppVisibility(r.appToken, true);
}
@@ -1064,7 +1066,7 @@ final class ActivityStack {
if (r.state != ActivityState.RESUMED && r != starting) {
// If this activity is paused, tell it
// to now show its window.
- if (true || DEBUG_VISBILITY) Slog.v(
+ if (DEBUG_VISBILITY) Slog.v(
TAG, "Making visible and scheduling visibility: " + r);
try {
if (mTranslucentActivityWaiting != null) {
@@ -1118,7 +1120,7 @@ final class ActivityStack {
// Now for any activities that aren't visible to the user, make
// sure they no longer are keeping the screen frozen.
if (r.visible) {
- if (true || DEBUG_VISBILITY) Slog.v(TAG, "Making invisible: " + r);
+ if (DEBUG_VISBILITY) Slog.v(TAG, "Making invisible: " + r);
r.visible = false;
try {
mWindowManager.setAppVisibility(r.appToken, false);
@@ -2951,6 +2953,7 @@ final class ActivityStack {
for (int taskNdx = top; taskNdx >= 0; --taskNdx) {
final TaskRecord task = mTaskHistory.get(taskNdx);
if (task.isHomeTask()) {
+ if (DEBUG_TASKS || DEBUG_STACK) Slog.d(TAG, "moveHomeTaskToTop: moving " + task);
mTaskHistory.remove(taskNdx);
mTaskHistory.add(top, task);
mWindowManager.moveTaskToTop(task.taskId);
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 040f0ac..2895552 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -68,9 +68,8 @@ import android.os.SystemClock;
import android.os.UserHandle;
import android.util.EventLog;
import android.util.Slog;
-import android.util.SparseArray;
+import android.util.SparseIntArray;
-import android.util.SparseBooleanArray;
import com.android.internal.app.HeavyWeightSwitcherActivity;
import com.android.internal.os.TransferPipe;
import com.android.server.am.ActivityManagerService.PendingActivityLaunch;
@@ -89,7 +88,7 @@ public final class ActivityStackSupervisor {
static final boolean DEBUG_ADD_REMOVE = DEBUG || false;
static final boolean DEBUG_APP = DEBUG || false;
static final boolean DEBUG_SAVED_STATE = DEBUG || false;
- static final boolean DEBUG_STATES = DEBUG || true;
+ static final boolean DEBUG_STATES = DEBUG || false;
static final boolean DEBUG_IDLE = DEBUG || false;
public static final int HOME_STACK_ID = 0;
@@ -204,8 +203,8 @@ public final class ActivityStackSupervisor {
*/
final PowerManager.WakeLock mGoingToSleep;
- /** State of the stacks when user switched, indexed by userId. */
- SparseBooleanArray mUserHomeInFront = new SparseBooleanArray(2);
+ /** Stack id of the front stack when user switched, indexed by userId. */
+ SparseIntArray mUserStackInFront = new SparseIntArray(2);
public ActivityStackSupervisor(ActivityManagerService service, Context context,
Looper looper) {
@@ -876,7 +875,7 @@ public final class ActivityStackSupervisor {
throws RemoteException {
r.startFreezingScreenLocked(app, 0);
- if (true) Slog.d(TAG, "realStartActivity: setting app visibility true");
+ if (false) Slog.d(TAG, "realStartActivity: setting app visibility true");
mWindowManager.setAppVisibility(r.appToken, true);
// schedule launch ticks to collect information about slow apps.
@@ -1927,7 +1926,7 @@ public final class ActivityStackSupervisor {
}
void removeUserLocked(int userId) {
- mUserHomeInFront.delete(userId);
+ mUserStackInFront.delete(userId);
}
/**
@@ -2248,8 +2247,8 @@ public final class ActivityStackSupervisor {
}
boolean switchUserLocked(int userId, UserStartedState uss) {
- mUserHomeInFront.put(mCurrentUser, isFrontStack(mHomeStack));
- final boolean homeInFront = mUserHomeInFront.get(userId, true);
+ mUserStackInFront.put(mCurrentUser, getFocusedStack().getStackId());
+ final int restoreStackId = mUserStackInFront.get(userId, HOME_STACK_ID);
mCurrentUser = userId;
mStartingUsers.add(uss);
@@ -2257,7 +2256,13 @@ public final class ActivityStackSupervisor {
mStacks.get(stackNdx).switchUserLocked(userId);
}
+ ActivityStack stack = getStack(restoreStackId);
+ if (stack == null) {
+ stack = mHomeStack;
+ }
+ final boolean homeInFront = stack.isHomeStack();
moveHomeStack(homeInFront);
+ mWindowManager.moveTaskToTop(stack.topTask().taskId);
return homeInFront;
}
@@ -2270,7 +2275,7 @@ public final class ActivityStackSupervisor {
final boolean nowVisible = allResumedActivitiesVisible();
for (int i=0; i<N; i++) {
ActivityRecord s = mStoppingActivities.get(i);
- if (true || localLOGV) Slog.v(TAG, "Stopping " + s + ": nowVisible="
+ if (localLOGV) Slog.v(TAG, "Stopping " + s + ": nowVisible="
+ nowVisible + " waitingVisible=" + s.waitingVisible
+ " finishing=" + s.finishing);
if (s.waitingVisible && nowVisible) {
@@ -2351,7 +2356,7 @@ public final class ActivityStackSupervisor {
pw.print(prefix); pw.print("mStackState="); pw.println(stackStateToString(mStackState));
pw.print(prefix); pw.println("mSleepTimeout: " + mSleepTimeout);
pw.print(prefix); pw.println("mCurTaskId: " + mCurTaskId);
- pw.print(prefix); pw.println("mUserHomeInFront: " + mUserHomeInFront);
+ pw.print(prefix); pw.println("mUserStackInFront: " + mUserStackInFront);
}
ArrayList<ActivityRecord> getDumpActivitiesLocked(String name) {
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 00a653b..cfb10a0 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -9735,7 +9735,7 @@ public class WindowManagerService extends IWindowManager.Stub
newFocus = computeFocusedWindowLocked();
}
- if (true || DEBUG_FOCUS_LIGHT || localLOGV) Slog.v(TAG, "Changing focus from " +
+ if (DEBUG_FOCUS_LIGHT || localLOGV) Slog.v(TAG, "Changing focus from " +
mCurrentFocus + " to " + newFocus + " Callers=" + Debug.getCallers(4));
final WindowState oldFocus = mCurrentFocus;
mCurrentFocus = newFocus;