diff options
| -rw-r--r-- | core/java/android/net/CaptivePortalTracker.java | 9 | ||||
| -rw-r--r-- | core/java/android/widget/Editor.java | 13 | ||||
| -rw-r--r-- | core/java/android/widget/RelativeLayout.java | 69 | ||||
| -rw-r--r-- | core/java/com/android/internal/util/StateMachine.java | 117 | ||||
| -rw-r--r-- | core/res/res/layout/search_view.xml | 1 | ||||
| -rw-r--r-- | services/java/com/android/server/am/ActivityRecord.java | 9 | ||||
| -rw-r--r-- | services/java/com/android/server/am/ActivityStack.java | 26 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 19 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiWatchdogStateMachine.java | 11 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pService.java | 6 |
10 files changed, 154 insertions, 126 deletions
diff --git a/core/java/android/net/CaptivePortalTracker.java b/core/java/android/net/CaptivePortalTracker.java index ce71e6b04c11..354a8c4a84a6 100644 --- a/core/java/android/net/CaptivePortalTracker.java +++ b/core/java/android/net/CaptivePortalTracker.java @@ -370,13 +370,4 @@ public class CaptivePortalTracker extends StateMachine { } mNotificationShown = visible; } - - private static void log(String s) { - Log.d(TAG, s); - } - - private static void loge(String s) { - Log.e(TAG, s); - } - } diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 4eaa78a72c49..c270e9d1ed74 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -2694,23 +2694,14 @@ public class Editor { TypedArray styledAttributes = mTextView.getContext().obtainStyledAttributes( com.android.internal.R.styleable.SelectionModeDrawables); - boolean allowText = mTextView.getContext().getResources().getBoolean( - com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon); - mode.setTitle(mTextView.getContext().getString( com.android.internal.R.string.textSelectionCABTitle)); mode.setSubtitle(null); mode.setTitleOptionalHint(true); - int selectAllIconId = 0; // No icon by default - if (!allowText) { - // Provide an icon, text will not be displayed on smaller screens. - selectAllIconId = styledAttributes.getResourceId( - R.styleable.SelectionModeDrawables_actionModeSelectAllDrawable, 0); - } - menu.add(0, TextView.ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll). - setIcon(selectAllIconId). + setIcon(styledAttributes.getResourceId( + R.styleable.SelectionModeDrawables_actionModeSelectAllDrawable, 0)). setAlphabeticShortcut('a'). setShowAsAction( MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index 2b7e162d3b9e..dbeb26dbe349 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -37,6 +37,7 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; @@ -220,10 +221,13 @@ public class RelativeLayout extends ViewGroup { // Some apps came to rely on them. :( private boolean mAllowBrokenMeasureSpecs = false; + private int mDisplayWidth; + public RelativeLayout(Context context) { super(context); mAllowBrokenMeasureSpecs = context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; + getDisplayWidth(); } public RelativeLayout(Context context, AttributeSet attrs) { @@ -231,6 +235,7 @@ public class RelativeLayout extends ViewGroup { initFromAttributes(context, attrs); mAllowBrokenMeasureSpecs = context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; + getDisplayWidth(); } public RelativeLayout(Context context, AttributeSet attrs, int defStyle) { @@ -238,6 +243,7 @@ public class RelativeLayout extends ViewGroup { initFromAttributes(context, attrs); mAllowBrokenMeasureSpecs = context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; + getDisplayWidth(); } private void initFromAttributes(Context context, AttributeSet attrs) { @@ -247,6 +253,11 @@ public class RelativeLayout extends ViewGroup { a.recycle(); } + private void getDisplayWidth() { + WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); + mDisplayWidth = wm.getDefaultDisplay().getWidth(); + } + @Override public boolean shouldDelayChildPressedState() { return false; @@ -438,38 +449,19 @@ public class RelativeLayout extends ViewGroup { final boolean isWrapContentWidth = widthMode != MeasureSpec.EXACTLY; final boolean isWrapContentHeight = heightMode != MeasureSpec.EXACTLY; + // We need to know our size for doing the correct computation of children positioning in RTL + // mode but there is no practical way to get it instead of running the code below. + // So, instead of running the code twice, we just set the width to the "display width" + // before the computation and then, as a last pass, we will update their real position with + // an offset equals to "displayWidth - width". + final int layoutDirection = getLayoutDirection(); + if (isLayoutRtl() && myWidth == -1) { + myWidth = mDisplayWidth; + } + View[] views = mSortedHorizontalChildren; int count = views.length; - // We need to know our size for doing the correct computation of positioning in RTL mode - if (isLayoutRtl() && (myWidth == -1 || isWrapContentWidth)) { - int w = getPaddingStart() + getPaddingEnd(); - for (int i = 0; i < count; i++) { - View child = views[i]; - if (child.getVisibility() != GONE) { - LayoutParams params = (LayoutParams) child.getLayoutParams(); - int[] rules = params.getRules(View.LAYOUT_DIRECTION_LTR); - - applyHorizontalSizeRules(params, myWidth, rules); - measureChildHorizontal(child, params, -1, myHeight); - - w += child.getMeasuredWidth(); - w += params.leftMargin + params.rightMargin; - } - } - if (myWidth == -1) { - // Easy case: "myWidth" was undefined before so use the width we have just computed - myWidth = w; - } else { - // "myWidth" was defined before, so take the min of it and the computed width if it - // is a non null one - if (w > 0) { - myWidth = Math.min(myWidth, w); - } - } - } - - final int layoutDirection = getLayoutDirection(); for (int i = 0; i < count; i++) { View child = views[i]; if (child.getVisibility() != GONE) { @@ -500,7 +492,11 @@ public class RelativeLayout extends ViewGroup { } if (isWrapContentWidth) { - width = Math.max(width, params.mRight); + if (isLayoutRtl()) { + width = Math.max(width, myWidth - params.mLeft); + } else { + width = Math.max(width, params.mRight); + } } if (isWrapContentHeight) { @@ -628,6 +624,19 @@ public class RelativeLayout extends ViewGroup { } } + if (isLayoutRtl()) { + final int offsetWidth = myWidth - width; + for (int i = 0; i < count; i++) { + View child = getChildAt(i); + if (child.getVisibility() != GONE) { + LayoutParams params = (LayoutParams) child.getLayoutParams(); + params.mLeft -= offsetWidth; + params.mRight -= offsetWidth; + } + } + + } + setMeasuredDimension(width, height); } diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java index 39446599d49a..1e5a97a87cd2 100644 --- a/core/java/com/android/internal/util/StateMachine.java +++ b/core/java/com/android/internal/util/StateMachine.java @@ -35,7 +35,7 @@ import java.util.Vector; * * <p>The state machine defined here is a hierarchical state machine which processes messages * and can have states arranged hierarchically.</p> - * + * * <p>A state is a <code>State</code> object and must implement * <code>processMessage</code> and optionally <code>enter/exit/getName</code>. * The enter/exit methods are equivalent to the construction and destruction @@ -148,7 +148,7 @@ class HelloWorld extends StateMachine { class State1 extends State { @Override public boolean processMessage(Message message) { - Log.d(TAG, "Hello World"); + log("Hello World"); return HANDLED; } } @@ -232,8 +232,6 @@ state mP2 { * <p>The implementation is below and also in StateMachineTest:</p> <code> class Hsm1 extends StateMachine { - private static final String TAG = "hsm1"; - public static final int CMD_1 = 1; public static final int CMD_2 = 2; public static final int CMD_3 = 3; @@ -241,16 +239,16 @@ class Hsm1 extends StateMachine { public static final int CMD_5 = 5; public static Hsm1 makeHsm1() { - Log.d(TAG, "makeHsm1 E"); + log("makeHsm1 E"); Hsm1 sm = new Hsm1("hsm1"); sm.start(); - Log.d(TAG, "makeHsm1 X"); + log("makeHsm1 X"); return sm; } Hsm1(String name) { super(name); - Log.d(TAG, "ctor E"); + log("ctor E"); // Add states, use indentation to show hierarchy addState(mP1); @@ -260,16 +258,16 @@ class Hsm1 extends StateMachine { // Set the initial state setInitialState(mS1); - Log.d(TAG, "ctor X"); + log("ctor X"); } class P1 extends State { @Override public void enter() { - Log.d(TAG, "mP1.enter"); + log("mP1.enter"); } @Override public boolean processMessage(Message message) { boolean retVal; - Log.d(TAG, "mP1.processMessage what=" + message.what); + log("mP1.processMessage what=" + message.what); switch(message.what) { case CMD_2: // CMD_2 will arrive in mS2 before CMD_3 @@ -286,16 +284,16 @@ class Hsm1 extends StateMachine { return retVal; } @Override public void exit() { - Log.d(TAG, "mP1.exit"); + log("mP1.exit"); } } class S1 extends State { @Override public void enter() { - Log.d(TAG, "mS1.enter"); + log("mS1.enter"); } @Override public boolean processMessage(Message message) { - Log.d(TAG, "S1.processMessage what=" + message.what); + log("S1.processMessage what=" + message.what); if (message.what == CMD_1) { // Transition to ourself to show that enter/exit is called transitionTo(mS1); @@ -306,17 +304,17 @@ class Hsm1 extends StateMachine { } } @Override public void exit() { - Log.d(TAG, "mS1.exit"); + log("mS1.exit"); } } class S2 extends State { @Override public void enter() { - Log.d(TAG, "mS2.enter"); + log("mS2.enter"); } @Override public boolean processMessage(Message message) { boolean retVal; - Log.d(TAG, "mS2.processMessage what=" + message.what); + log("mS2.processMessage what=" + message.what); switch(message.what) { case(CMD_2): sendMessage(obtainMessage(CMD_4)); @@ -334,17 +332,17 @@ class Hsm1 extends StateMachine { return retVal; } @Override public void exit() { - Log.d(TAG, "mS2.exit"); + log("mS2.exit"); } } class P2 extends State { @Override public void enter() { - Log.d(TAG, "mP2.enter"); + log("mP2.enter"); sendMessage(obtainMessage(CMD_5)); } @Override public boolean processMessage(Message message) { - Log.d(TAG, "P2.processMessage what=" + message.what); + log("P2.processMessage what=" + message.what); switch(message.what) { case(CMD_3): break; @@ -357,13 +355,13 @@ class Hsm1 extends StateMachine { return HANDLED; } @Override public void exit() { - Log.d(TAG, "mP2.exit"); + log("mP2.exit"); } } @Override void onHalting() { - Log.d(TAG, "halting"); + log("halting"); synchronized (this) { this.notifyAll(); } @@ -386,7 +384,7 @@ synchronize(hsm) { // wait for the messages to be handled hsm.wait(); } catch (InterruptedException e) { - Log.e(TAG, "exception while waiting " + e.getMessage()); + loge("exception while waiting " + e.getMessage()); } } </code> @@ -418,8 +416,7 @@ D/hsm1 ( 1999): halting </code> */ public class StateMachine { - - private static final String TAG = "StateMachine"; + // Name of the state machine and used as logging tag private String mName; /** Message.what value when quitting */ @@ -772,7 +769,7 @@ public class StateMachine { */ @Override public final void handleMessage(Message msg) { - if (mDbg) Log.d(TAG, "handleMessage: E msg.what=" + msg.what); + if (mDbg) mSm.log("handleMessage: E msg.what=" + msg.what); /** Save the current message */ mMsg = msg; @@ -793,7 +790,7 @@ public class StateMachine { } performTransitions(msgProcessedState); - if (mDbg) Log.d(TAG, "handleMessage: X"); + if (mDbg) mSm.log("handleMessage: X"); } /** @@ -813,7 +810,7 @@ public class StateMachine { boolean recordLogMsg = mSm.recordLogRec(mMsg); while (mDestState != null) { - if (mDbg) Log.d(TAG, "handleMessage: new destination call exit"); + if (mDbg) mSm.log("handleMessage: new destination call exit"); /** * Save mDestState locally and set to null @@ -905,7 +902,7 @@ public class StateMachine { * Complete the construction of the state machine. */ private final void completeConstruction() { - if (mDbg) Log.d(TAG, "completeConstruction: E"); + if (mDbg) mSm.log("completeConstruction: E"); /** * Determine the maximum depth of the state hierarchy @@ -921,7 +918,7 @@ public class StateMachine { maxDepth = depth; } } - if (mDbg) Log.d(TAG, "completeConstruction: maxDepth=" + maxDepth); + if (mDbg) mSm.log("completeConstruction: maxDepth=" + maxDepth); mStateStack = new StateInfo[maxDepth]; mTempStateStack = new StateInfo[maxDepth]; @@ -930,7 +927,7 @@ public class StateMachine { /** Sending SM_INIT_CMD message to invoke enter methods asynchronously */ sendMessageAtFrontOfQueue(obtainMessage(SM_INIT_CMD, mSmHandlerObj)); - if (mDbg) Log.d(TAG, "completeConstruction: X"); + if (mDbg) mSm.log("completeConstruction: X"); } /** @@ -942,7 +939,7 @@ public class StateMachine { private final State processMsg(Message msg) { StateInfo curStateInfo = mStateStack[mStateStackTopIndex]; if (mDbg) { - Log.d(TAG, "processMsg: " + curStateInfo.state.getName()); + mSm.log("processMsg: " + curStateInfo.state.getName()); } if (isQuit(msg)) { @@ -961,7 +958,7 @@ public class StateMachine { break; } if (mDbg) { - Log.d(TAG, "processMsg: " + curStateInfo.state.getName()); + mSm.log("processMsg: " + curStateInfo.state.getName()); } } } @@ -976,7 +973,7 @@ public class StateMachine { while ((mStateStackTopIndex >= 0) && (mStateStack[mStateStackTopIndex] != commonStateInfo)) { State curState = mStateStack[mStateStackTopIndex].state; - if (mDbg) Log.d(TAG, "invokeExitMethods: " + curState.getName()); + if (mDbg) mSm.log("invokeExitMethods: " + curState.getName()); curState.exit(); mStateStack[mStateStackTopIndex].active = false; mStateStackTopIndex -= 1; @@ -988,7 +985,7 @@ public class StateMachine { */ private final void invokeEnterMethods(int stateStackEnteringIndex) { for (int i = stateStackEnteringIndex; i <= mStateStackTopIndex; i++) { - if (mDbg) Log.d(TAG, "invokeEnterMethods: " + mStateStack[i].state.getName()); + if (mDbg) mSm.log("invokeEnterMethods: " + mStateStack[i].state.getName()); mStateStack[i].state.enter(); mStateStack[i].active = true; } @@ -1006,7 +1003,7 @@ public class StateMachine { */ for (int i = mDeferredMessages.size() - 1; i >= 0; i-- ) { Message curMsg = mDeferredMessages.get(i); - if (mDbg) Log.d(TAG, "moveDeferredMessageAtFrontOfQueue; what=" + curMsg.what); + if (mDbg) mSm.log("moveDeferredMessageAtFrontOfQueue; what=" + curMsg.what); sendMessageAtFrontOfQueue(curMsg); } mDeferredMessages.clear(); @@ -1024,7 +1021,7 @@ public class StateMachine { int i = mTempStateStackCount - 1; int j = startingIndex; while (i >= 0) { - if (mDbg) Log.d(TAG, "moveTempStackToStateStack: i=" + i + ",j=" + j); + if (mDbg) mSm.log("moveTempStackToStateStack: i=" + i + ",j=" + j); mStateStack[j] = mTempStateStack[i]; j += 1; i -= 1; @@ -1032,7 +1029,7 @@ public class StateMachine { mStateStackTopIndex = j - 1; if (mDbg) { - Log.d(TAG, "moveTempStackToStateStack: X mStateStackTop=" + mSm.log("moveTempStackToStateStack: X mStateStackTop=" + mStateStackTopIndex + ",startingIndex=" + startingIndex + ",Top=" + mStateStack[mStateStackTopIndex].state.getName()); } @@ -1065,7 +1062,7 @@ public class StateMachine { } while ((curStateInfo != null) && !curStateInfo.active); if (mDbg) { - Log.d(TAG, "setupTempStateStackWithStatesToEnter: X mTempStateStackCount=" + mSm.log("setupTempStateStackWithStatesToEnter: X mTempStateStackCount=" + mTempStateStackCount + ",curStateInfo: " + curStateInfo); } return curStateInfo; @@ -1076,7 +1073,7 @@ public class StateMachine { */ private final void setupInitialStateStack() { if (mDbg) { - Log.d(TAG, "setupInitialStateStack: E mInitialState=" + mSm.log("setupInitialStateStack: E mInitialState=" + mInitialState.getName()); } @@ -1117,7 +1114,7 @@ public class StateMachine { */ private final StateInfo addState(State state, State parent) { if (mDbg) { - Log.d(TAG, "addStateInternal: E state=" + state.getName() + mSm.log("addStateInternal: E state=" + state.getName() + ",parent=" + ((parent == null) ? "" : parent.getName())); } StateInfo parentStateInfo = null; @@ -1142,7 +1139,7 @@ public class StateMachine { stateInfo.state = state; stateInfo.parentStateInfo = parentStateInfo; stateInfo.active = false; - if (mDbg) Log.d(TAG, "addStateInternal: X stateInfo: " + stateInfo); + if (mDbg) mSm.log("addStateInternal: X stateInfo: " + stateInfo); return stateInfo; } @@ -1162,19 +1159,19 @@ public class StateMachine { /** @see StateMachine#setInitialState(State) */ private final void setInitialState(State initialState) { - if (mDbg) Log.d(TAG, "setInitialState: initialState=" + initialState.getName()); + if (mDbg) mSm.log("setInitialState: initialState=" + initialState.getName()); mInitialState = initialState; } /** @see StateMachine#transitionTo(IState) */ private final void transitionTo(IState destState) { mDestState = (State) destState; - if (mDbg) Log.d(TAG, "transitionTo: destState=" + mDestState.getName()); + if (mDbg) mSm.log("transitionTo: destState=" + mDestState.getName()); } /** @see StateMachine#deferMessage(Message) */ private final void deferMessage(Message msg) { - if (mDbg) Log.d(TAG, "deferMessage: msg=" + msg.what); + if (mDbg) mSm.log("deferMessage: msg=" + msg.what); /* Copy the "msg" to "newMsg" as "msg" will be recycled */ Message newMsg = obtainMessage(); @@ -1185,17 +1182,17 @@ public class StateMachine { /** @see StateMachine#quit() */ private final void quit() { - if (mDbg) Log.d(TAG, "quit:"); + if (mDbg) mSm.log("quit:"); sendMessage(obtainMessage(SM_QUIT_CMD, mSmHandlerObj)); } /** @see StateMachine#quitNow() */ private final void quitNow() { - if (mDbg) Log.d(TAG, "abort:"); + if (mDbg) mSm.log("quitNow:"); sendMessageAtFrontOfQueue(obtainMessage(SM_QUIT_CMD, mSmHandlerObj)); } - /** Validate that the message was sent by quit or abort. */ + /** Validate that the message was sent by quit or quitNow. */ private final boolean isQuit(Message msg) { return (msg.what == SM_QUIT_CMD) && (msg.obj == mSmHandlerObj); } @@ -1337,7 +1334,7 @@ public class StateMachine { * @param msg that couldn't be handled. */ protected void unhandledMessage(Message msg) { - if (mSmHandler.mDbg) Log.e(TAG, mName + " - unhandledMessage: msg.what=" + msg.what); + if (mSmHandler.mDbg) loge(" - unhandledMessage: msg.what=" + msg.what); } /** @@ -1696,4 +1693,28 @@ public class StateMachine { } pw.println("curState=" + getCurrentState().getName()); } + + protected void log(String s) { + Log.d(mName, s); + } + + protected void logv(String s) { + Log.v(mName, s); + } + + protected void logi(String s) { + Log.i(mName, s); + } + + protected void logd(String s) { + Log.d(mName, s); + } + + protected void logw(String s) { + Log.w(mName, s); + } + + protected void loge(String s) { + Log.e(mName, s); + } } diff --git a/core/res/res/layout/search_view.xml b/core/res/res/layout/search_view.xml index a281fcc881d3..29c0576ffbde 100644 --- a/core/res/res/layout/search_view.xml +++ b/core/res/res/layout/search_view.xml @@ -45,6 +45,7 @@ android:layout_height="match_parent" android:layout_gravity="center_vertical" android:src="?android:attr/searchViewSearchIcon" + android:focusable="true" android:contentDescription="@string/searchview_description_search" /> diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java index 749dc6651d38..3af22876a732 100644 --- a/services/java/com/android/server/am/ActivityRecord.java +++ b/services/java/com/android/server/am/ActivityRecord.java @@ -123,6 +123,8 @@ final class ActivityRecord { boolean frozenBeforeDestroy;// has been frozen but not yet destroyed. boolean immersive; // immersive mode (don't interrupt if possible) boolean forceNewConfig; // force re-create with new config next time + int launchCount; // count of launches since last state + long lastLaunchTime; // time of last lauch of this activity String stringName; // for caching of toString(). @@ -201,7 +203,12 @@ final class ActivityRecord { } } pw.print(prefix); pw.print("launchFailed="); pw.print(launchFailed); - pw.print(" haveState="); pw.print(haveState); + pw.print(" launchCount="); pw.print(launchCount); + pw.print(" lastLaunchTime="); + if (lastLaunchTime == 0) pw.print("0"); + else TimeUtils.formatDuration(lastLaunchTime, now, pw); + pw.println(); + pw.print(prefix); pw.print(" haveState="); pw.print(haveState); pw.print(" icicle="); pw.println(icicle); pw.print(prefix); pw.print("state="); pw.print(state); pw.print(" stopped="); pw.print(stopped); diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index c1b10cfa683b..de9dda4a11cb 100644 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -88,6 +88,7 @@ final class ActivityStack { static final boolean DEBUG_STATES = false; static final boolean DEBUG_ADD_REMOVE = false; static final boolean DEBUG_SAVED_STATE = false; + static final boolean DEBUG_APP = false; static final boolean VALIDATE_TOKENS = ActivityManagerService.VALIDATE_TOKENS; @@ -653,6 +654,8 @@ final class ActivityStack { r.app = app; app.waitingToKill = null; + r.launchCount++; + r.lastLaunchTime = SystemClock.uptimeMillis(); if (localLOGV) Slog.v(TAG, "Launching: " + r); @@ -803,7 +806,7 @@ final class ActivityStack { // Is this activity's application already running? ProcessRecord app = mService.getProcessRecordLocked(r.processName, r.info.applicationInfo.uid); - + if (r.launchTime == 0) { r.launchTime = SystemClock.uptimeMillis(); if (mInitialStartTime == 0) { @@ -1091,6 +1094,7 @@ final class ActivityStack { // haven't really saved the state. r.icicle = icicle; r.haveState = true; + r.launchCount = 0; r.updateThumbnail(thumbnail, description); } if (!r.stopped) { @@ -3931,6 +3935,7 @@ final class ActivityStack { if (setState) { if (DEBUG_STATES) Slog.v(TAG, "Moving to DESTROYED: " + r + " (cleaning up)"); r.state = ActivityState.DESTROYED; + if (DEBUG_APP) Slog.v(TAG, "Clearing app during cleanUp for activity " + r); r.app = null; } @@ -3988,6 +3993,7 @@ final class ActivityStack { if (DEBUG_STATES) Slog.v(TAG, "Moving to DESTROYED: " + r + " (removed from history)"); r.state = ActivityState.DESTROYED; + if (DEBUG_APP) Slog.v(TAG, "Clearing app during remove for activity " + r); r.app = null; mService.mWindowManager.removeAppToken(r.appToken); if (VALIDATE_TOKENS) { @@ -4130,6 +4136,7 @@ final class ActivityStack { if (DEBUG_STATES) Slog.v(TAG, "Moving to DESTROYED: " + r + " (destroy skipped)"); r.state = ActivityState.DESTROYED; + if (DEBUG_APP) Slog.v(TAG, "Clearing app during destroy for activity " + r); r.app = null; } } else { @@ -4141,6 +4148,7 @@ final class ActivityStack { if (DEBUG_STATES) Slog.v(TAG, "Moving to DESTROYED: " + r + " (no app)"); r.state = ActivityState.DESTROYED; + if (DEBUG_APP) Slog.v(TAG, "Clearing app during destroy for activity " + r); r.app = null; } } @@ -4215,7 +4223,21 @@ final class ActivityStack { if (DEBUG_CLEANUP) Slog.v( TAG, "Record #" + i + " " + r + ": app=" + r.app); if (r.app == app) { + boolean remove; if ((!r.haveState && !r.stateNotNeeded) || r.finishing) { + // Don't currently have state for the activity, or + // it is finishing -- always remove it. + remove = true; + } else if (r.launchCount > 2 && + r.lastLaunchTime > (SystemClock.uptimeMillis()-60000)) { + // We have launched this activity too many times since it was + // able to run, so give up and remove it. + remove = true; + } else { + // The process may be gone, but the activity lives on! + remove = false; + } + if (remove) { if (ActivityStack.DEBUG_ADD_REMOVE || DEBUG_CLEANUP) { RuntimeException here = new RuntimeException("here"); here.fillInStackTrace(); @@ -4242,6 +4264,8 @@ final class ActivityStack { if (r.visible) { hasVisibleActivities = true; } + if (DEBUG_APP) Slog.v(TAG, "Clearing app during removeHistory for activity " + + r); r.app = null; r.nowVisible = false; if (!r.haveState) { diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 476ebbc94abc..9c59f63fba82 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -103,7 +103,6 @@ import java.util.regex.Pattern; */ public class WifiStateMachine extends StateMachine { - private static final String TAG = "WifiStateMachine"; private static final String NETWORKTYPE = "WIFI"; private static final boolean DBG = false; @@ -565,7 +564,7 @@ public class WifiStateMachine extends StateMachine { private final IBatteryStats mBatteryStats; public WifiStateMachine(Context context, String wlanInterface) { - super(TAG); + super("WifiStateMachine"); mContext = context; mInterfaceName = wlanInterface; @@ -678,7 +677,7 @@ public class WifiStateMachine extends StateMachine { mScanResultCache = new LruCache<String, ScanResult>(SCAN_RESULT_CACHE_SIZE); PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); - mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); + mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getName()); mSuspendWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WifiSuspend"); mSuspendWakeLock.setReferenceCounted(false); @@ -3132,14 +3131,14 @@ public class WifiStateMachine extends StateMachine { break; default: result = new WpsResult(Status.FAILURE); - Log.e(TAG, "Invalid setup for WPS"); + loge("Invalid setup for WPS"); break; } if (result.status == Status.SUCCESS) { replyToMessage(message, WifiManager.START_WPS_SUCCEEDED, result); transitionTo(mWpsRunningState); } else { - Log.e(TAG, "Failed to start WPS with config " + wpsInfo.toString()); + loge("Failed to start WPS with config " + wpsInfo.toString()); replyToMessage(message, WifiManager.WPS_FAILED, WifiManager.ERROR); } break; @@ -3465,7 +3464,7 @@ public class WifiStateMachine extends StateMachine { public void exit() { /* Request a CS wakelock during transition to mobile */ checkAndSetConnectivityInstance(); - mCm.requestNetworkTransitionWakelock(TAG); + mCm.requestNetworkTransitionWakelock(getName()); } } @@ -4040,12 +4039,4 @@ public class WifiStateMachine extends StateMachine { msg.arg2 = srcMsg.arg2; return msg; } - - private void log(String s) { - Log.d(TAG, s); - } - - private void loge(String s) { - Log.e(TAG, s); - } } diff --git a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java index 423558f4b52d..53e6b519ccf7 100644 --- a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java +++ b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java @@ -77,7 +77,6 @@ public class WifiWatchdogStateMachine extends StateMachine { /* STOPSHIP: Keep this configurable for debugging until ship */ private static boolean DBG = false; - private static final String TAG = "WifiWatchdogStateMachine"; private static final int BASE = Protocol.BASE_WIFI_WATCHDOG; @@ -306,7 +305,7 @@ public class WifiWatchdogStateMachine extends StateMachine { * (all other states) */ private WifiWatchdogStateMachine(Context context) { - super(TAG); + super("WifiWatchdogStateMachine"); mContext = context; mContentResolver = context.getContentResolver(); mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); @@ -968,14 +967,6 @@ public class WifiWatchdogStateMachine extends StateMachine { return Settings.Global.putInt(cr, name, value ? 1 : 0); } - private static void logd(String s) { - Log.d(TAG, s); - } - - private static void loge(String s) { - Log.e(TAG, s); - } - /** * Bundle of good link count parameters */ diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index debf98810006..77604a48cd71 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -2460,11 +2460,13 @@ public class WifiP2pService extends IWifiP2pManager.Stub { return msg; } - private void logd(String s) { + @Override + protected void logd(String s) { Slog.d(TAG, s); } - private void loge(String s) { + @Override + protected void loge(String s) { Slog.e(TAG, s); } |