Search in sources :

Example 6 with IRemoteCallback

use of android.os.IRemoteCallback in project android_frameworks_base by DirtyUnicorns.

the class EphemeralResolverService method onBind.

@Override
public final IBinder onBind(Intent intent) {
    return new IEphemeralResolver.Stub() {

        @Override
        public void getEphemeralResolveInfoList(IRemoteCallback callback, int[] digestPrefix, int prefixMask, int sequence) {
            final Message msg = mHandler.obtainMessage(ServiceHandler.MSG_GET_EPHEMERAL_RESOLVE_INFO, prefixMask, sequence, callback);
            final Bundle data = new Bundle();
            data.putIntArray(EXTRA_PREFIX, digestPrefix);
            msg.setData(data);
            msg.sendToTarget();
        }
    };
}
Also used : IRemoteCallback(android.os.IRemoteCallback) Message(android.os.Message) Bundle(android.os.Bundle)

Example 7 with IRemoteCallback

use of android.os.IRemoteCallback in project android_frameworks_base by DirtyUnicorns.

the class UserController method dispatchUserSwitch.

void dispatchUserSwitch(final UserState uss, final int oldUserId, final int newUserId) {
    Slog.d(TAG, "Dispatch onUserSwitching oldUser #" + oldUserId + " newUser #" + newUserId);
    final int observerCount = mUserSwitchObservers.beginBroadcast();
    if (observerCount > 0) {
        final ArraySet<String> curWaitingUserSwitchCallbacks = new ArraySet<>();
        synchronized (mService) {
            uss.switching = true;
            mCurWaitingUserSwitchCallbacks = curWaitingUserSwitchCallbacks;
        }
        final AtomicInteger waitingCallbacksCount = new AtomicInteger(observerCount);
        final long dispatchStartedTime = SystemClock.elapsedRealtime();
        for (int i = 0; i < observerCount; i++) {
            try {
                // Prepend with unique prefix to guarantee that keys are unique
                final String name = "#" + i + " " + mUserSwitchObservers.getBroadcastCookie(i);
                synchronized (mService) {
                    curWaitingUserSwitchCallbacks.add(name);
                }
                final IRemoteCallback callback = new IRemoteCallback.Stub() {

                    @Override
                    public void sendResult(Bundle data) throws RemoteException {
                        synchronized (mService) {
                            long delay = SystemClock.elapsedRealtime() - dispatchStartedTime;
                            if (delay > USER_SWITCH_TIMEOUT) {
                                Slog.wtf(TAG, "User switch timeout: observer " + name + " sent result after " + delay + " ms");
                            }
                            // Early return if this session is no longer valid
                            if (curWaitingUserSwitchCallbacks != mCurWaitingUserSwitchCallbacks) {
                                return;
                            }
                            curWaitingUserSwitchCallbacks.remove(name);
                            // Continue switching if all callbacks have been notified
                            if (waitingCallbacksCount.decrementAndGet() == 0) {
                                sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
                            }
                        }
                    }
                };
                mUserSwitchObservers.getBroadcastItem(i).onUserSwitching(newUserId, callback);
            } catch (RemoteException e) {
            }
        }
    } else {
        synchronized (mService) {
            sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
        }
    }
    mUserSwitchObservers.finishBroadcast();
}
Also used : ArraySet(android.util.ArraySet) IRemoteCallback(android.os.IRemoteCallback) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Example 8 with IRemoteCallback

use of android.os.IRemoteCallback in project android_frameworks_base by AOSPA.

the class EphemeralResolverService method onBind.

@Override
public final IBinder onBind(Intent intent) {
    return new IEphemeralResolver.Stub() {

        @Override
        public void getEphemeralResolveInfoList(IRemoteCallback callback, int[] digestPrefix, int prefixMask, int sequence) {
            final Message msg = mHandler.obtainMessage(ServiceHandler.MSG_GET_EPHEMERAL_RESOLVE_INFO, prefixMask, sequence, callback);
            final Bundle data = new Bundle();
            data.putIntArray(EXTRA_PREFIX, digestPrefix);
            msg.setData(data);
            msg.sendToTarget();
        }
    };
}
Also used : IRemoteCallback(android.os.IRemoteCallback) Message(android.os.Message) Bundle(android.os.Bundle)

Example 9 with IRemoteCallback

use of android.os.IRemoteCallback in project android_frameworks_base by AOSPA.

the class UserController method dispatchUserSwitch.

void dispatchUserSwitch(final UserState uss, final int oldUserId, final int newUserId) {
    Slog.d(TAG, "Dispatch onUserSwitching oldUser #" + oldUserId + " newUser #" + newUserId);
    final int observerCount = mUserSwitchObservers.beginBroadcast();
    if (observerCount > 0) {
        final ArraySet<String> curWaitingUserSwitchCallbacks = new ArraySet<>();
        synchronized (mService) {
            uss.switching = true;
            mCurWaitingUserSwitchCallbacks = curWaitingUserSwitchCallbacks;
        }
        final AtomicInteger waitingCallbacksCount = new AtomicInteger(observerCount);
        final long dispatchStartedTime = SystemClock.elapsedRealtime();
        for (int i = 0; i < observerCount; i++) {
            try {
                // Prepend with unique prefix to guarantee that keys are unique
                final String name = "#" + i + " " + mUserSwitchObservers.getBroadcastCookie(i);
                synchronized (mService) {
                    curWaitingUserSwitchCallbacks.add(name);
                }
                final IRemoteCallback callback = new IRemoteCallback.Stub() {

                    @Override
                    public void sendResult(Bundle data) throws RemoteException {
                        synchronized (mService) {
                            long delay = SystemClock.elapsedRealtime() - dispatchStartedTime;
                            if (delay > USER_SWITCH_TIMEOUT) {
                                Slog.wtf(TAG, "User switch timeout: observer " + name + " sent result after " + delay + " ms");
                            }
                            // Early return if this session is no longer valid
                            if (curWaitingUserSwitchCallbacks != mCurWaitingUserSwitchCallbacks) {
                                return;
                            }
                            curWaitingUserSwitchCallbacks.remove(name);
                            // Continue switching if all callbacks have been notified
                            if (waitingCallbacksCount.decrementAndGet() == 0) {
                                sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
                            }
                        }
                    }
                };
                mUserSwitchObservers.getBroadcastItem(i).onUserSwitching(newUserId, callback);
            } catch (RemoteException e) {
            }
        }
    } else {
        synchronized (mService) {
            sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
        }
    }
    mUserSwitchObservers.finishBroadcast();
}
Also used : ArraySet(android.util.ArraySet) IRemoteCallback(android.os.IRemoteCallback) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Example 10 with IRemoteCallback

use of android.os.IRemoteCallback in project android_frameworks_base by ResurrectionRemix.

the class UserController method dispatchUserSwitch.

void dispatchUserSwitch(final UserState uss, final int oldUserId, final int newUserId) {
    Slog.d(TAG, "Dispatch onUserSwitching oldUser #" + oldUserId + " newUser #" + newUserId);
    final int observerCount = mUserSwitchObservers.beginBroadcast();
    if (observerCount > 0) {
        final ArraySet<String> curWaitingUserSwitchCallbacks = new ArraySet<>();
        synchronized (mService) {
            uss.switching = true;
            mCurWaitingUserSwitchCallbacks = curWaitingUserSwitchCallbacks;
        }
        final AtomicInteger waitingCallbacksCount = new AtomicInteger(observerCount);
        final long dispatchStartedTime = SystemClock.elapsedRealtime();
        for (int i = 0; i < observerCount; i++) {
            try {
                // Prepend with unique prefix to guarantee that keys are unique
                final String name = "#" + i + " " + mUserSwitchObservers.getBroadcastCookie(i);
                synchronized (mService) {
                    curWaitingUserSwitchCallbacks.add(name);
                }
                final IRemoteCallback callback = new IRemoteCallback.Stub() {

                    @Override
                    public void sendResult(Bundle data) throws RemoteException {
                        synchronized (mService) {
                            long delay = SystemClock.elapsedRealtime() - dispatchStartedTime;
                            if (delay > USER_SWITCH_TIMEOUT) {
                                Slog.wtf(TAG, "User switch timeout: observer " + name + " sent result after " + delay + " ms");
                            }
                            // Early return if this session is no longer valid
                            if (curWaitingUserSwitchCallbacks != mCurWaitingUserSwitchCallbacks) {
                                return;
                            }
                            curWaitingUserSwitchCallbacks.remove(name);
                            // Continue switching if all callbacks have been notified
                            if (waitingCallbacksCount.decrementAndGet() == 0) {
                                sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
                            }
                        }
                    }
                };
                mUserSwitchObservers.getBroadcastItem(i).onUserSwitching(newUserId, callback);
            } catch (RemoteException e) {
            }
        }
    } else {
        synchronized (mService) {
            sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
        }
    }
    mUserSwitchObservers.finishBroadcast();
}
Also used : ArraySet(android.util.ArraySet) IRemoteCallback(android.os.IRemoteCallback) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Aggregations

IRemoteCallback (android.os.IRemoteCallback)30 Bundle (android.os.Bundle)14 RemoteException (android.os.RemoteException)14 Point (android.graphics.Point)9 Message (android.os.Message)8 IUserSwitchObserver (android.app.IUserSwitchObserver)5 PendingIntent (android.app.PendingIntent)5 BroadcastReceiver (android.content.BroadcastReceiver)5 Context (android.content.Context)5 Intent (android.content.Intent)5 IntentFilter (android.content.IntentFilter)5 ArraySet (android.util.ArraySet)4 AlphaAnimation (android.view.animation.AlphaAnimation)4 Animation (android.view.animation.Animation)4 AnimationSet (android.view.animation.AnimationSet)4 ClipRectAnimation (android.view.animation.ClipRectAnimation)4 ScaleAnimation (android.view.animation.ScaleAnimation)4 TranslateAnimation (android.view.animation.TranslateAnimation)4 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)4 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)4