Search in sources :

Example 26 with MutableBoolean

use of android.util.MutableBoolean in project android_frameworks_base by AOSPA.

the class RecentsImpl method toggleRecents.

public void toggleRecents(int growTarget) {
    // Skip this toggle if we are already waiting to trigger recents via alt-tab
    if (mFastAltTabTrigger.isDozing()) {
        return;
    }
    mDraggingInRecents = false;
    mLaunchedWhileDocking = false;
    mTriggeredFromAltTab = false;
    try {
        SystemServicesProxy ssp = Recents.getSystemServices();
        MutableBoolean isHomeStackVisible = new MutableBoolean(true);
        long elapsedTime = SystemClock.elapsedRealtime() - mLastToggleTime;
        if (ssp.isRecentsActivityVisible(isHomeStackVisible)) {
            RecentsDebugFlags debugFlags = Recents.getDebugFlags();
            RecentsConfiguration config = Recents.getConfiguration();
            RecentsActivityLaunchState launchState = config.getLaunchState();
            if (!launchState.launchedWithAltTab) {
                // Has the user tapped quickly?
                boolean isQuickTap = ViewConfiguration.getDoubleTapMinTime() < elapsedTime && elapsedTime < ViewConfiguration.getDoubleTapTimeout();
                if (Recents.getConfiguration().isGridEnabled) {
                    if (isQuickTap) {
                        EventBus.getDefault().post(new LaunchNextTaskRequestEvent());
                    } else {
                        EventBus.getDefault().post(new LaunchMostRecentTaskRequestEvent());
                    }
                } else {
                    if (!debugFlags.isPagingEnabled() || isQuickTap) {
                        // Launch the next focused task
                        EventBus.getDefault().post(new LaunchNextTaskRequestEvent());
                    } else {
                        // Notify recents to move onto the next task
                        EventBus.getDefault().post(new IterateRecentsEvent());
                    }
                }
            } else {
                // account
                if (elapsedTime < MIN_TOGGLE_DELAY_MS) {
                    return;
                }
                EventBus.getDefault().post(new ToggleRecentsEvent());
                mLastToggleTime = SystemClock.elapsedRealtime();
            }
            return;
        } else {
            // account
            if (elapsedTime < MIN_TOGGLE_DELAY_MS) {
                return;
            }
            // Otherwise, start the recents activity
            ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
            startRecentsActivity(runningTask, isHomeStackVisible.value, true, /* animate */
            growTarget);
            // Only close the other system windows if we are actually showing recents
            ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
            mLastToggleTime = SystemClock.elapsedRealtime();
        }
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch RecentsActivity", e);
    }
}
Also used : IterateRecentsEvent(com.android.systemui.recents.events.activity.IterateRecentsEvent) MutableBoolean(android.util.MutableBoolean) ToggleRecentsEvent(com.android.systemui.recents.events.activity.ToggleRecentsEvent) ActivityManager(android.app.ActivityManager) SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) LaunchNextTaskRequestEvent(com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent) ActivityNotFoundException(android.content.ActivityNotFoundException) LaunchMostRecentTaskRequestEvent(com.android.systemui.recents.events.activity.LaunchMostRecentTaskRequestEvent)

Example 27 with MutableBoolean

use of android.util.MutableBoolean in project android_frameworks_base by AOSPA.

the class TaskStackViewTouchHandler method onBeginDrag.

@Override
public void onBeginDrag(View v) {
    TaskView tv = (TaskView) v;
    // Disable clipping with the stack while we are swiping
    tv.setClipViewInStack(false);
    // Disallow touch events from this task view
    tv.setTouchEnabled(false);
    // Disallow parents from intercepting touch events
    final ViewParent parent = mSv.getParent();
    if (parent != null) {
        parent.requestDisallowInterceptTouchEvent(true);
    }
    // Add this task to the set of tasks we are deleting
    mSv.addIgnoreTask(tv.getTask());
    // Determine if we are animating the other tasks while dismissing this task
    mCurrentTasks = new ArrayList<Task>(mSv.getStack().getStackTasks());
    MutableBoolean isFrontMostTask = new MutableBoolean(false);
    Task anchorTask = mSv.findAnchorTask(mCurrentTasks, isFrontMostTask);
    TaskStackLayoutAlgorithm layoutAlgorithm = mSv.getStackAlgorithm();
    TaskStackViewScroller stackScroller = mSv.getScroller();
    if (anchorTask != null) {
        // Get the current set of task transforms
        mSv.getCurrentTaskTransforms(mCurrentTasks, mCurrentTaskTransforms);
        // Get the stack scroll of the task to anchor to (since we are removing something, the
        // front most task will be our anchor task)
        float prevAnchorTaskScroll = 0;
        boolean pullStackForward = mCurrentTasks.size() > 0;
        if (pullStackForward) {
            prevAnchorTaskScroll = layoutAlgorithm.getStackScrollForTask(anchorTask);
        }
        // Calculate where the views would be without the deleting tasks
        mSv.updateLayoutAlgorithm(false);
        float newStackScroll = stackScroller.getStackScroll();
        if (isFrontMostTask.value) {
            // Bound the stack scroll to pull tasks forward if necessary
            newStackScroll = stackScroller.getBoundedStackScroll(newStackScroll);
        } else if (pullStackForward) {
            // Otherwise, offset the scroll by the movement of the anchor task
            float anchorTaskScroll = layoutAlgorithm.getStackScrollForTaskIgnoreOverrides(anchorTask);
            float stackScrollOffset = (anchorTaskScroll - prevAnchorTaskScroll);
            if (layoutAlgorithm.getFocusState() != TaskStackLayoutAlgorithm.STATE_FOCUSED) {
                // If we are focused, we don't want the front task to move, but otherwise, we
                // allow the back task to move up, and the front task to move back
                stackScrollOffset *= 0.75f;
            }
            newStackScroll = stackScroller.getBoundedStackScroll(stackScroller.getStackScroll() + stackScrollOffset);
        }
        // Pick up the newly visible views, not including the deleting tasks
        mSv.bindVisibleTaskViews(newStackScroll, true);
        // Get the final set of task transforms (with task removed)
        mSv.getLayoutTaskTransforms(newStackScroll, TaskStackLayoutAlgorithm.STATE_UNFOCUSED, mCurrentTasks, true, /* ignoreTaskOverrides */
        mFinalTaskTransforms);
        // Set the target to scroll towards upon dismissal
        mTargetStackScroll = newStackScroll;
    /*
             * Post condition: All views that will be visible as a part of the gesture are retrieved
             *                 and at their initial positions.  The stack is still at the current
             *                 scroll, but the layout is updated without the task currently being
             *                 dismissed.  The final layout is in the unfocused stack state, which
             *                 will be applied when the current task is dismissed.
             */
    }
}
Also used : Task(com.android.systemui.recents.model.Task) ViewParent(android.view.ViewParent) MutableBoolean(android.util.MutableBoolean)

Example 28 with MutableBoolean

use of android.util.MutableBoolean in project android_frameworks_base by AOSPA.

the class BatteryStats method dumpCheckinLocked.

@SuppressWarnings("unused")
public void dumpCheckinLocked(Context context, PrintWriter pw, List<ApplicationInfo> apps, int flags, long histStart) {
    prepareForDumpLocked();
    dumpLine(pw, 0, /* uid */
    "i", /* category */
    VERSION_DATA, CHECKIN_VERSION, getParcelVersion(), getStartPlatformVersion(), getEndPlatformVersion());
    long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();
    final boolean filtering = (flags & (DUMP_HISTORY_ONLY | DUMP_CHARGED_ONLY | DUMP_DAILY_ONLY)) != 0;
    if ((flags & DUMP_INCLUDE_HISTORY) != 0 || (flags & DUMP_HISTORY_ONLY) != 0) {
        if (startIteratingHistoryLocked()) {
            try {
                for (int i = 0; i < getHistoryStringPoolSize(); i++) {
                    pw.print(BATTERY_STATS_CHECKIN_VERSION);
                    pw.print(',');
                    pw.print(HISTORY_STRING_POOL);
                    pw.print(',');
                    pw.print(i);
                    pw.print(",");
                    pw.print(getHistoryTagPoolUid(i));
                    pw.print(",\"");
                    String str = getHistoryTagPoolString(i);
                    str = str.replace("\\", "\\\\");
                    str = str.replace("\"", "\\\"");
                    pw.print(str);
                    pw.print("\"");
                    pw.println();
                }
                dumpHistoryLocked(pw, flags, histStart, true);
            } finally {
                finishIteratingHistoryLocked();
            }
        }
    }
    if (filtering && (flags & (DUMP_CHARGED_ONLY | DUMP_DAILY_ONLY)) == 0) {
        return;
    }
    if (apps != null) {
        SparseArray<Pair<ArrayList<String>, MutableBoolean>> uids = new SparseArray<>();
        for (int i = 0; i < apps.size(); i++) {
            ApplicationInfo ai = apps.get(i);
            Pair<ArrayList<String>, MutableBoolean> pkgs = uids.get(UserHandle.getAppId(ai.uid));
            if (pkgs == null) {
                pkgs = new Pair<>(new ArrayList<String>(), new MutableBoolean(false));
                uids.put(UserHandle.getAppId(ai.uid), pkgs);
            }
            pkgs.first.add(ai.packageName);
        }
        SparseArray<? extends Uid> uidStats = getUidStats();
        final int NU = uidStats.size();
        String[] lineArgs = new String[2];
        for (int i = 0; i < NU; i++) {
            int uid = UserHandle.getAppId(uidStats.keyAt(i));
            Pair<ArrayList<String>, MutableBoolean> pkgs = uids.get(uid);
            if (pkgs != null && !pkgs.second.value) {
                pkgs.second.value = true;
                for (int j = 0; j < pkgs.first.size(); j++) {
                    lineArgs[0] = Integer.toString(uid);
                    lineArgs[1] = pkgs.first.get(j);
                    dumpLine(pw, 0, /* uid */
                    "i", /* category */
                    UID_DATA, (Object[]) lineArgs);
                }
            }
        }
    }
    if (!filtering || (flags & DUMP_CHARGED_ONLY) != 0) {
        dumpDurationSteps(pw, "", DISCHARGE_STEP_DATA, getDischargeLevelStepTracker(), true);
        String[] lineArgs = new String[1];
        long timeRemaining = computeBatteryTimeRemaining(SystemClock.elapsedRealtime());
        if (timeRemaining >= 0) {
            lineArgs[0] = Long.toString(timeRemaining);
            dumpLine(pw, 0, /* uid */
            "i", /* category */
            DISCHARGE_TIME_REMAIN_DATA, (Object[]) lineArgs);
        }
        dumpDurationSteps(pw, "", CHARGE_STEP_DATA, getChargeLevelStepTracker(), true);
        timeRemaining = computeChargeTimeRemaining(SystemClock.elapsedRealtime());
        if (timeRemaining >= 0) {
            lineArgs[0] = Long.toString(timeRemaining);
            dumpLine(pw, 0, /* uid */
            "i", /* category */
            CHARGE_TIME_REMAIN_DATA, (Object[]) lineArgs);
        }
        dumpCheckinLocked(context, pw, STATS_SINCE_CHARGED, -1, (flags & DUMP_DEVICE_WIFI_ONLY) != 0);
    }
}
Also used : MutableBoolean(android.util.MutableBoolean) ApplicationInfo(android.content.pm.ApplicationInfo) ArrayList(java.util.ArrayList) SparseArray(android.util.SparseArray) LongSparseArray(android.util.LongSparseArray) Pair(android.util.Pair)

Example 29 with MutableBoolean

use of android.util.MutableBoolean in project robolectric by robolectric.

the class PreferenceIntegrationTest method click_shouldCallPreferenceClickListener.

@Test
public void click_shouldCallPreferenceClickListener() throws Exception {
    final PreferenceScreen screen = inflatePreferenceActivity();
    final Preference preference = screen.findPreference("preference");
    final MutableBoolean clicked = new MutableBoolean(false);
    preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            clicked.value = true;
            return true;
        }
    });
    shadowOf(preference).click();
    assertThat(clicked.value).isTrue();
}
Also used : MutableBoolean(android.util.MutableBoolean) Test(org.junit.Test)

Example 30 with MutableBoolean

use of android.util.MutableBoolean in project android_frameworks_base by ResurrectionRemix.

the class RecentsImpl method toggleRecents.

public void toggleRecents(int growTarget) {
    // Skip this toggle if we are already waiting to trigger recents via alt-tab
    if (mFastAltTabTrigger.isDozing()) {
        return;
    }
    mDraggingInRecents = false;
    mLaunchedWhileDocking = false;
    mTriggeredFromAltTab = false;
    try {
        SystemServicesProxy ssp = Recents.getSystemServices();
        MutableBoolean isHomeStackVisible = new MutableBoolean(true);
        long elapsedTime = SystemClock.elapsedRealtime() - mLastToggleTime;
        if (ssp.isRecentsActivityVisible(isHomeStackVisible)) {
            RecentsDebugFlags debugFlags = Recents.getDebugFlags();
            RecentsConfiguration config = Recents.getConfiguration();
            RecentsActivityLaunchState launchState = config.getLaunchState();
            if (!launchState.launchedWithAltTab) {
                // Has the user tapped quickly?
                boolean isQuickTap = ViewConfiguration.getDoubleTapMinTime() < elapsedTime && elapsedTime < ViewConfiguration.getDoubleTapTimeout();
                if (Recents.getConfiguration().isGridEnabled()) {
                    if (isQuickTap) {
                        EventBus.getDefault().post(new LaunchNextTaskRequestEvent());
                    } else {
                        EventBus.getDefault().post(new LaunchMostRecentTaskRequestEvent());
                    }
                } else {
                    if (!debugFlags.isPagingEnabled() || isQuickTap) {
                        // Launch the next focused task
                        EventBus.getDefault().post(new LaunchNextTaskRequestEvent());
                    } else {
                        // Notify recents to move onto the next task
                        EventBus.getDefault().post(new IterateRecentsEvent());
                    }
                }
            } else {
                // account
                if (elapsedTime < MIN_TOGGLE_DELAY_MS) {
                    return;
                }
                EventBus.getDefault().post(new ToggleRecentsEvent());
                mLastToggleTime = SystemClock.elapsedRealtime();
            }
            return;
        } else {
            // account
            if (elapsedTime < MIN_TOGGLE_DELAY_MS) {
                return;
            }
            // Otherwise, start the recents activity
            ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
            startRecentsActivity(runningTask, isHomeStackVisible.value, true, /* animate */
            growTarget);
            // Only close the other system windows if we are actually showing recents
            ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
            mLastToggleTime = SystemClock.elapsedRealtime();
        }
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch RecentsActivity", e);
    }
}
Also used : IterateRecentsEvent(com.android.systemui.recents.events.activity.IterateRecentsEvent) MutableBoolean(android.util.MutableBoolean) ToggleRecentsEvent(com.android.systemui.recents.events.activity.ToggleRecentsEvent) ActivityManager(android.app.ActivityManager) SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) LaunchNextTaskRequestEvent(com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent) ActivityNotFoundException(android.content.ActivityNotFoundException) LaunchMostRecentTaskRequestEvent(com.android.systemui.recents.events.activity.LaunchMostRecentTaskRequestEvent)

Aggregations

MutableBoolean (android.util.MutableBoolean)38 ActivityManager (android.app.ActivityManager)15 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 ActivityNotFoundException (android.content.ActivityNotFoundException)10 ApplicationInfo (android.content.pm.ApplicationInfo)5 LongSparseArray (android.util.LongSparseArray)5 Pair (android.util.Pair)5 SparseArray (android.util.SparseArray)5 ViewParent (android.view.ViewParent)5 IterateRecentsEvent (com.android.systemui.recents.events.activity.IterateRecentsEvent)5 LaunchNextTaskRequestEvent (com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent)5 ToggleRecentsEvent (com.android.systemui.recents.events.activity.ToggleRecentsEvent)5 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)5 Task (com.android.systemui.recents.model.Task)5 TaskStack (com.android.systemui.recents.model.TaskStack)5 Method (java.lang.reflect.Method)5 ArrayList (java.util.ArrayList)5 LaunchMostRecentTaskRequestEvent (com.android.systemui.recents.events.activity.LaunchMostRecentTaskRequestEvent)4 CursorWindow (android.database.CursorWindow)1 DbStats (android.database.sqlite.SQLiteDebug.DbStats)1