类android.view.IWindowManager源码实例Demo

下面列出了怎么用android.view.IWindowManager的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: LegacySensorManager.java
public LegacySensorManager(SensorManager sensorManager) {
    mSensorManager = sensorManager;

    synchronized (SensorManager.class) {
        if (!sInitialized) {
            sWindowManager = IWindowManager.Stub.asInterface(
                    ServiceManager.getService("window"));
            if (sWindowManager != null) {
                // if it's null we're running in the system process
                // which won't get the rotated values
                try {
                    sRotation = sWindowManager.watchRotation(
                            new IRotationWatcher.Stub() {
                                public void onRotationChanged(int rotation) {
                                    LegacySensorManager.onRotationChanged(rotation);
                                }
                            }, DEFAULT_DISPLAY);
                } catch (RemoteException e) {
                }
            }
        }
    }
}
 
源代码2 项目: DroidCast   文件: DisplayUtil.java
@SuppressLint("PrivateApi")
public DisplayUtil() {
    Class<?> serviceManagerClass = null;

    try {
        serviceManagerClass = Class.forName("android.os.ServiceManager");

        Method getService = serviceManagerClass.getDeclaredMethod("getService", String.class);

        // WindowManager
        Object ws = getService.invoke(null, Context.WINDOW_SERVICE);

        iWindowManager = IWindowManager.Stub.asInterface((IBinder) ws);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码3 项目: AndroidComponentPlugin   文件: Instrumentation.java
/**
 * Force the global system in or out of touch mode.  This can be used if
 * your instrumentation relies on the UI being in one more or the other
 * when it starts.
 * 
 * @param inTouch Set to true to be in touch mode, false to be in
 * focus mode.
 */
public void setInTouchMode(boolean inTouch) {
    try {
        IWindowManager.Stub.asInterface(
                ServiceManager.getService("window")).setInTouchMode(inTouch);
    } catch (RemoteException e) {
        // Shouldn't happen!
    }
}
 
源代码4 项目: AndroidComponentPlugin   文件: Instrumentation.java
/**
 * Force the global system in or out of touch mode.  This can be used if
 * your instrumentation relies on the UI being in one more or the other
 * when it starts.
 * 
 * @param inTouch Set to true to be in touch mode, false to be in
 * focus mode.
 */
public void setInTouchMode(boolean inTouch) {
    try {
        IWindowManager.Stub.asInterface(
                ServiceManager.getService("window")).setInTouchMode(inTouch);
    } catch (RemoteException e) {
        // Shouldn't happen!
    }
}
 
源代码5 项目: AndroidComponentPlugin   文件: Instrumentation.java
/**
 * Force the global system in or out of touch mode.  This can be used if
 * your instrumentation relies on the UI being in one more or the other
 * when it starts.
 * 
 * @param inTouch Set to true to be in touch mode, false to be in
 * focus mode.
 */
public void setInTouchMode(boolean inTouch) {
    try {
        IWindowManager.Stub.asInterface(
                ServiceManager.getService("window")).setInTouchMode(inTouch);
    } catch (RemoteException e) {
        // Shouldn't happen!
    }
}
 
源代码6 项目: AndroidComponentPlugin   文件: Instrumentation.java
/**
 * Force the global system in or out of touch mode.  This can be used if
 * your instrumentation relies on the UI being in one more or the other
 * when it starts.
 * 
 * @param inTouch Set to true to be in touch mode, false to be in
 * focus mode.
 */
public void setInTouchMode(boolean inTouch) {
    try {
        IWindowManager.Stub.asInterface(
                ServiceManager.getService("window")).setInTouchMode(inTouch);
    } catch (RemoteException e) {
        // Shouldn't happen!
    }
}
 
public WallpaperManagerService(Context context) {
    if (DEBUG) Slog.v(TAG, "WallpaperService startup");
    mContext = context;
    mShuttingDown = false;
    mImageWallpaper = ComponentName.unflattenFromString(
            context.getResources().getString(R.string.image_wallpaper_component));
    mDefaultWallpaperComponent = WallpaperManager.getDefaultWallpaperComponent(context);
    mIWindowManager = IWindowManager.Stub.asInterface(
            ServiceManager.getService(Context.WINDOW_SERVICE));
    mIPackageManager = AppGlobals.getPackageManager();
    mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
    mMonitor = new MyPackageMonitor();
    mColorsChangedListeners = new SparseArray<>();
}
 
源代码8 项目: android_9.0.0_r45   文件: ShortcutService.java
boolean injectIsSafeModeEnabled() {
    final long token = injectClearCallingIdentity();
    try {
        return IWindowManager.Stub
                .asInterface(ServiceManager.getService(Context.WINDOW_SERVICE))
                .isSafeModeEnabled();
    } catch (RemoteException e) {
        return false; // Shouldn't happen though.
    } finally {
        injectRestoreCallingIdentity(token);
    }
}
 
源代码9 项目: android_9.0.0_r45   文件: AssistDataRequester.java
/**
 * @param callbacks The callbacks to handle the asynchronous reply with the assist data.
 * @param callbacksLock The lock for the requester to hold when calling any of the
 *                     {@param callbacks}. The owner should also take care in locking
 *                     appropriately when calling into this requester.
 * @param requestStructureAppOps The app ops to check before requesting the assist structure
 * @param requestScreenshotAppOps The app ops to check before requesting the assist screenshot.
 *                                This can be {@link AppOpsManager#OP_NONE} to indicate that
 *                                screenshots should never be fetched.
 */
public AssistDataRequester(Context context, IActivityManager service,
        IWindowManager windowManager, AppOpsManager appOpsManager,
        AssistDataRequesterCallbacks callbacks, Object callbacksLock,
        int requestStructureAppOps, int requestScreenshotAppOps) {
    mCallbacks = callbacks;
    mCallbacksLock = callbacksLock;
    mWindowManager = windowManager;
    mService = service;
    mContext = context;
    mAppOpsManager = appOpsManager;
    mRequestStructureAppOps = requestStructureAppOps;
    mRequestScreenshotAppOps = requestScreenshotAppOps;
}
 
源代码10 项目: android_9.0.0_r45   文件: Instrumentation.java
/**
 * Force the global system in or out of touch mode.  This can be used if
 * your instrumentation relies on the UI being in one more or the other
 * when it starts.
 * 
 * @param inTouch Set to true to be in touch mode, false to be in
 * focus mode.
 */
public void setInTouchMode(boolean inTouch) {
    try {
        IWindowManager.Stub.asInterface(
                ServiceManager.getService("window")).setInTouchMode(inTouch);
    } catch (RemoteException e) {
        // Shouldn't happen!
    }
}
 
源代码11 项目: FunnyDraw   文件: Main.java
private static void calculateCanvas() throws Exception {
    Method getServiceMethod = Class.forName("android.os.ServiceManager").
            getDeclaredMethod("getService", String.class);
    Point displaySize = new Point();
    IWindowManager wm = IWindowManager.Stub.asInterface((IBinder)
            getServiceMethod.invoke(null, Context.WINDOW_SERVICE));
    wm.getBaseDisplaySize(0, displaySize);
    Rect canvasRect = new Rect(100, 400, displaySize.x - 100, displaySize.y);
    Canvas canvas = new Canvas(canvasRect.width(), canvasRect.height(), canvasRect.centerX(),
            canvasRect.centerY());
    SampleManager.get().setCanvas(canvas);
}
 
源代码12 项目: droidel   文件: Instrumentation.java
/**
 * Force the global system in or out of touch mode.  This can be used if
 * your instrumentation relies on the UI being in one more or the other
 * when it starts.
 * 
 * @param inTouch Set to true to be in touch mode, false to be in
 * focus mode.
 */
public void setInTouchMode(boolean inTouch) {
    try {
        IWindowManager.Stub.asInterface(
                ServiceManager.getService("window")).setInTouchMode(inTouch);
    } catch (RemoteException e) {
        // Shouldn't happen!
    }
}
 
源代码13 项目: android_9.0.0_r45   文件: StrictMode.java
protected IWindowManager create() {
    return IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
}
 
源代码14 项目: android-inputinjector   文件: InjectionManager.java
public InjectionManager(Context c)
{
	if(Integer.valueOf(android.os.Build.VERSION.SDK_INT) < android.os.Build.VERSION_CODES.JELLY_BEAN)
	{
		mWmbinder = ServiceManager.getService( INTERNAL_SERVICE_PRE_JELLY );
		mWinMan = IWindowManager.Stub.asInterface( mWmbinder );
		
		printDeclaredMethods(mWinMan.getClass());
		
		//TODO: Implement full injection support for pre Jelly Bean solutions
	}
	else
	{
		mInputManager = c.getSystemService(Context.INPUT_SERVICE);
		
		try
		{
			//printDeclaredMethods(mInputManager.getClass());
			
			//Unveil hidden methods
			mInjectEventMethod = mInputManager.getClass().getDeclaredMethod("injectInputEvent", new Class[] { InputEvent.class, Integer.TYPE });
			mInjectEventMethod.setAccessible(true);
			Field eventAsync = mInputManager.getClass().getDeclaredField("INJECT_INPUT_EVENT_MODE_ASYNC");
			Field eventResult = mInputManager.getClass().getDeclaredField("INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT");
			Field eventFinish = mInputManager.getClass().getDeclaredField("INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH");
			eventAsync.setAccessible(true);
			eventResult.setAccessible(true);
			eventFinish.setAccessible(true);
			INJECT_INPUT_EVENT_MODE_ASYNC = eventAsync.getInt(mInputManager.getClass());
			INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT = eventResult.getInt(mInputManager.getClass());
			INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = eventFinish.getInt(mInputManager.getClass());
		}
		catch (NoSuchMethodException nsme)
		{
			Log.e(TAG,  "Critical methods not available");
		}
		catch (NoSuchFieldException nsfe)
		{
			Log.e(TAG,  "Critical fields not available");
		}
		catch (IllegalAccessException iae)
		{
			Log.e(TAG,  "Critical fields not accessable");
		}
	}
}
 
源代码15 项目: AndroidComponentPlugin   文件: Instrumentation.java
/**
 * Send a key event to the currently focused window/view and wait for it to
 * be processed.  Finished at some point after the recipient has returned
 * from its event processing, though it may <em>not</em> have completely
 * finished reacting from the event -- for example, if it needs to update
 * its display as a result, it may still be in the process of doing that.
 * 
 * @param event The event to send to the current focus.
 */
public void sendKeySync(KeyEvent event) {
    validateNotAppThread();
    try {
        (IWindowManager.Stub.asInterface(ServiceManager.getService("window")))
            .injectKeyEvent(event, true);
    } catch (RemoteException e) {
    }
}
 
源代码16 项目: AndroidComponentPlugin   文件: Instrumentation.java
/**
 * Dispatch a pointer event. Finished at some point after the recipient has
 * returned from its event processing, though it may <em>not</em> have
 * completely finished reacting from the event -- for example, if it needs
 * to update its display as a result, it may still be in the process of
 * doing that.
 * 
 * @param event A motion event describing the pointer action.  (As noted in 
 * {@link MotionEvent#obtain(long, long, int, float, float, int)}, be sure to use 
 * {@link SystemClock#uptimeMillis()} as the timebase.
 */
public void sendPointerSync(MotionEvent event) {
    validateNotAppThread();
    try {
        (IWindowManager.Stub.asInterface(ServiceManager.getService("window")))
            .injectPointerEvent(event, true);
    } catch (RemoteException e) {
    }
}
 
源代码17 项目: AndroidComponentPlugin   文件: Instrumentation.java
/**
 * Dispatch a trackball event. Finished at some point after the recipient has
 * returned from its event processing, though it may <em>not</em> have
 * completely finished reacting from the event -- for example, if it needs
 * to update its display as a result, it may still be in the process of
 * doing that.
 * 
 * @param event A motion event describing the trackball action.  (As noted in 
 * {@link MotionEvent#obtain(long, long, int, float, float, int)}, be sure to use 
 * {@link SystemClock#uptimeMillis()} as the timebase.
 */
public void sendTrackballEventSync(MotionEvent event) {
    validateNotAppThread();
    try {
        (IWindowManager.Stub.asInterface(ServiceManager.getService("window")))
            .injectTrackballEvent(event, true);
    } catch (RemoteException e) {
    }
}
 
源代码18 项目: android_9.0.0_r45   文件: WindowManagerPolicy.java
/**
 * Perform initialization of the policy.
 *
 * @param context The system context we are running in.
 */
public void init(Context context, IWindowManager windowManager,
        WindowManagerFuncs windowManagerFuncs);
 
 类所在包
 同包方法