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