android.view.IWindowManager Java Examples

The following examples show how to use android.view.IWindowManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DisplayUtil.java    From DroidCast with Apache License 2.0 6 votes vote down vote up
@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();
    }
}
 
Example #2
Source File: LegacySensorManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
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) {
                }
            }
        }
    }
}
 
Example #3
Source File: Instrumentation.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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!
    }
}
 
Example #4
Source File: Instrumentation.java    From droidel with Apache License 2.0 5 votes vote down vote up
/**
 * 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!
    }
}
 
Example #5
Source File: Main.java    From FunnyDraw with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #6
Source File: Instrumentation.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * 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!
    }
}
 
Example #7
Source File: AssistDataRequester.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #8
Source File: ShortcutService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #9
Source File: WallpaperManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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<>();
}
 
Example #10
Source File: Instrumentation.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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!
    }
}
 
Example #11
Source File: Instrumentation.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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!
    }
}
 
Example #12
Source File: Instrumentation.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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!
    }
}
 
Example #13
Source File: StrictMode.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
protected IWindowManager create() {
    return IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
}
 
Example #14
Source File: InjectionManager.java    From android-inputinjector with GNU General Public License v2.0 4 votes vote down vote up
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");
		}
	}
}
 
Example #15
Source File: Instrumentation.java    From AndroidComponentPlugin with Apache License 2.0 3 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #16
Source File: Instrumentation.java    From AndroidComponentPlugin with Apache License 2.0 3 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #17
Source File: Instrumentation.java    From AndroidComponentPlugin with Apache License 2.0 3 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #18
Source File: WindowManagerPolicy.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Perform initialization of the policy.
 *
 * @param context The system context we are running in.
 */
public void init(Context context, IWindowManager windowManager,
        WindowManagerFuncs windowManagerFuncs);