Search in sources :

Example 66 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class CameraService method notifyMediaserverLocked.

private boolean notifyMediaserverLocked(int eventType, Set<Integer> updatedUserHandles) {
    // process.
    if (mCameraServiceRaw == null) {
        IBinder cameraServiceBinder = getBinderService(CAMERA_SERVICE_BINDER_NAME);
        if (cameraServiceBinder == null) {
            Slog.w(TAG, "Could not notify mediaserver, camera service not available.");
            // Camera service not active, cannot evict user clients.
            return false;
        }
        try {
            cameraServiceBinder.linkToDeath(this, /*flags*/
            0);
        } catch (RemoteException e) {
            Slog.w(TAG, "Could not link to death of native camera service");
            return false;
        }
        mCameraServiceRaw = ICameraService.Stub.asInterface(cameraServiceBinder);
    }
    try {
        mCameraServiceRaw.notifySystemEvent(eventType, toArray(updatedUserHandles));
    } catch (RemoteException e) {
        Slog.w(TAG, "Could not notify mediaserver, remote exception: " + e);
        // Not much we can do if camera service is dead.
        return false;
    }
    return true;
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 67 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class PacManager method bind.

private void bind() {
    if (mContext == null) {
        Log.e(TAG, "No context for binding");
        return;
    }
    Intent intent = new Intent();
    intent.setClassName(PAC_PACKAGE, PAC_SERVICE);
    if ((mProxyConnection != null) && (mConnection != null)) {
        // Already bound no need to bind again, just download the new file.
        mNetThreadHandler.post(mPacDownloader);
        return;
    }
    mConnection = new ServiceConnection() {

        @Override
        public void onServiceDisconnected(ComponentName component) {
            synchronized (mProxyLock) {
                mProxyService = null;
            }
        }

        @Override
        public void onServiceConnected(ComponentName component, IBinder binder) {
            synchronized (mProxyLock) {
                try {
                    Log.d(TAG, "Adding service " + PAC_SERVICE_NAME + " " + binder.getInterfaceDescriptor());
                } catch (RemoteException e1) {
                    Log.e(TAG, "Remote Exception", e1);
                }
                ServiceManager.addService(PAC_SERVICE_NAME, binder);
                mProxyService = IProxyService.Stub.asInterface(binder);
                if (mProxyService == null) {
                    Log.e(TAG, "No proxy service");
                } else {
                    try {
                        mProxyService.startPacSystem();
                    } catch (RemoteException e) {
                        Log.e(TAG, "Unable to reach ProxyService - PAC will not be started", e);
                    }
                    mNetThreadHandler.post(mPacDownloader);
                }
            }
        }
    };
    mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE);
    intent = new Intent();
    intent.setClassName(PROXY_PACKAGE, PROXY_SERVICE);
    mProxyConnection = new ServiceConnection() {

        @Override
        public void onServiceDisconnected(ComponentName component) {
        }

        @Override
        public void onServiceConnected(ComponentName component, IBinder binder) {
            IProxyCallback callbackService = IProxyCallback.Stub.asInterface(binder);
            if (callbackService != null) {
                try {
                    callbackService.getProxyPort(new IProxyPortListener.Stub() {

                        @Override
                        public void setProxyPort(int port) throws RemoteException {
                            if (mLastPort != -1) {
                                // Always need to send if port changed
                                mHasSentBroadcast = false;
                            }
                            mLastPort = port;
                            if (port != -1) {
                                Log.d(TAG, "Local proxy is bound on " + port);
                                sendProxyIfNeeded();
                            } else {
                                Log.e(TAG, "Received invalid port from Local Proxy," + " PAC will not be operational");
                            }
                        }
                    });
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    mContext.bindService(intent, mProxyConnection, Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE);
}
Also used : ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ComponentName(android.content.ComponentName) IProxyCallback(com.android.net.IProxyCallback) RemoteException(android.os.RemoteException)

Example 68 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class UserController method getUserManager.

private UserManagerService getUserManager() {
    UserManagerService userManager = mUserManager;
    if (userManager == null) {
        IBinder b = ServiceManager.getService(Context.USER_SERVICE);
        userManager = mUserManager = (UserManagerService) IUserManager.Stub.asInterface(b);
    }
    return userManager;
}
Also used : IBinder(android.os.IBinder) UserManagerService(com.android.server.pm.UserManagerService)

Example 69 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class ManagedServices method getServiceFromTokenLocked.

public ManagedServiceInfo getServiceFromTokenLocked(IInterface service) {
    if (service == null) {
        return null;
    }
    final IBinder token = service.asBinder();
    final int N = mServices.size();
    for (int i = 0; i < N; i++) {
        final ManagedServiceInfo info = mServices.get(i);
        if (info.service.asBinder() == token)
            return info;
    }
    return null;
}
Also used : IBinder(android.os.IBinder)

Example 70 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class PhoneWindowManager method takeScreenshot.

// Assume this is called from the Handler thread.
private void takeScreenshot(final int screenshotType) {
    synchronized (mScreenshotLock) {
        if (mScreenshotConnection != null) {
            return;
        }
        final ComponentName serviceComponent = new ComponentName(SYSUI_PACKAGE, SYSUI_SCREENSHOT_SERVICE);
        final Intent serviceIntent = new Intent();
        serviceIntent.setComponent(serviceComponent);
        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, screenshotType);
                    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) {
                synchronized (mScreenshotLock) {
                    if (mScreenshotConnection != null) {
                        mContext.unbindService(mScreenshotConnection);
                        mScreenshotConnection = null;
                        mHandler.removeCallbacks(mScreenshotTimeout);
                        notifyScreenshotError();
                    }
                }
            }
        };
        if (mContext.bindServiceAsUser(serviceIntent, conn, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE, 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) ComponentName(android.content.ComponentName) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) Messenger(android.os.Messenger) RemoteException(android.os.RemoteException)

Aggregations

IBinder (android.os.IBinder)991 RemoteException (android.os.RemoteException)494 Intent (android.content.Intent)141 ComponentName (android.content.ComponentName)128 ServiceConnection (android.content.ServiceConnection)94 Parcel (android.os.Parcel)91 Point (android.graphics.Point)67 PendingIntent (android.app.PendingIntent)60 IOException (java.io.IOException)53 UserHandle (android.os.UserHandle)50 Bundle (android.os.Bundle)40 Binder (android.os.Binder)37 Message (android.os.Message)37 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)34 AndroidRuntimeException (android.util.AndroidRuntimeException)33 Handler (android.os.Handler)31 ArrayList (java.util.ArrayList)27 IContentProvider (android.content.IContentProvider)25 TransactionTooLargeException (android.os.TransactionTooLargeException)25 OperationResult (android.security.keymaster.OperationResult)25