Merge "Window position not reported if the window is not moved." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
85b1041f89
@@ -17,6 +17,7 @@
|
||||
package android.inputmethodservice;
|
||||
|
||||
import com.android.internal.os.HandlerCaller;
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.view.IInputMethodCallback;
|
||||
import com.android.internal.view.IInputMethodSession;
|
||||
|
||||
@@ -91,28 +92,28 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
|
||||
(ExtractedText)msg.obj);
|
||||
return;
|
||||
case DO_DISPATCH_KEY_EVENT: {
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
mInputMethodSession.dispatchKeyEvent(msg.arg1,
|
||||
(KeyEvent)args.arg1,
|
||||
new InputMethodEventCallbackWrapper(
|
||||
(IInputMethodCallback)args.arg2));
|
||||
mCaller.recycleArgs(args);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_DISPATCH_TRACKBALL_EVENT: {
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
mInputMethodSession.dispatchTrackballEvent(msg.arg1,
|
||||
(MotionEvent)args.arg1,
|
||||
new InputMethodEventCallbackWrapper(
|
||||
(IInputMethodCallback)args.arg2));
|
||||
mCaller.recycleArgs(args);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_UPDATE_SELECTION: {
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
mInputMethodSession.updateSelection(args.argi1, args.argi2,
|
||||
args.argi3, args.argi4, args.argi5, args.argi6);
|
||||
mCaller.recycleArgs(args);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_UPDATE_CURSOR: {
|
||||
@@ -120,10 +121,10 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
|
||||
return;
|
||||
}
|
||||
case DO_APP_PRIVATE_COMMAND: {
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
mInputMethodSession.appPrivateCommand((String)args.arg1,
|
||||
(Bundle)args.arg2);
|
||||
mCaller.recycleArgs(args);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_TOGGLE_SOFT_INPUT: {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.inputmethodservice;
|
||||
|
||||
import com.android.internal.os.HandlerCaller;
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.view.IInputContext;
|
||||
import com.android.internal.view.IInputMethod;
|
||||
import com.android.internal.view.IInputMethodCallback;
|
||||
@@ -124,7 +125,7 @@ class IInputMethodWrapper extends IInputMethod.Stub
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
target.dump((FileDescriptor)args.arg1,
|
||||
(PrintWriter)args.arg2, (String[])args.arg3);
|
||||
@@ -134,6 +135,7 @@ class IInputMethodWrapper extends IInputMethod.Stub
|
||||
synchronized (args.arg4) {
|
||||
((CountDownLatch)args.arg4).countDown();
|
||||
}
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,23 +151,25 @@ class IInputMethodWrapper extends IInputMethod.Stub
|
||||
inputMethod.unbindInput();
|
||||
return;
|
||||
case DO_START_INPUT: {
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
IInputContext inputContext = (IInputContext)args.arg1;
|
||||
InputConnection ic = inputContext != null
|
||||
? new InputConnectionWrapper(inputContext) : null;
|
||||
EditorInfo info = (EditorInfo)args.arg2;
|
||||
info.makeCompatible(mTargetSdkVersion);
|
||||
inputMethod.startInput(ic, info);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_RESTART_INPUT: {
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
IInputContext inputContext = (IInputContext)args.arg1;
|
||||
InputConnection ic = inputContext != null
|
||||
? new InputConnectionWrapper(inputContext) : null;
|
||||
EditorInfo info = (EditorInfo)args.arg2;
|
||||
info.makeCompatible(mTargetSdkVersion);
|
||||
inputMethod.restartInput(ic, info);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_CREATE_SESSION: {
|
||||
|
||||
@@ -255,7 +255,7 @@ public abstract class WallpaperService extends Service {
|
||||
|
||||
final BaseIWindow mWindow = new BaseIWindow() {
|
||||
@Override
|
||||
public void resized(int w, int h, Rect contentInsets,
|
||||
public void resized(Rect frame, Rect contentInsets,
|
||||
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
|
||||
Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
|
||||
reportDraw ? 1 : 0);
|
||||
|
||||
@@ -25,16 +25,14 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Pool;
|
||||
import android.util.Poolable;
|
||||
import android.util.PoolableManager;
|
||||
import android.util.Pools;
|
||||
import android.util.SparseLongArray;
|
||||
import android.view.accessibility.AccessibilityInteractionClient;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityNodeProvider;
|
||||
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -48,7 +46,6 @@ import java.util.Map;
|
||||
* UI thread.
|
||||
*/
|
||||
final class AccessibilityInteractionController {
|
||||
private static final int POOL_SIZE = 5;
|
||||
|
||||
private ArrayList<AccessibilityNodeInfo> mTempAccessibilityNodeInfoList =
|
||||
new ArrayList<AccessibilityNodeInfo>();
|
||||
@@ -76,60 +73,6 @@ final class AccessibilityInteractionController {
|
||||
mPrefetcher = new AccessibilityNodePrefetcher();
|
||||
}
|
||||
|
||||
// Reusable poolable arguments for interacting with the view hierarchy
|
||||
// to fit more arguments than Message and to avoid sharing objects between
|
||||
// two messages since several threads can send messages concurrently.
|
||||
private final Pool<SomeArgs> mPool = Pools.synchronizedPool(Pools.finitePool(
|
||||
new PoolableManager<SomeArgs>() {
|
||||
public SomeArgs newInstance() {
|
||||
return new SomeArgs();
|
||||
}
|
||||
|
||||
public void onAcquired(SomeArgs info) {
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public void onReleased(SomeArgs info) {
|
||||
info.clear();
|
||||
}
|
||||
}, POOL_SIZE)
|
||||
);
|
||||
|
||||
private class SomeArgs implements Poolable<SomeArgs> {
|
||||
private SomeArgs mNext;
|
||||
private boolean mIsPooled;
|
||||
|
||||
public Object arg1;
|
||||
public Object arg2;
|
||||
public int argi1;
|
||||
public int argi2;
|
||||
public int argi3;
|
||||
|
||||
public SomeArgs getNextPoolable() {
|
||||
return mNext;
|
||||
}
|
||||
|
||||
public boolean isPooled() {
|
||||
return mIsPooled;
|
||||
}
|
||||
|
||||
public void setNextPoolable(SomeArgs args) {
|
||||
mNext = args;
|
||||
}
|
||||
|
||||
public void setPooled(boolean isPooled) {
|
||||
mIsPooled = isPooled;
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
arg1 = null;
|
||||
arg2 = null;
|
||||
argi1 = 0;
|
||||
argi2 = 0;
|
||||
argi3 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isShown(View view) {
|
||||
// The first two checks are made also made by isShown() which
|
||||
// however traverses the tree up to the parent to catch that.
|
||||
@@ -148,7 +91,7 @@ final class AccessibilityInteractionController {
|
||||
message.what = PrivateHandler.MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_ACCESSIBILITY_ID;
|
||||
message.arg1 = flags;
|
||||
|
||||
SomeArgs args = mPool.acquire();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.argi1 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
|
||||
args.argi2 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
|
||||
args.argi3 = interactionId;
|
||||
@@ -177,7 +120,7 @@ final class AccessibilityInteractionController {
|
||||
final IAccessibilityInteractionConnectionCallback callback =
|
||||
(IAccessibilityInteractionConnectionCallback) args.arg1;
|
||||
|
||||
mPool.release(args);
|
||||
args.recycle();
|
||||
|
||||
List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
|
||||
infos.clear();
|
||||
@@ -216,7 +159,7 @@ final class AccessibilityInteractionController {
|
||||
message.arg1 = flags;
|
||||
message.arg2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
|
||||
|
||||
SomeArgs args = mPool.acquire();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.argi1 = viewId;
|
||||
args.argi2 = interactionId;
|
||||
args.arg1 = callback;
|
||||
@@ -245,7 +188,7 @@ final class AccessibilityInteractionController {
|
||||
final IAccessibilityInteractionConnectionCallback callback =
|
||||
(IAccessibilityInteractionConnectionCallback) args.arg1;
|
||||
|
||||
mPool.release(args);
|
||||
args.recycle();
|
||||
|
||||
AccessibilityNodeInfo info = null;
|
||||
try {
|
||||
@@ -284,7 +227,7 @@ final class AccessibilityInteractionController {
|
||||
message.what = PrivateHandler.MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_TEXT;
|
||||
message.arg1 = flags;
|
||||
|
||||
SomeArgs args = mPool.acquire();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = text;
|
||||
args.arg2 = callback;
|
||||
args.argi1 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
|
||||
@@ -315,7 +258,7 @@ final class AccessibilityInteractionController {
|
||||
final int accessibilityViewId = args.argi1;
|
||||
final int virtualDescendantId = args.argi2;
|
||||
final int interactionId = args.argi3;
|
||||
mPool.release(args);
|
||||
args.recycle();
|
||||
|
||||
List<AccessibilityNodeInfo> infos = null;
|
||||
try {
|
||||
@@ -383,7 +326,7 @@ final class AccessibilityInteractionController {
|
||||
message.arg1 = flags;
|
||||
message.arg2 = focusType;
|
||||
|
||||
SomeArgs args = mPool.acquire();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.argi1 = interactionId;
|
||||
args.argi2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
|
||||
args.argi3 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
|
||||
@@ -414,7 +357,7 @@ final class AccessibilityInteractionController {
|
||||
final IAccessibilityInteractionConnectionCallback callback =
|
||||
(IAccessibilityInteractionConnectionCallback) args.arg1;
|
||||
|
||||
mPool.release(args);
|
||||
args.recycle();
|
||||
|
||||
AccessibilityNodeInfo focused = null;
|
||||
try {
|
||||
@@ -480,8 +423,7 @@ final class AccessibilityInteractionController {
|
||||
message.arg1 = flags;
|
||||
message.arg2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
|
||||
|
||||
SomeArgs args = mPool.acquire();
|
||||
args.argi1 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.argi2 = direction;
|
||||
args.argi3 = interactionId;
|
||||
args.arg1 = callback;
|
||||
@@ -505,13 +447,12 @@ final class AccessibilityInteractionController {
|
||||
final int accessibilityViewId = message.arg2;
|
||||
|
||||
SomeArgs args = (SomeArgs) message.obj;
|
||||
final int virtualDescendantId = args.argi1;
|
||||
final int direction = args.argi2;
|
||||
final int interactionId = args.argi3;
|
||||
final IAccessibilityInteractionConnectionCallback callback =
|
||||
(IAccessibilityInteractionConnectionCallback) args.arg1;
|
||||
|
||||
mPool.release(args);
|
||||
args.recycle();
|
||||
|
||||
AccessibilityNodeInfo next = null;
|
||||
try {
|
||||
@@ -552,7 +493,7 @@ final class AccessibilityInteractionController {
|
||||
message.arg1 = flags;
|
||||
message.arg2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
|
||||
|
||||
SomeArgs args = mPool.acquire();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.argi1 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
|
||||
args.argi2 = action;
|
||||
args.argi3 = interactionId;
|
||||
@@ -585,7 +526,7 @@ final class AccessibilityInteractionController {
|
||||
(IAccessibilityInteractionConnectionCallback) args.arg1;
|
||||
Bundle arguments = (Bundle) args.arg2;
|
||||
|
||||
mPool.release(args);
|
||||
args.recycle();
|
||||
|
||||
boolean succeeded = false;
|
||||
try {
|
||||
|
||||
@@ -45,7 +45,7 @@ oneway interface IWindow {
|
||||
*/
|
||||
void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
|
||||
|
||||
void resized(int w, int h, in Rect contentInsets,
|
||||
void resized(in Rect frame, in Rect contentInsets,
|
||||
in Rect visibleInsets, boolean reportDraw, in Configuration newConfig);
|
||||
void moved(int newX, int newY);
|
||||
void dispatchAppVisibility(boolean visible);
|
||||
|
||||
@@ -74,6 +74,7 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Scroller;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.policy.PolicyManager;
|
||||
import com.android.internal.view.BaseSurfaceHolder;
|
||||
import com.android.internal.view.RootViewSurfaceTaker;
|
||||
@@ -109,7 +110,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
private static final boolean DEBUG_FPS = false;
|
||||
|
||||
private static final boolean USE_RENDER_THREAD = false;
|
||||
|
||||
|
||||
/**
|
||||
* Set this system property to true to force the view hierarchy to render
|
||||
* at 60 Hz. This can be used to measure the potential framerate.
|
||||
@@ -264,12 +265,6 @@ public final class ViewRootImpl implements ViewParent,
|
||||
final Configuration mLastConfiguration = new Configuration();
|
||||
final Configuration mPendingConfiguration = new Configuration();
|
||||
|
||||
class ResizedInfo {
|
||||
Rect contentInsets;
|
||||
Rect visibleInsets;
|
||||
Configuration newConfig;
|
||||
}
|
||||
|
||||
boolean mScrollMayChange;
|
||||
int mSoftInputMode;
|
||||
View mLastScrolledFocus;
|
||||
@@ -2823,29 +2818,31 @@ public final class ViewRootImpl implements ViewParent,
|
||||
case MSG_DISPATCH_GET_NEW_SURFACE:
|
||||
handleGetNewSurface();
|
||||
break;
|
||||
case MSG_RESIZED:
|
||||
ResizedInfo ri = (ResizedInfo)msg.obj;
|
||||
|
||||
if (mWinFrame.width() == msg.arg1 && mWinFrame.height() == msg.arg2
|
||||
&& mPendingContentInsets.equals(ri.contentInsets)
|
||||
&& mPendingVisibleInsets.equals(ri.visibleInsets)
|
||||
&& ((ResizedInfo)msg.obj).newConfig == null) {
|
||||
case MSG_RESIZED: {
|
||||
// Recycled in the fall through...
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
if (mWinFrame.equals((Rect) args.arg1)
|
||||
&& mPendingContentInsets.equals((Rect) args.arg2)
|
||||
&& mPendingVisibleInsets.equals((Rect) args.arg3)
|
||||
&& ((Configuration) args.arg4 == null)) {
|
||||
break;
|
||||
}
|
||||
// fall through...
|
||||
} // fall through...
|
||||
case MSG_RESIZED_REPORT:
|
||||
if (mAdded) {
|
||||
Configuration config = ((ResizedInfo)msg.obj).newConfig;
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
|
||||
Configuration config = (Configuration) args.arg4;
|
||||
if (config != null) {
|
||||
updateConfiguration(config, false);
|
||||
}
|
||||
// TODO: Should left/top stay unchanged and only change the right/bottom?
|
||||
mWinFrame.left = 0;
|
||||
mWinFrame.right = msg.arg1;
|
||||
mWinFrame.top = 0;
|
||||
mWinFrame.bottom = msg.arg2;
|
||||
mPendingContentInsets.set(((ResizedInfo)msg.obj).contentInsets);
|
||||
mPendingVisibleInsets.set(((ResizedInfo)msg.obj).visibleInsets);
|
||||
|
||||
mWinFrame.set((Rect) args.arg1);
|
||||
mPendingContentInsets.set((Rect) args.arg2);
|
||||
mPendingVisibleInsets.set((Rect) args.arg3);
|
||||
|
||||
args.recycle();
|
||||
|
||||
if (msg.what == MSG_RESIZED_REPORT) {
|
||||
mReportNextDraw = true;
|
||||
}
|
||||
@@ -2853,6 +2850,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
if (mView != null) {
|
||||
forceLayout(mView);
|
||||
}
|
||||
|
||||
requestLayout();
|
||||
}
|
||||
break;
|
||||
@@ -4069,26 +4067,25 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
public void dispatchResized(int w, int h, Rect contentInsets,
|
||||
public void dispatchResized(Rect frame, Rect contentInsets,
|
||||
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
|
||||
if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": w=" + w
|
||||
+ " h=" + h + " contentInsets=" + contentInsets.toShortString()
|
||||
if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": frame=" + frame.toShortString()
|
||||
+ " contentInsets=" + contentInsets.toShortString()
|
||||
+ " visibleInsets=" + visibleInsets.toShortString()
|
||||
+ " reportDraw=" + reportDraw);
|
||||
Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT :MSG_RESIZED);
|
||||
Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT : MSG_RESIZED);
|
||||
if (mTranslator != null) {
|
||||
mTranslator.translateRectInScreenToAppWindow(frame);
|
||||
mTranslator.translateRectInScreenToAppWindow(contentInsets);
|
||||
mTranslator.translateRectInScreenToAppWindow(visibleInsets);
|
||||
w *= mTranslator.applicationInvertedScale;
|
||||
h *= mTranslator.applicationInvertedScale;
|
||||
}
|
||||
msg.arg1 = w;
|
||||
msg.arg2 = h;
|
||||
ResizedInfo ri = new ResizedInfo();
|
||||
ri.contentInsets = new Rect(contentInsets);
|
||||
ri.visibleInsets = new Rect(visibleInsets);
|
||||
ri.newConfig = newConfig;
|
||||
msg.obj = ri;
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
final boolean sameProcessCall = (Binder.getCallingPid() == android.os.Process.myPid());
|
||||
args.arg1 = sameProcessCall ? new Rect(frame) : frame;
|
||||
args.arg2 = sameProcessCall ? new Rect(contentInsets) : contentInsets;
|
||||
args.arg3 = sameProcessCall ? new Rect(visibleInsets) : visibleInsets;
|
||||
args.arg4 = sameProcessCall && newConfig != null ? new Configuration(newConfig) : newConfig;
|
||||
msg.obj = args;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@@ -4734,11 +4731,11 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
|
||||
}
|
||||
|
||||
public void resized(int w, int h, Rect contentInsets,
|
||||
public void resized(Rect frame, Rect contentInsets,
|
||||
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
|
||||
final ViewRootImpl viewAncestor = mViewAncestor.get();
|
||||
if (viewAncestor != null) {
|
||||
viewAncestor.dispatchResized(w, h, contentInsets,
|
||||
viewAncestor.dispatchResized(frame, contentInsets,
|
||||
visibleInsets, reportDraw, newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package android.view.inputmethod;
|
||||
|
||||
import com.android.internal.os.HandlerCaller;
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.view.IInputConnectionWrapper;
|
||||
import com.android.internal.view.IInputContext;
|
||||
import com.android.internal.view.IInputMethodCallback;
|
||||
@@ -341,7 +341,7 @@ public final class InputMethodManager {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_DUMP: {
|
||||
HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
doDump((FileDescriptor)args.arg1,
|
||||
(PrintWriter)args.arg2, (String[])args.arg3);
|
||||
@@ -351,6 +351,7 @@ public final class InputMethodManager {
|
||||
synchronized (args.arg4) {
|
||||
((CountDownLatch)args.arg4).countDown();
|
||||
}
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case MSG_BIND: {
|
||||
@@ -486,7 +487,7 @@ public final class InputMethodManager {
|
||||
// interface to the system.
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
HandlerCaller.SomeArgs sargs = new HandlerCaller.SomeArgs();
|
||||
SomeArgs sargs = SomeArgs.obtain();
|
||||
sargs.arg1 = fd;
|
||||
sargs.arg2 = fout;
|
||||
sargs.arg3 = args;
|
||||
|
||||
@@ -22,35 +22,14 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
public class HandlerCaller {
|
||||
private static final String TAG = "HandlerCaller";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
|
||||
public final Context mContext;
|
||||
|
||||
final Looper mMainLooper;
|
||||
final Handler mH;
|
||||
|
||||
final Callback mCallback;
|
||||
|
||||
public static class SomeArgs {
|
||||
SomeArgs next;
|
||||
|
||||
public Object arg1;
|
||||
public Object arg2;
|
||||
public Object arg3;
|
||||
public Object arg4;
|
||||
public int argi1;
|
||||
public int argi2;
|
||||
public int argi3;
|
||||
public int argi4;
|
||||
public int argi5;
|
||||
public int argi6;
|
||||
}
|
||||
|
||||
static final int ARGS_POOL_MAX_SIZE = 10;
|
||||
int mArgsPoolSize;
|
||||
SomeArgs mArgsPool;
|
||||
|
||||
|
||||
class MyHandler extends Handler {
|
||||
MyHandler(Looper looper) {
|
||||
super(looper);
|
||||
@@ -80,29 +59,6 @@ public class HandlerCaller {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public SomeArgs obtainArgs() {
|
||||
synchronized (mH) {
|
||||
SomeArgs args = mArgsPool;
|
||||
if (args != null) {
|
||||
mArgsPool = args.next;
|
||||
args.next = null;
|
||||
mArgsPoolSize--;
|
||||
return args;
|
||||
}
|
||||
}
|
||||
return new SomeArgs();
|
||||
}
|
||||
|
||||
public void recycleArgs(SomeArgs args) {
|
||||
synchronized (mH) {
|
||||
if (mArgsPoolSize < ARGS_POOL_MAX_SIZE) {
|
||||
args.next = mArgsPool;
|
||||
mArgsPool = args;
|
||||
mArgsPoolSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void executeOrSendMessage(Message msg) {
|
||||
// If we are calling this from the main thread, then we can call
|
||||
// right through. Otherwise, we need to send the message to the
|
||||
@@ -141,7 +97,7 @@ public class HandlerCaller {
|
||||
}
|
||||
|
||||
public Message obtainMessageBOO(int what, boolean arg1, Object arg2, Object arg3) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = arg2;
|
||||
args.arg2 = arg3;
|
||||
return mH.obtainMessage(what, arg1 ? 1 : 0, 0, args);
|
||||
@@ -169,28 +125,28 @@ public class HandlerCaller {
|
||||
|
||||
public Message obtainMessageIIOO(int what, int arg1, int arg2,
|
||||
Object arg3, Object arg4) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = arg3;
|
||||
args.arg2 = arg4;
|
||||
return mH.obtainMessage(what, arg1, arg2, args);
|
||||
}
|
||||
|
||||
public Message obtainMessageIOO(int what, int arg1, Object arg2, Object arg3) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = arg2;
|
||||
args.arg2 = arg3;
|
||||
return mH.obtainMessage(what, arg1, 0, args);
|
||||
}
|
||||
|
||||
public Message obtainMessageOO(int what, Object arg1, Object arg2) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = arg1;
|
||||
args.arg2 = arg2;
|
||||
return mH.obtainMessage(what, 0, 0, args);
|
||||
}
|
||||
|
||||
public Message obtainMessageOOO(int what, Object arg1, Object arg2, Object arg3) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = arg1;
|
||||
args.arg2 = arg2;
|
||||
args.arg3 = arg3;
|
||||
@@ -199,7 +155,7 @@ public class HandlerCaller {
|
||||
|
||||
public Message obtainMessageOOOO(int what, Object arg1, Object arg2,
|
||||
Object arg3, Object arg4) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = arg1;
|
||||
args.arg2 = arg2;
|
||||
args.arg3 = arg3;
|
||||
@@ -209,7 +165,7 @@ public class HandlerCaller {
|
||||
|
||||
public Message obtainMessageIIII(int what, int arg1, int arg2,
|
||||
int arg3, int arg4) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.argi1 = arg1;
|
||||
args.argi2 = arg2;
|
||||
args.argi3 = arg3;
|
||||
@@ -219,7 +175,7 @@ public class HandlerCaller {
|
||||
|
||||
public Message obtainMessageIIIIII(int what, int arg1, int arg2,
|
||||
int arg3, int arg4, int arg5, int arg6) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.argi1 = arg1;
|
||||
args.argi2 = arg2;
|
||||
args.argi3 = arg3;
|
||||
@@ -231,7 +187,7 @@ public class HandlerCaller {
|
||||
|
||||
public Message obtainMessageIIIIO(int what, int arg1, int arg2,
|
||||
int arg3, int arg4, Object arg5) {
|
||||
SomeArgs args = obtainArgs();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = arg5;
|
||||
args.argi1 = arg1;
|
||||
args.argi2 = arg2;
|
||||
|
||||
95
core/java/com/android/internal/os/SomeArgs.java
Normal file
95
core/java/com/android/internal/os/SomeArgs.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.os;
|
||||
|
||||
/**
|
||||
* Helper class for passing more arguments though a message
|
||||
* and avoiding allocation of a custom class for wrapping the
|
||||
* arguments. This class maintains a pool of instances and
|
||||
* it is responsibility of the client to recycle and instance
|
||||
* once it is no longer used.
|
||||
*/
|
||||
public final class SomeArgs {
|
||||
|
||||
private static final int MAX_POOL_SIZE = 10;
|
||||
|
||||
private static SomeArgs sPool;
|
||||
private static int sPoolSize;
|
||||
private static Object sPoolLock = new Object();
|
||||
|
||||
private SomeArgs mNext;
|
||||
|
||||
private boolean mInPool;
|
||||
|
||||
public Object arg1;
|
||||
public Object arg2;
|
||||
public Object arg3;
|
||||
public Object arg4;
|
||||
public int argi1;
|
||||
public int argi2;
|
||||
public int argi3;
|
||||
public int argi4;
|
||||
public int argi5;
|
||||
public int argi6;
|
||||
|
||||
private SomeArgs() {
|
||||
/* do nothing - reduce visibility */
|
||||
}
|
||||
|
||||
public static SomeArgs obtain() {
|
||||
synchronized (sPoolLock) {
|
||||
if (sPoolSize > 0) {
|
||||
SomeArgs args = sPool;
|
||||
sPool = sPool.mNext;
|
||||
args.mNext = null;
|
||||
args.mInPool = false;
|
||||
sPoolSize--;
|
||||
return args;
|
||||
} else {
|
||||
return new SomeArgs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void recycle() {
|
||||
if (mInPool) {
|
||||
throw new IllegalStateException("Already recycled.");
|
||||
}
|
||||
synchronized (sPoolLock) {
|
||||
clear();
|
||||
if (sPoolSize < MAX_POOL_SIZE) {
|
||||
mNext = sPool;
|
||||
mInPool = true;
|
||||
sPool = this;
|
||||
sPoolSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
arg1 = null;
|
||||
arg2 = null;
|
||||
arg3 = null;
|
||||
arg4 = null;
|
||||
argi1 = 0;
|
||||
argi2 = 0;
|
||||
argi3 = 0;
|
||||
argi4 = 0;
|
||||
argi5 = 0;
|
||||
argi6 = 0;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class BaseIWindow extends IWindow.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resized(int w, int h, Rect contentInsets,
|
||||
public void resized(Rect frame, Rect contentInsets,
|
||||
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
|
||||
if (reportDraw) {
|
||||
try {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.server;
|
||||
|
||||
import com.android.internal.content.PackageMonitor;
|
||||
import com.android.internal.os.HandlerCaller;
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.util.FastXmlSerializer;
|
||||
import com.android.internal.view.IInputContext;
|
||||
import com.android.internal.view.IInputMethod;
|
||||
@@ -2024,7 +2025,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
HandlerCaller.SomeArgs args;
|
||||
SomeArgs args;
|
||||
switch (msg.what) {
|
||||
case MSG_SHOW_IM_PICKER:
|
||||
showInputMethodMenu();
|
||||
@@ -2035,8 +2036,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
return true;
|
||||
|
||||
case MSG_SHOW_IM_SUBTYPE_ENABLER:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
showInputMethodAndSubtypeEnabler((String)args.arg1);
|
||||
args.recycle();
|
||||
return true;
|
||||
|
||||
case MSG_SHOW_IM_CONFIG:
|
||||
@@ -2053,48 +2055,53 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
return true;
|
||||
case MSG_BIND_INPUT:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
((IInputMethod)args.arg1).bindInput((InputBinding)args.arg2);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
case MSG_SHOW_SOFT_INPUT:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
((IInputMethod)args.arg1).showSoftInput(msg.arg1,
|
||||
(ResultReceiver)args.arg2);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
case MSG_HIDE_SOFT_INPUT:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
((IInputMethod)args.arg1).hideSoftInput(0,
|
||||
(ResultReceiver)args.arg2);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
case MSG_ATTACH_TOKEN:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
if (DEBUG) Slog.v(TAG, "Sending attach of token: " + args.arg2);
|
||||
((IInputMethod)args.arg1).attachToken((IBinder)args.arg2);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
case MSG_CREATE_SESSION:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
((IInputMethod)args.arg1).createSession(
|
||||
(IInputMethodCallback)args.arg2);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
// ---------------------------------------------------------
|
||||
|
||||
case MSG_START_INPUT:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
SessionState session = (SessionState)args.arg1;
|
||||
setEnabledSessionInMainThread(session);
|
||||
@@ -2102,9 +2109,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
(EditorInfo)args.arg3);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
case MSG_RESTART_INPUT:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
SessionState session = (SessionState)args.arg1;
|
||||
setEnabledSessionInMainThread(session);
|
||||
@@ -2112,6 +2120,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
(EditorInfo)args.arg3);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
|
||||
// ---------------------------------------------------------
|
||||
@@ -2124,13 +2133,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
return true;
|
||||
case MSG_BIND_METHOD:
|
||||
args = (HandlerCaller.SomeArgs)msg.obj;
|
||||
args = (SomeArgs)msg.obj;
|
||||
try {
|
||||
((IInputMethodClient)args.arg1).onBindMethod(
|
||||
(InputBindResult)args.arg2);
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Client died receiving input method " + args.arg2);
|
||||
}
|
||||
args.recycle();
|
||||
return true;
|
||||
case MSG_SET_ACTIVE:
|
||||
try {
|
||||
|
||||
@@ -8973,9 +8973,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
if (DEBUG_ORIENTATION &&
|
||||
winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i(
|
||||
TAG, "Resizing " + win + " WITH DRAW PENDING");
|
||||
win.mClient.resized((int)winAnimator.mSurfaceW,
|
||||
(int)winAnimator.mSurfaceH,
|
||||
win.mLastContentInsets, win.mLastVisibleInsets,
|
||||
win.mClient.resized(win.mFrame, win.mLastContentInsets, win.mLastVisibleInsets,
|
||||
winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING,
|
||||
configChanged ? win.mConfiguration : null);
|
||||
win.mContentInsetsChanged = false;
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class BridgeWindow implements IWindow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resized(int arg0, int arg1, Rect arg2, Rect arg3,
|
||||
public void resized(Rect arg1, Rect arg2, Rect arg3,
|
||||
boolean arg4, Configuration arg5) throws RemoteException {
|
||||
// pass for now.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user