ADD week 5
This commit is contained in:
117
02-Easy5/E5/sources/android/support/v4/os/IResultReceiver.java
Normal file
117
02-Easy5/E5/sources/android/support/v4/os/IResultReceiver.java
Normal file
@ -0,0 +1,117 @@
|
||||
package android.support.v4.os;
|
||||
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface IResultReceiver extends IInterface {
|
||||
public static final String DESCRIPTOR = "android.support.v4.os.IResultReceiver";
|
||||
|
||||
public static class Default implements IResultReceiver {
|
||||
@Override // android.os.IInterface
|
||||
public IBinder asBinder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.os.IResultReceiver
|
||||
public void send(int i, Bundle bundle) throws RemoteException {
|
||||
}
|
||||
}
|
||||
|
||||
void send(int i, Bundle bundle) throws RemoteException;
|
||||
|
||||
public static abstract class Stub extends Binder implements IResultReceiver {
|
||||
static final int TRANSACTION_send = 1;
|
||||
|
||||
@Override // android.os.IInterface
|
||||
public IBinder asBinder() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Stub() {
|
||||
attachInterface(this, IResultReceiver.DESCRIPTOR);
|
||||
}
|
||||
|
||||
public static IResultReceiver asInterface(IBinder iBinder) {
|
||||
if (iBinder == null) {
|
||||
return null;
|
||||
}
|
||||
IInterface queryLocalInterface = iBinder.queryLocalInterface(IResultReceiver.DESCRIPTOR);
|
||||
if (queryLocalInterface != null && (queryLocalInterface instanceof IResultReceiver)) {
|
||||
return (IResultReceiver) queryLocalInterface;
|
||||
}
|
||||
return new Proxy(iBinder);
|
||||
}
|
||||
|
||||
@Override // android.os.Binder
|
||||
public boolean onTransact(int i, Parcel parcel, Parcel parcel2, int i2) throws RemoteException {
|
||||
if (i >= 1 && i <= 16777215) {
|
||||
parcel.enforceInterface(IResultReceiver.DESCRIPTOR);
|
||||
}
|
||||
if (i == 1598968902) {
|
||||
parcel2.writeString(IResultReceiver.DESCRIPTOR);
|
||||
return true;
|
||||
}
|
||||
if (i == 1) {
|
||||
send(parcel.readInt(), (Bundle) _Parcel.readTypedObject(parcel, Bundle.CREATOR));
|
||||
return true;
|
||||
}
|
||||
return super.onTransact(i, parcel, parcel2, i2);
|
||||
}
|
||||
|
||||
private static class Proxy implements IResultReceiver {
|
||||
private IBinder mRemote;
|
||||
|
||||
@Override // android.os.IInterface
|
||||
public IBinder asBinder() {
|
||||
return this.mRemote;
|
||||
}
|
||||
|
||||
public String getInterfaceDescriptor() {
|
||||
return IResultReceiver.DESCRIPTOR;
|
||||
}
|
||||
|
||||
Proxy(IBinder iBinder) {
|
||||
this.mRemote = iBinder;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.os.IResultReceiver
|
||||
public void send(int i, Bundle bundle) throws RemoteException {
|
||||
Parcel obtain = Parcel.obtain();
|
||||
try {
|
||||
obtain.writeInterfaceToken(IResultReceiver.DESCRIPTOR);
|
||||
obtain.writeInt(i);
|
||||
_Parcel.writeTypedObject(obtain, bundle, 0);
|
||||
this.mRemote.transact(1, obtain, null, 1);
|
||||
} finally {
|
||||
obtain.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class _Parcel {
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static <T> T readTypedObject(Parcel parcel, Parcelable.Creator<T> creator) {
|
||||
if (parcel.readInt() != 0) {
|
||||
return creator.createFromParcel(parcel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static <T extends Parcelable> void writeTypedObject(Parcel parcel, T t, int i) {
|
||||
if (t != null) {
|
||||
parcel.writeInt(1);
|
||||
t.writeToParcel(parcel, i);
|
||||
} else {
|
||||
parcel.writeInt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
106
02-Easy5/E5/sources/android/support/v4/os/ResultReceiver.java
Normal file
106
02-Easy5/E5/sources/android/support/v4/os/ResultReceiver.java
Normal file
@ -0,0 +1,106 @@
|
||||
package android.support.v4.os;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
import android.support.v4.os.IResultReceiver;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ResultReceiver implements Parcelable {
|
||||
public static final Parcelable.Creator<ResultReceiver> CREATOR = new Parcelable.Creator<ResultReceiver>() { // from class: android.support.v4.os.ResultReceiver.1
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public ResultReceiver createFromParcel(Parcel parcel) {
|
||||
return new ResultReceiver(parcel);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public ResultReceiver[] newArray(int i) {
|
||||
return new ResultReceiver[i];
|
||||
}
|
||||
};
|
||||
final Handler mHandler;
|
||||
final boolean mLocal;
|
||||
IResultReceiver mReceiver;
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void onReceiveResult(int i, Bundle bundle) {
|
||||
}
|
||||
|
||||
class MyRunnable implements Runnable {
|
||||
final int mResultCode;
|
||||
final Bundle mResultData;
|
||||
|
||||
MyRunnable(int i, Bundle bundle) {
|
||||
this.mResultCode = i;
|
||||
this.mResultData = bundle;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ResultReceiver.this.onReceiveResult(this.mResultCode, this.mResultData);
|
||||
}
|
||||
}
|
||||
|
||||
class MyResultReceiver extends IResultReceiver.Stub {
|
||||
MyResultReceiver() {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.os.IResultReceiver
|
||||
public void send(int i, Bundle bundle) {
|
||||
if (ResultReceiver.this.mHandler != null) {
|
||||
ResultReceiver.this.mHandler.post(ResultReceiver.this.new MyRunnable(i, bundle));
|
||||
} else {
|
||||
ResultReceiver.this.onReceiveResult(i, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ResultReceiver(Handler handler) {
|
||||
this.mLocal = true;
|
||||
this.mHandler = handler;
|
||||
}
|
||||
|
||||
public void send(int i, Bundle bundle) {
|
||||
if (this.mLocal) {
|
||||
Handler handler = this.mHandler;
|
||||
if (handler != null) {
|
||||
handler.post(new MyRunnable(i, bundle));
|
||||
return;
|
||||
} else {
|
||||
onReceiveResult(i, bundle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
IResultReceiver iResultReceiver = this.mReceiver;
|
||||
if (iResultReceiver != null) {
|
||||
try {
|
||||
iResultReceiver.send(i, bundle);
|
||||
} catch (RemoteException unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
synchronized (this) {
|
||||
if (this.mReceiver == null) {
|
||||
this.mReceiver = new MyResultReceiver();
|
||||
}
|
||||
parcel.writeStrongBinder(this.mReceiver.asBinder());
|
||||
}
|
||||
}
|
||||
|
||||
ResultReceiver(Parcel parcel) {
|
||||
this.mLocal = false;
|
||||
this.mHandler = null;
|
||||
this.mReceiver = IResultReceiver.Stub.asInterface(parcel.readStrongBinder());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user