Search in sources :

Example 91 with Message

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

the class MobileDataStateTracker method setDetailedState.

/**
     * Record the detailed state of a network, and if it is a
     * change from the previous state, send a notification to
     * any listeners.
     * @param state the new {@code DetailedState}
     * @param reason a {@code String} indicating a reason for the state change,
     * if one was supplied. May be {@code null}.
     * @param extraInfo optional {@code String} providing extra information about the state change
     */
private void setDetailedState(NetworkInfo.DetailedState state, String reason, String extraInfo) {
    if (DBG)
        log("setDetailed state, old =" + mNetworkInfo.getDetailedState() + " and new state=" + state);
    if (state != mNetworkInfo.getDetailedState()) {
        boolean wasConnecting = (mNetworkInfo.getState() == NetworkInfo.State.CONNECTING);
        String lastReason = mNetworkInfo.getReason();
        /*
             * If a reason was supplied when the CONNECTING state was entered, and no
             * reason was supplied for entering the CONNECTED state, then retain the
             * reason that was supplied when going to CONNECTING.
             */
        if (wasConnecting && state == NetworkInfo.DetailedState.CONNECTED && reason == null && lastReason != null)
            reason = lastReason;
        mNetworkInfo.setDetailedState(state, reason, extraInfo);
        Message msg = mTarget.obtainMessage(EVENT_STATE_CHANGED, new NetworkInfo(mNetworkInfo));
        msg.sendToTarget();
    }
}
Also used : Message(android.os.Message)

Example 92 with Message

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

the class GeofenceHardwareImpl method registerForMonitorStateChangeCallback.

public boolean registerForMonitorStateChangeCallback(int monitoringType, IGeofenceHardwareMonitorCallback callback) {
    Message reaperMessage = mReaperHandler.obtainMessage(REAPER_MONITOR_CALLBACK_ADDED, callback);
    reaperMessage.arg1 = monitoringType;
    mReaperHandler.sendMessage(reaperMessage);
    Message m = mCallbacksHandler.obtainMessage(CALLBACK_ADD, callback);
    m.arg1 = monitoringType;
    mCallbacksHandler.sendMessage(m);
    return true;
}
Also used : Message(android.os.Message)

Example 93 with Message

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

the class GeofenceHardwareImpl method addCircularFence.

public boolean addCircularFence(int geofenceId, int monitoringType, double latitude, double longitude, double radius, int lastTransition, int monitorTransitions, int notificationResponsivenes, int unknownTimer, IGeofenceHardwareCallback callback) {
    // by upper layers
    if (DEBUG) {
        Log.d(TAG, "addCircularFence: GeofenceId: " + geofenceId + " Latitude: " + latitude + " Longitude: " + longitude + " Radius: " + radius + " LastTransition: " + lastTransition + " MonitorTransition: " + monitorTransitions + " NotificationResponsiveness: " + notificationResponsivenes + " UnKnown Timer: " + unknownTimer + " MonitoringType: " + monitoringType);
    }
    boolean result;
    // operations is not called or fails.
    synchronized (mGeofences) {
        mGeofences.put(geofenceId, callback);
    }
    switch(monitoringType) {
        case GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE:
            if (mGpsService == null)
                return false;
            try {
                result = mGpsService.addCircularHardwareGeofence(geofenceId, latitude, longitude, radius, lastTransition, monitorTransitions, notificationResponsivenes, unknownTimer);
            } catch (RemoteException e) {
                Log.e(TAG, "AddGeofence: Remote Exception calling LocationManagerService");
                result = false;
            }
            break;
        default:
            result = false;
    }
    if (result) {
        Message m = mReaperHandler.obtainMessage(REAPER_GEOFENCE_ADDED, callback);
        m.arg1 = monitoringType;
        mReaperHandler.sendMessage(m);
    } else {
        synchronized (mGeofences) {
            mGeofences.remove(geofenceId);
        }
    }
    if (DEBUG)
        Log.d(TAG, "addCircularFence: Result is: " + result);
    return result;
}
Also used : Message(android.os.Message) RemoteException(android.os.RemoteException)

Example 94 with Message

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

the class GeofenceHardwareImpl method reportGpsGeofenceStatus.

/**
     * called from GpsLocationProvider to report GPS status change.
     */
public void reportGpsGeofenceStatus(int status, int flags, double latitude, double longitude, double altitude, float speed, float bearing, float accuracy, long timestamp) {
    Location location = getLocation(flags, latitude, longitude, altitude, speed, bearing, accuracy, timestamp);
    boolean available = false;
    if (status == GeofenceHardware.GPS_GEOFENCE_AVAILABLE)
        available = true;
    int val = (available ? GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE : GeofenceHardware.MONITOR_CURRENTLY_UNAVAILABLE);
    setMonitorAvailability(GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE, val);
    acquireWakeLock();
    Message m = mCallbacksHandler.obtainMessage(GPS_GEOFENCE_STATUS, location);
    m.arg1 = val;
    mCallbacksHandler.sendMessage(m);
}
Also used : Message(android.os.Message) Location(android.location.Location)

Example 95 with Message

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

the class Registrant method internalNotifyRegistrant.

/*package*/
void internalNotifyRegistrant(Object result, Throwable exception) {
    Handler h = getHandler();
    if (h == null) {
        clear();
    } else {
        Message msg = Message.obtain();
        msg.what = what;
        msg.obj = new AsyncResult(userObj, result, exception);
        h.sendMessage(msg);
    }
}
Also used : Message(android.os.Message) Handler(android.os.Handler)

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