Search in sources :

Example 16 with Message

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;
}
Also used : Message(android.os.Message)

Example 17 with Message

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;
}
Also used : Message(android.os.Message) Bundle(android.os.Bundle)

Example 18 with Message

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();
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) Field(java.lang.reflect.Field) BundleImpl(android.taobao.atlas.framework.BundleImpl) Message(android.os.Message)

Example 19 with Message

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);
        }
    }
}
Also used : ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) Message(android.os.Message) Handler(android.os.Handler) DeviceKeyHandler(com.android.internal.os.DeviceKeyHandler) ComponentName(android.content.ComponentName) Intent(android.content.Intent) Messenger(android.os.Messenger) RemoteException(android.os.RemoteException)

Example 20 with Message

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);
}
Also used : Message(android.os.Message)

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