use of android.os.Message in project Klyph by jonathangerbaud.
the class SetNotificationReadService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Message msg = mServiceHandler.obtainMessage();
if (intent != null) {
msg.obj = intent.getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);
mServiceHandler.sendMessage(msg);
stopSelf();
}
// If we get killed, after returning from here, restart
return START_STICKY;
}
use of android.os.Message in project Klyph by jonathangerbaud.
the class UploadPhotoService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
Message msg = mServiceHandler.obtainMessage();
Bundle bundle = new Bundle();
bundle.putStringArrayList(KlyphBundleExtras.UPLOAD_PHOTO_URIS, intent.getStringArrayListExtra(KlyphBundleExtras.UPLOAD_PHOTO_URIS));
bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_CAPTION, intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_CAPTION));
bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_PLACE, intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_PLACE));
bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_PRIVACY, intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_PRIVACY));
bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_ALBUM, intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_ALBUM));
bundle.putStringArrayList(KlyphBundleExtras.UPLOAD_PHOTO_TAGS, intent.getStringArrayListExtra(KlyphBundleExtras.UPLOAD_PHOTO_TAGS));
msg.setData(bundle);
mServiceHandler.sendMessage(msg);
}
// If we get killed, after returning from here, restart
return START_STICKY;
}
use of android.os.Message in project atlas by alibaba.
the class ActivityThreadHook method handleService.
private void handleService(final Message message) throws Exception {
Class ReceiverData = Class.forName("android.app.ActivityThread$CreateServiceData");
final Field info_field = ReceiverData.getDeclaredField("info");
info_field.setAccessible(true);
final ServiceInfo info = (ServiceInfo) info_field.get(message.obj);
String componentName = info.name;
String bundleName = AtlasBundleInfoManager.instance().getBundleForComponet(componentName);
if (!TextUtils.isEmpty(bundleName)) {
BundleImpl impl = (BundleImpl) Atlas.getInstance().getBundle(bundleName);
if (impl != null && impl.checkValidate()) {
mActivityThreadHandler.handleMessage(message);
if (sDelayServiceMessageList != null) {
sDelayServiceMessageList.remove(message);
}
executeDelayMsg();
} else {
if (sDelayServiceMessageList == null) {
sDelayServiceMessageList = new ArrayList<Message>();
sDelayServiceMessageList.add(Message.obtain(message));
}
BundleUtil.checkBundleStateAsync(bundleName, new Runnable() {
@Override
public void run() {
try {
executeDelayMsg();
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
}, null);
}
} else {
mActivityThreadHandler.handleMessage(message);
if (sDelayServiceMessageList != null) {
sDelayServiceMessageList.remove(message);
}
executeDelayMsg();
}
}
use of android.os.Message in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method takeScreenshot.
// Assume this is called from the Handler thread.
private void takeScreenshot() {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) {
return;
}
ComponentName cn = new ComponentName("com.android.systemui", "com.android.systemui.screenshot.TakeScreenshotService");
Intent intent = new Intent();
intent.setComponent(cn);
ServiceConnection conn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != this) {
return;
}
Messenger messenger = new Messenger(service);
Message msg = Message.obtain(null, 1);
final ServiceConnection myConn = this;
Handler h = new Handler(mHandler.getLooper()) {
@Override
public void handleMessage(Message msg) {
synchronized (mScreenshotLock) {
if (mScreenshotConnection == myConn) {
mContext.unbindService(mScreenshotConnection);
mScreenshotConnection = null;
mHandler.removeCallbacks(mScreenshotTimeout);
}
}
}
};
msg.replyTo = new Messenger(h);
msg.arg1 = msg.arg2 = 0;
if (mStatusBar != null && mStatusBar.isVisibleLw())
msg.arg1 = 1;
if (mNavigationBar != null && mNavigationBar.isVisibleLw())
msg.arg2 = 1;
try {
messenger.send(msg);
} catch (RemoteException e) {
}
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
};
if (mContext.bindServiceAsUser(intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) {
mScreenshotConnection = conn;
mHandler.postDelayed(mScreenshotTimeout, 10000);
}
}
}
use of android.os.Message in project android_frameworks_base by ParanoidAndroid.
the class KeyguardViewMediator method wakeWhenReady.
/**
* Send message to keyguard telling it about a wake key so it can adjust
* its state accordingly and then poke the wake lock when it is ready.
* @param keyCode The wake key.
* @see #handleWakeWhenReady
* @see #onWakeKeyWhenKeyguardShowingTq(int)
*/
private void wakeWhenReady(int keyCode) {
if (DBG_WAKE)
Log.d(TAG, "wakeWhenReady(" + keyCode + ")");
/**
* acquire the handoff lock that will keep the cpu running. this will
* be released once the keyguard has set itself up and poked the other wakelock
* in {@link #handleWakeWhenReady(int)}
*/
mWakeAndHandOff.acquire();
Message msg = mHandler.obtainMessage(WAKE_WHEN_READY, keyCode, 0);
mHandler.sendMessage(msg);
}
Aggregations