Search in sources :

Example 51 with Message

use of android.os.Message in project android_frameworks_base by ParanoidAndroid.

the class DisplayPowerController method debounceProximitySensor.

private void debounceProximitySensor() {
    if (mPendingProximity != PROXIMITY_UNKNOWN) {
        final long now = SystemClock.uptimeMillis();
        if (mPendingProximityDebounceTime <= now) {
            mProximity = mPendingProximity;
            sendUpdatePowerState();
        } else {
            Message msg = mHandler.obtainMessage(MSG_PROXIMITY_SENSOR_DEBOUNCED);
            msg.setAsynchronous(true);
            mHandler.sendMessageAtTime(msg, mPendingProximityDebounceTime);
        }
    }
}
Also used : Message(android.os.Message)

Example 52 with Message

use of android.os.Message in project android_frameworks_base by ParanoidAndroid.

the class WifiTrafficPoller method notifyOnDataActivity.

private void notifyOnDataActivity() {
    long sent, received;
    long preTxPkts = mTxPkts, preRxPkts = mRxPkts;
    int dataActivity = WifiManager.DATA_ACTIVITY_NONE;
    mTxPkts = TrafficStats.getTxPackets(mInterface);
    mRxPkts = TrafficStats.getRxPackets(mInterface);
    if (preTxPkts > 0 || preRxPkts > 0) {
        sent = mTxPkts - preTxPkts;
        received = mRxPkts - preRxPkts;
        if (sent > 0) {
            dataActivity |= WifiManager.DATA_ACTIVITY_OUT;
        }
        if (received > 0) {
            dataActivity |= WifiManager.DATA_ACTIVITY_IN;
        }
        if (dataActivity != mDataActivity && mScreenOn.get()) {
            mDataActivity = dataActivity;
            for (Messenger client : mClients) {
                Message msg = Message.obtain();
                msg.what = WifiManager.DATA_ACTIVITY_NOTIFICATION;
                msg.arg1 = mDataActivity;
                try {
                    client.send(msg);
                } catch (RemoteException e) {
                // Failed to reach, skip
                // Client removal is handled in WifiService
                }
            }
        }
    }
}
Also used : Message(android.os.Message) Messenger(android.os.Messenger) RemoteException(android.os.RemoteException)

Example 53 with Message

use of android.os.Message in project android_frameworks_base by ParanoidAndroid.

the class AppWindowToken method updateReportedVisibilityLocked.

void updateReportedVisibilityLocked() {
    if (appToken == null) {
        return;
    }
    int numInteresting = 0;
    int numVisible = 0;
    int numDrawn = 0;
    boolean nowGone = true;
    if (WindowManagerService.DEBUG_VISIBILITY)
        Slog.v(WindowManagerService.TAG, "Update reported visibility: " + this);
    final int N = allAppWindows.size();
    for (int i = 0; i < N; i++) {
        WindowState win = allAppWindows.get(i);
        if (win == startingWindow || win.mAppFreezing || win.mViewVisibility != View.VISIBLE || win.mAttrs.type == TYPE_APPLICATION_STARTING || win.mDestroying) {
            continue;
        }
        if (WindowManagerService.DEBUG_VISIBILITY) {
            Slog.v(WindowManagerService.TAG, "Win " + win + ": isDrawn=" + win.isDrawnLw() + ", isAnimating=" + win.mWinAnimator.isAnimating());
            if (!win.isDrawnLw()) {
                Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mWinAnimator.mSurfaceControl + " pv=" + win.mPolicyVisibility + " mDrawState=" + win.mWinAnimator.mDrawState + " ah=" + win.mAttachedHidden + " th=" + (win.mAppToken != null ? win.mAppToken.hiddenRequested : false) + " a=" + win.mWinAnimator.mAnimating);
            }
        }
        numInteresting++;
        if (win.isDrawnLw()) {
            numDrawn++;
            if (!win.mWinAnimator.isAnimating()) {
                numVisible++;
            }
            nowGone = false;
        } else if (win.mWinAnimator.isAnimating()) {
            nowGone = false;
        }
    }
    boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
    boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
    if (!nowGone) {
        // If the app is not yet gone, then it can only become visible/drawn.
        if (!nowDrawn) {
            nowDrawn = reportedDrawn;
        }
        if (!nowVisible) {
            nowVisible = reportedVisible;
        }
    }
    if (WindowManagerService.DEBUG_VISIBILITY)
        Slog.v(WindowManagerService.TAG, "VIS " + this + ": interesting=" + numInteresting + " visible=" + numVisible);
    if (nowDrawn != reportedDrawn) {
        if (nowDrawn) {
            Message m = service.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_DRAWN, this);
            service.mH.sendMessage(m);
        }
        reportedDrawn = nowDrawn;
    }
    if (nowVisible != reportedVisible) {
        if (WindowManagerService.DEBUG_VISIBILITY)
            Slog.v(WindowManagerService.TAG, "Visibility changed in " + this + ": vis=" + nowVisible);
        reportedVisible = nowVisible;
        Message m = service.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_WINDOWS, nowVisible ? 1 : 0, nowGone ? 1 : 0, this);
        service.mH.sendMessage(m);
    }
}
Also used : Message(android.os.Message)

Example 54 with Message

use of android.os.Message in project android_frameworks_base by ParanoidAndroid.

the class Notifier method updatePendingBroadcastLocked.

private void updatePendingBroadcastLocked() {
    if (!mBroadcastInProgress && mActualPowerState != POWER_STATE_UNKNOWN && (mPendingWakeUpBroadcast || mPendingGoToSleepBroadcast || mActualPowerState != mBroadcastedPowerState)) {
        mBroadcastInProgress = true;
        mSuspendBlocker.acquire();
        Message msg = mHandler.obtainMessage(MSG_BROADCAST);
        msg.setAsynchronous(true);
        mHandler.sendMessage(msg);
    }
}
Also used : Message(android.os.Message)

Example 55 with Message

use of android.os.Message in project android_frameworks_base by ParanoidAndroid.

the class DragState method notifyDropLw.

// Tell the drop target about the data.  Returns 'true' if we can immediately
// dispatch the global drag-ended message, 'false' if we need to wait for a
// result from the recipient.
boolean notifyDropLw(float x, float y) {
    WindowState touchedWin = getTouchedWinAtPointLw(x, y);
    if (touchedWin == null) {
        // "drop" outside a valid window -- no recipient to apply a
        // timeout to, and we can send the drag-ended message immediately.
        mDragResult = false;
        return true;
    }
    if (WindowManagerService.DEBUG_DRAG) {
        Slog.d(WindowManagerService.TAG, "sending DROP to " + touchedWin);
    }
    final int myPid = Process.myPid();
    final IBinder token = touchedWin.mClient.asBinder();
    DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DROP, x, y, null, null, mData, false);
    try {
        touchedWin.mClient.dispatchDragEvent(evt);
        // 5 second timeout for this window to respond to the drop
        mService.mH.removeMessages(H.DRAG_END_TIMEOUT, token);
        Message msg = mService.mH.obtainMessage(H.DRAG_END_TIMEOUT, token);
        mService.mH.sendMessageDelayed(msg, 5000);
    } catch (RemoteException e) {
        Slog.w(WindowManagerService.TAG, "can't send drop notification to win " + touchedWin);
        return true;
    } finally {
        if (myPid != touchedWin.mSession.mPid) {
            evt.recycle();
        }
    }
    mToken = token;
    return false;
}
Also used : DragEvent(android.view.DragEvent) IBinder(android.os.IBinder) Message(android.os.Message) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Aggregations

Message (android.os.Message)3198 Handler (android.os.Handler)347 RemoteException (android.os.RemoteException)263 Bundle (android.os.Bundle)210 Test (org.junit.Test)144 Intent (android.content.Intent)130 IOException (java.io.IOException)124 Point (android.graphics.Point)86 HashMap (java.util.HashMap)77 SomeArgs (com.android.internal.os.SomeArgs)67 SmallTest (android.test.suitebuilder.annotation.SmallTest)64 Messenger (android.os.Messenger)63 ArrayList (java.util.ArrayList)59 View (android.view.View)52 File (java.io.File)50 MediumTest (android.test.suitebuilder.annotation.MediumTest)43 TextView (android.widget.TextView)41 IBinder (android.os.IBinder)38 Map (java.util.Map)37 PendingIntent (android.app.PendingIntent)33