use of android.os.IRemoteCallback in project android_frameworks_base by crdroidandroid.
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();
}
};
}
use of android.os.IRemoteCallback in project android_frameworks_base by crdroidandroid.
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();
}
use of android.os.IRemoteCallback in project android_frameworks_base by crdroidandroid.
the class AppTransition method createAspectScaledThumbnailFreeformAnimationLocked.
private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame, Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) {
final float sourceWidth = sourceFrame.width();
final float sourceHeight = sourceFrame.height();
final float destWidth = destFrame.width();
final float destHeight = destFrame.height();
final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth;
final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight;
AnimationSet set = new AnimationSet(true);
final int surfaceInsetsH = surfaceInsets == null ? 0 : surfaceInsets.left + surfaceInsets.right;
final int surfaceInsetsV = surfaceInsets == null ? 0 : surfaceInsets.top + surfaceInsets.bottom;
// We want the scaling to happen from the center of the surface. In order to achieve that,
// we need to account for surface insets that will be used to enlarge the surface.
final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2;
final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2;
final ScaleAnimation scale = enter ? new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter) : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter);
final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2;
final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2;
final int destHCenter = destFrame.left + destFrame.width() / 2;
final int destVCenter = destFrame.top + destFrame.height() / 2;
final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter;
final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter;
final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0) : new TranslateAnimation(0, fromX, 0, fromY);
set.addAnimation(scale);
set.addAnimation(translation);
final IRemoteCallback callback = mAnimationFinishedCallback;
if (callback != null) {
set.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
return set;
}
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();
}
};
}
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();
}
};
}
Aggregations