Search in sources :

Example 1 with ShowUserToastEvent

use of com.android.systemui.recents.events.component.ShowUserToastEvent in project platform_frameworks_base by android.

the class Recents method dockTopTask.

@Override
public boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds, int metricsDockAction) {
    // recents
    if (!isUserSetup()) {
        return false;
    }
    Point realSize = new Point();
    if (initialBounds == null) {
        mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getRealSize(realSize);
        initialBounds = new Rect(0, 0, realSize.x, realSize.y);
    }
    int currentUser = sSystemServicesProxy.getCurrentUser();
    SystemServicesProxy ssp = Recents.getSystemServices();
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    boolean screenPinningActive = ssp.isScreenPinningActive();
    boolean isRunningTaskInHomeStack = runningTask != null && SystemServicesProxy.isHomeStack(runningTask.stackId);
    if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) {
        logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode);
        if (runningTask.isDockable) {
            if (metricsDockAction != -1) {
                MetricsLogger.action(mContext, metricsDockAction, runningTask.topActivity.flattenToShortString());
            }
            if (sSystemServicesProxy.isSystemUser(currentUser)) {
                mImpl.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
            } else {
                if (mSystemToUserCallbacks != null) {
                    IRecentsNonSystemUserCallbacks callbacks = mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
                    if (callbacks != null) {
                        try {
                            callbacks.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Callback failed", e);
                        }
                    } else {
                        Log.e(TAG, "No SystemUI callbacks found for user: " + currentUser);
                    }
                }
            }
            mDraggingInRecentsCurrentUser = currentUser;
            return true;
        } else {
            EventBus.getDefault().send(new ShowUserToastEvent(R.string.recents_incompatible_app_message, Toast.LENGTH_SHORT));
            return false;
        }
    } else {
        return false;
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) ShowUserToastEvent(com.android.systemui.recents.events.component.ShowUserToastEvent) Point(android.graphics.Point) ActivityManager(android.app.ActivityManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 2 with ShowUserToastEvent

use of com.android.systemui.recents.events.component.ShowUserToastEvent in project android_frameworks_base by ResurrectionRemix.

the class Recents method dockTopTask.

@Override
public boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds, int metricsDockAction) {
    // recents
    if (!isUserSetup()) {
        return false;
    }
    Point realSize = new Point();
    if (initialBounds == null) {
        mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getRealSize(realSize);
        initialBounds = new Rect(0, 0, realSize.x, realSize.y);
    }
    int currentUser = sSystemServicesProxy.getCurrentUser();
    SystemServicesProxy ssp = Recents.getSystemServices();
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    boolean screenPinningActive = ssp.isScreenPinningActive();
    boolean isRunningTaskInHomeStack = runningTask != null && SystemServicesProxy.isHomeStack(runningTask.stackId);
    if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) {
        logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode);
        if (runningTask.isDockable) {
            if (metricsDockAction != -1) {
                MetricsLogger.action(mContext, metricsDockAction, runningTask.topActivity.flattenToShortString());
            }
            if (sSystemServicesProxy.isSystemUser(currentUser)) {
                mImpl.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
            } else {
                if (mSystemToUserCallbacks != null) {
                    IRecentsNonSystemUserCallbacks callbacks = mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
                    if (callbacks != null) {
                        try {
                            callbacks.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Callback failed", e);
                        }
                    } else {
                        Log.e(TAG, "No SystemUI callbacks found for user: " + currentUser);
                    }
                }
            }
            mDraggingInRecentsCurrentUser = currentUser;
            return true;
        } else {
            EventBus.getDefault().send(new ShowUserToastEvent(R.string.recents_incompatible_app_message, Toast.LENGTH_SHORT));
            return false;
        }
    } else {
        return false;
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) ShowUserToastEvent(com.android.systemui.recents.events.component.ShowUserToastEvent) Point(android.graphics.Point) ActivityManager(android.app.ActivityManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 3 with ShowUserToastEvent

use of com.android.systemui.recents.events.component.ShowUserToastEvent in project android_frameworks_base by DirtyUnicorns.

the class Recents method dockTopTask.

@Override
public boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds, int metricsDockAction) {
    // recents
    if (!isUserSetup()) {
        return false;
    }
    Point realSize = new Point();
    if (initialBounds == null) {
        mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getRealSize(realSize);
        initialBounds = new Rect(0, 0, realSize.x, realSize.y);
    }
    int currentUser = sSystemServicesProxy.getCurrentUser();
    SystemServicesProxy ssp = Recents.getSystemServices();
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    boolean screenPinningActive = ssp.isScreenPinningActive();
    boolean isRunningTaskInHomeStack = runningTask != null && SystemServicesProxy.isHomeStack(runningTask.stackId);
    if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) {
        logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode);
        if (runningTask.isDockable) {
            if (metricsDockAction != -1) {
                MetricsLogger.action(mContext, metricsDockAction, runningTask.topActivity.flattenToShortString());
            }
            if (sSystemServicesProxy.isSystemUser(currentUser)) {
                mImpl.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
            } else {
                if (mSystemToUserCallbacks != null) {
                    IRecentsNonSystemUserCallbacks callbacks = mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
                    if (callbacks != null) {
                        try {
                            callbacks.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Callback failed", e);
                        }
                    } else {
                        Log.e(TAG, "No SystemUI callbacks found for user: " + currentUser);
                    }
                }
            }
            mDraggingInRecentsCurrentUser = currentUser;
            return true;
        } else {
            EventBus.getDefault().send(new ShowUserToastEvent(R.string.recents_incompatible_app_message, Toast.LENGTH_SHORT));
            return false;
        }
    } else {
        return false;
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) ShowUserToastEvent(com.android.systemui.recents.events.component.ShowUserToastEvent) Point(android.graphics.Point) ActivityManager(android.app.ActivityManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 4 with ShowUserToastEvent

use of com.android.systemui.recents.events.component.ShowUserToastEvent in project android_frameworks_base by AOSPA.

the class Recents method dockTopTask.

@Override
public boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds, int metricsDockAction) {
    // recents
    if (!isUserSetup()) {
        return false;
    }
    Point realSize = new Point();
    if (initialBounds == null) {
        mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getRealSize(realSize);
        initialBounds = new Rect(0, 0, realSize.x, realSize.y);
    }
    int currentUser = sSystemServicesProxy.getCurrentUser();
    SystemServicesProxy ssp = Recents.getSystemServices();
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    boolean screenPinningActive = ssp.isScreenPinningActive();
    boolean isRunningTaskInHomeStack = runningTask != null && SystemServicesProxy.isHomeStack(runningTask.stackId);
    if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) {
        logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode);
        if (runningTask.isDockable) {
            if (metricsDockAction != -1) {
                MetricsLogger.action(mContext, metricsDockAction, runningTask.topActivity.flattenToShortString());
            }
            if (sSystemServicesProxy.isSystemUser(currentUser)) {
                mImpl.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
            } else {
                if (mSystemToUserCallbacks != null) {
                    IRecentsNonSystemUserCallbacks callbacks = mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
                    if (callbacks != null) {
                        try {
                            callbacks.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Callback failed", e);
                        }
                    } else {
                        Log.e(TAG, "No SystemUI callbacks found for user: " + currentUser);
                    }
                }
            }
            mDraggingInRecentsCurrentUser = currentUser;
            return true;
        } else {
            EventBus.getDefault().send(new ShowUserToastEvent(R.string.recents_incompatible_app_message, Toast.LENGTH_SHORT));
            return false;
        }
    } else {
        return false;
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) ShowUserToastEvent(com.android.systemui.recents.events.component.ShowUserToastEvent) Point(android.graphics.Point) ActivityManager(android.app.ActivityManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 5 with ShowUserToastEvent

use of com.android.systemui.recents.events.component.ShowUserToastEvent in project android_frameworks_base by crdroidandroid.

the class Recents method dockTopTask.

@Override
public boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds, int metricsDockAction) {
    // recents
    if (!isUserSetup()) {
        return false;
    }
    Point realSize = new Point();
    if (initialBounds == null) {
        mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getRealSize(realSize);
        initialBounds = new Rect(0, 0, realSize.x, realSize.y);
    }
    int currentUser = sSystemServicesProxy.getCurrentUser();
    SystemServicesProxy ssp = Recents.getSystemServices();
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    boolean screenPinningActive = ssp.isScreenPinningActive();
    boolean isRunningTaskInHomeStack = runningTask != null && SystemServicesProxy.isHomeStack(runningTask.stackId);
    if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) {
        logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode);
        if (runningTask.isDockable) {
            if (metricsDockAction != -1) {
                MetricsLogger.action(mContext, metricsDockAction, runningTask.topActivity.flattenToShortString());
            }
            if (sSystemServicesProxy.isSystemUser(currentUser)) {
                mImpl.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
            } else {
                if (mSystemToUserCallbacks != null) {
                    IRecentsNonSystemUserCallbacks callbacks = mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
                    if (callbacks != null) {
                        try {
                            callbacks.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Callback failed", e);
                        }
                    } else {
                        Log.e(TAG, "No SystemUI callbacks found for user: " + currentUser);
                    }
                }
            }
            mDraggingInRecentsCurrentUser = currentUser;
            return true;
        } else {
            EventBus.getDefault().send(new ShowUserToastEvent(R.string.recents_incompatible_app_message, Toast.LENGTH_SHORT));
            return false;
        }
    } else {
        return false;
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) ShowUserToastEvent(com.android.systemui.recents.events.component.ShowUserToastEvent) Point(android.graphics.Point) ActivityManager(android.app.ActivityManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Aggregations

ActivityManager (android.app.ActivityManager)5 Point (android.graphics.Point)5 Rect (android.graphics.Rect)5 RemoteException (android.os.RemoteException)5 ShowUserToastEvent (com.android.systemui.recents.events.component.ShowUserToastEvent)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5