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);
}
}
}
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
}
}
}
}
}
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);
}
}
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);
}
}
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;
}
Aggregations