android.os.Parcel.writeStrongBinder()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(251)

本文整理了Java中android.os.Parcel.writeStrongBinder()方法的一些代码示例,展示了Parcel.writeStrongBinder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.writeStrongBinder()方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:writeStrongBinder

Parcel.writeStrongBinder介绍

[英]Write an object into the parcel at the current dataPosition(), growing dataCapacity() if needed.
[中]将对象写入当前dataPosition()处的地块,如果需要,增加dataCapacity()。

代码示例

代码示例来源:origin: johncarl81/parceler

@Override
  public void nullSafeToParcel(IBinder input, Parcel parcel) {
    parcel.writeStrongBinder(input);
  }
};

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeInt(this.mType);
  dest.writeByte(this.mOrderedHint ? (byte) 1 : (byte) 0);
  dest.writeByte(this.mInitialStickyHint ? (byte) 1 : (byte) 0);
  dest.writeStrongBinder(this.mToken);
  dest.writeInt(this.mSendingUser);
  dest.writeInt(this.mFlags);
  dest.writeInt(this.mResultCode);
  dest.writeString(this.mResultData);
  dest.writeBundle(this.mResultExtras);
  dest.writeByte(this.mAbortBroadcast ? (byte) 1 : (byte) 0);
  dest.writeByte(this.mFinished ? (byte) 1 : (byte) 0);
}

代码示例来源:origin: firebase/firebase-jobdispatcher-android

@Override
 public void writeToParcel(Parcel parcel, int flags) {
  parcel.writeStrongBinder(binder);
 }
}

代码示例来源:origin: stackoverflow.com

public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
51    {
52        try {
53            switch (code) {
54            case IServiceManager.GET_SERVICE_TRANSACTION: {
55                data.enforceInterface(IServiceManager.descriptor);
56                String name = data.readString();
57                IBinder service = getService(name);
58                reply.writeStrongBinder(service);
59                return true;
60            }
61
62            case IServiceManager.CHECK_SERVICE_TRANSACTION: {
63                data.enforceInterface(IServiceManager.descriptor);
64                String name = data.readString();
65                IBinder service = checkService(name);
66                reply.writeStrongBinder(service);
67                return true;
68            }
69
//Rest has been discarded for brevity…………………..

………………….
………………….
…………………

代码示例来源:origin: android-hacker/VirtualXposed

if (DEBUG)
  Log.d(TAG, "Breaking @" + i + " of " + N + ": retriever=" + retriever);
dest.writeStrongBinder(retriever);

代码示例来源:origin: Marswin/MarsDaemon

mServiceData.writeStrongBinder(null);

代码示例来源:origin: Marswin/MarsDaemon

mBroadcastData.writeInterfaceToken("android.app.IActivityManager");
mBroadcastData.writeStrongBinder(null);
intent.writeToParcel(mBroadcastData, 0);
mBroadcastData.writeString(intent.resolveTypeIfNeeded(context.getContentResolver()));
mBroadcastData.writeStrongBinder(null);
mBroadcastData.writeInt(Activity.RESULT_OK);
mBroadcastData.writeString(null);

代码示例来源:origin: Marswin/MarsDaemon

mServiceData.writeStrongBinder(null);

代码示例来源:origin: LawnchairLauncher/Lawnchair

@Override
public void windowAttached(WindowManager.LayoutParams attrs, ILauncherOverlayCallback callbacks, int options) throws RemoteException {
  Parcel data = Parcel.obtain();
  try {
    data.writeInterfaceToken(ILauncherOverlay.class.getName());
    if (attrs != null) {
      data.writeInt(1);
      attrs.writeToParcel(data, 0);
    } else {
      data.writeInt(0);
    }
    data.writeStrongBinder(callbacks.asBinder());
    data.writeInt(options);
    data.writeInt(1);
    mRemote.transact(WINDOW_ATTACHED_TRANSACTION, data, null, FLAG_ONEWAY);
  } finally {
    data.recycle();
  }
}

代码示例来源:origin: android-hacker/VirtualXposed

public static PendingIntent readPendingIntent(IBinder binder) {
  Parcel parcel = Parcel.obtain();
  parcel.writeStrongBinder(binder);
  parcel.setDataPosition(0);
  try {
    return PendingIntent.readPendingIntentOrNullFromParcel(parcel);
  } finally {
    parcel.recycle();
  }
}

代码示例来源:origin: LawnchairLauncher/Lawnchair

@Override
public void windowAttached2(Bundle bundle, ILauncherOverlayCallback iLauncherOverlayCallback) throws RemoteException {
  IBinder iBinder = null;
  Parcel obtain = Parcel.obtain();
  try {
    obtain.writeInterfaceToken("com.google.android.libraries.launcherclient.ILauncherOverlay");
    if (bundle == null) {
      obtain.writeInt(0);
    } else {
      obtain.writeInt(1);
      bundle.writeToParcel(obtain, 0);
    }
    if (iLauncherOverlayCallback != null) {
      iBinder = iLauncherOverlayCallback.asBinder();
    }
    obtain.writeStrongBinder(iBinder);
    this.mRemote.transact(14, obtain, null, FLAG_ONEWAY);
  } finally {
    obtain.recycle();
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = LOLLIPOP)
public void testWriteNullStrongBinder() {
 parcel.writeStrongBinder(null);
 parcel.setDataPosition(0);
 assertThat(parcel.readStrongBinder()).isNull();
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = LOLLIPOP)
public void testReadWriteSingleStrongBinder() {
 IBinder binder = new Binder();
 parcel.writeStrongBinder(binder);
 parcel.setDataPosition(0);
 assertThat(parcel.readStrongBinder()).isEqualTo(binder);
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = LOLLIPOP)
public void testReadWriteMultipleStrongBinders() {
 List<IBinder> binders = new ArrayList<>();
 for (int i = 0; i < 10; ++i) {
  IBinder binder = new Binder();
  binders.add(binder);
  parcel.writeStrongBinder(binder);
 }
 parcel.setDataPosition(0);
 for (int i = 0; i < 10; ++i) {
  assertThat(parcel.readStrongBinder()).isEqualTo(binders.get(i));
 }
 // now try to read past the number of items written and see what happens
 assertThat(parcel.readStrongBinder()).isNull();
}

代码示例来源:origin: firebase/firebase-jobdispatcher-android

@Test
public void testOnStartCommand_handlesStartJob_noTag() {
 JobService service = spy(new ExampleJobService());
 int startId = 7;
 Intent executeJobIntent = new Intent(JobService.ACTION_EXECUTE);
 Parcel p = Parcel.obtain();
 p.writeStrongBinder(mock(IBinder.class));
 executeJobIntent.putExtra("callback", new PendingCallback(p));
 service.onStartCommand(executeJobIntent, 0, startId);
 verify(service).stopSelf(startId);
 p.recycle();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testDataPositionAfterSomeWrites() {
 parcel.writeInt(1);
 assertThat(parcel.dataPosition()).isEqualTo(4);
 parcel.writeFloat(5);
 assertThat(parcel.dataPosition()).isEqualTo(8);
 parcel.writeDouble(37);
 assertThat(parcel.dataPosition()).isEqualTo(16);
 parcel.writeStrongBinder(new Binder()); // 20 bytes
 assertThat(parcel.dataPosition()).isEqualTo(36);
}

代码示例来源:origin: firebase/firebase-jobdispatcher-android

@Test
public void prepareJob() {
 Intent intent = new Intent();
 Bundle encode = encodeContentUriJob(getContentUriTrigger(), TestUtil.JOB_CODER);
 intent.putExtra(GooglePlayJobWriter.REQUEST_PARAM_EXTRAS, encode);
 Parcel container = Parcel.obtain();
 container.writeStrongBinder(new Binder());
 PendingCallback pcb = new PendingCallback(container);
 intent.putExtra("callback", pcb);
 ArrayList<Uri> uris = new ArrayList<>();
 uris.add(ContactsContract.AUTHORITY_URI);
 uris.add(Media.EXTERNAL_CONTENT_URI);
 intent.putParcelableArrayListExtra(BundleProtocol.PACKED_PARAM_TRIGGERED_URIS, uris);
 JobInvocation jobInvocation = receiver.prepareJob(intent);
 assertEquals(jobInvocation.getTriggerReason().getTriggeredContentUris(), uris);
}

代码示例来源:origin: firebase/firebase-jobdispatcher-android

public PendingCallback toPendingCallback() {
 Parcel container = Parcel.obtain();
 try {
  container.writeStrongBinder(this);
  container.setDataPosition(0);
  return new PendingCallback(container);
 } finally {
  container.recycle();
 }
}

代码示例来源:origin: stackoverflow.com

public boolean handleApplicationWtf(IBinder app, String tag,
    ApplicationErrorReport.CrashInfo crashInfo)
    throws RemoteException {
  Parcel data = Parcel.obtain();
  Parcel reply = Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeStrongBinder(app);
  data.writeString(tag);
  crashInfo.writeToParcel(data, 0);
  mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data,
      reply, 0);
  reply.readException();
  boolean res = reply.readInt() != 0;
  reply.recycle();
  data.recycle();
  return res;
}

代码示例来源:origin: skjolber/external-nfc-api

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(name);
  dest.writeStrongBinder(readerControl.asBinder());
}

相关文章

Parcel类方法