@Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { switch(code) { case TRANSACT_methodWithNotNullSizeArrayParameter: { data.enforceInterface(this.getInterfaceDescriptor()); final SizeF[] sizeArrayParamArray; final int sizeArrayParamLength = data.readInt(); if (sizeArrayParamLength < 0) { sizeArrayParamArray = null; } else { sizeArrayParamArray = new SizeF[sizeArrayParamLength]; for (int i = 0; i < sizeArrayParamArray.length; i++) { sizeArrayParamArray[i] = data.readSizeF(); } } delegate.methodWithNotNullSizeArrayParameter(sizeArrayParamArray); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); }
@Override public void methodWithNotNullSizeArrayParameter(@NotNull SizeF[] sizeArrayParam) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(NotNullSizeArrayParameter$$AidlServerImpl.DESCRIPTOR); if (sizeArrayParam == null) { data.writeInt(-1); } else { data.writeInt(sizeArrayParam.length); for (SizeF sizeArrayParamComponent : sizeArrayParam) { data.writeSizeF(sizeArrayParamComponent); } } delegate.transact(NotNullSizeArrayParameter$$AidlServerImpl.TRANSACT_methodWithNotNullSizeArrayParameter, data, reply, 0); reply.readException(); } finally { data.recycle(); reply.recycle(); } }
public float[] getAngle() { // 物理センサのサイズを取得(単位はミリメートル) // SizeFクラス float型の幅widthと高さheightの情報を持つ SizeF physicalSize = mCameraCharacteristics.get( mCameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE ); Log.d( "CameraCharacteristics", "物理サイズ : " + physicalSize.getWidth() + ", " + physicalSize.getHeight() ); // 焦点距離取得 float[] focalLength = mCameraCharacteristics.get( mCameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS ); // 画素配列の画素数取得 // Sizeクラス int型の幅widthと高さheightの情報を持つ Size fullArraySize = mCameraCharacteristics.get( mCameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE ); Log.d( "CameraCharacteristics", "画素配列幅 : " + fullArraySize.getWidth() + ", " + fullArraySize.getHeight() ); // 有効な配列領域取得( = 切り取り領域[ 0, 0, activeRect.width, activeRect.height ]) Rect activeRect = mCameraCharacteristics.get( mCameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE ); Log.d( "CameraCharacteristics", "有効配列幅 : " + activeRect.width() + ", " + activeRect.height() ); // 出力ストリームのサイズ取得 Size outputStreamSize = new Size( mTextureView.getWidth(), mTextureView.getHeight() ); Log.d( "CameraCharacteristics", "出力ストリーム : " + outputStreamSize.getWidth() + ", " + outputStreamSize.getHeight() ); // // 縦方向を切り取る場合(出力アスペクト比 > 切り取り領域のアスペクト比) // 横方向を切り取る場合(出力アスペクト比 < 切り取り領域のアスペクト比) /* * 【FOVを求める式】 angle = 2 * arctan( d / (2 * f) ) * f = 焦点距離, d = 縦または横のセンサ物理サイズ */ // 実際に画面に表示している領域と取得したセンサ全体の物理サイズは異なる // その辺の計算がよくわからないので全体で考えます float[] angle = new float[2]; angle[0] = 2f * (float)Math.toDegrees( Math.atan( physicalSize.getWidth() / ( 2 * focalLength[0] ) ) ); // 横 angle[1] = 2f * (float)Math.toDegrees( Math.atan( physicalSize.getHeight() / ( 2 * focalLength[0] ) ) ); // 縦 Log.d("getAngle", angle[0] + ", " + angle[1] + ", " ); return angle; }
@Test public void testSerializeSizeF() { SizeF expectedValue = new SizeF(9, 5); mCoder.serialize(bundle(), randomKey(), expectedValue); assertEquals(expectedValue, bundle().getSizeF(randomKey())); }
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Test public void testCoderApi21NotNullAbove21() throws CoderNotFoundException { assertCoderNotNull(Size.class); assertCoderNotNull(SizeF.class); }
@Config(maxSdk = Build.VERSION_CODES.KITKAT) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Test(expected = CoderNotFoundException.class) public void testCoderApi21ThrowsBelowApi21() throws CoderNotFoundException { assertCoderNotNull(Size.class); assertCoderNotNull(SizeF.class); }
@Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { switch(code) { case TRANSACT_methodWithCollectionReturn: { data.enforceInterface(this.getInterfaceDescriptor()); final ArrayList<SizeF> abstrListCollection; final int abstrListSize = data.readInt(); if (abstrListSize < 0) { abstrListCollection = null; } else { abstrListCollection = new ArrayList<>(abstrListSize); for (int j = 0; j < abstrListSize; j++) { final SizeF abstrListTmp; if (data.readByte() == -1) { abstrListTmp = null; } else { abstrListTmp = data.readSizeF(); } abstrListCollection.add(abstrListTmp); } } final Collection<AbstractListTest> returnValue = delegate.methodWithCollectionReturn(abstrListCollection); reply.writeNoException(); if (returnValue == null) { reply.writeInt(-1); } else { reply.writeInt(returnValue.size()); for (AbstractListTest returnValueElement : returnValue) { reply.writeStrongBinder(returnValueElement == null ? null : returnValueElement.asBinder()); } } return true; } } return super.onTransact(code, data, reply, flags); }
@TargetApi(21) public void testGetSizeF() { Key<SizeF> key = new Key<>("key"); Bundle bundle = new Bundle(); SizeF testSize = new SizeF(1, 2); bundle.putSizeF("key", testSize); TypedBundle typedBundle = runThroughParcel(new TypedBundle(bundle)); assertThat(typedBundle.get(key)).isEqualTo(testSize); }
@TargetApi(21) public void testPutSizeF() { Key<SizeF> key = new Key<>("key"); SizeF testSize = new SizeF(1, 2); TypedBundle typedBundle = new TypedBundle(); typedBundle.put(key, testSize); assertThat(runThroughParcel(typedBundle).getBundle().getSizeF("key")).isEqualTo(testSize); }
@TargetApi(21) public SizeF getSizeF(String key){ if(bundle != null){ return bundle.getSizeF(key); } try{ return (SizeF) stub.get(key); } catch(Exception e){ return null; } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void putSizeF(String key, SizeF value){ if(bundle != null) { bundle.putSizeF(key, value); } else { stub.put(key, value); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Test public void shouldSaveSizeFValueType() { Bundle bundle = mock(Bundle.class); SizeF value = new SizeF(42, 42); ValueSaver<SizeF> valueSaver = mValueSaverFactory.build(value); valueSaver.save(bundle, SOME_KEY, value); verify(bundle).putSizeF(SOME_KEY, value); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Test public void sizeFIsCorrectlyParcelled() { TypeAdapter<SizeF> adapter = StaticAdapters.SIZE_F_ADAPTER; SizeF expected = new SizeF(10.f, 10.f); SizeF result = writeThenRead(adapter, expected); assertThat(result).isEqualTo(expected); }
@Test public void testDeserializeSizeF() { SizeF expectedValue = new SizeF(9, 5); bundle().putSizeF(randomKey(), expectedValue); assertEquals(expectedValue, mCoder.deserialize(bundle(), randomKey())); }
@Override public void write(Bundle bundle, Object to, StateField field) throws IllegalAccessException { Field propertyField = field.getField(); propertyField.setAccessible(true); bundle.putSizeF(field.getBundleKey(), (SizeF) propertyField.get(to)); }
public BundleHelper put(@NonNull String key, @Nullable SizeF value){ bundle.putSizeF(key, value); return this; }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public AbstractNavigator putExtra(String key, SizeF value) { ensureExtras(); mTarget.getExtras().putSizeF(key, value); return this; }
@Override public Map<String, Integer> abstractMapMethod(Map<Parcelable, SizeF> responder) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(SimpleMap$$AidlServerImpl.DESCRIPTOR); if (responder == null) { data.writeInt(-1); } else { data.writeInt(responder.size()); for (Map.Entry<Parcelable, SizeF> responderEntry: responder.entrySet()) { data.writeParcelable(responderEntry.getKey(), 0); if (responderEntry.getValue() == null) { data.writeByte((byte) -1); } else { data.writeByte((byte) 0); data.writeSizeF(responderEntry.getValue()); } } } delegate.transact(SimpleMap$$AidlServerImpl.TRANSACT_abstractMapMethod, data, reply, 0); reply.readException(); final HashMap<String, Integer> returnValueMap; final int returnValueSize = reply.readInt(); if (returnValueSize < 0) { returnValueMap = null; } else { returnValueMap = new HashMap<>(); for (int k = 0; k < returnValueSize; k++) { final Integer returnValueTmp; if (reply.readByte() == -1) { returnValueTmp = null; } else { returnValueTmp = reply.readInt(); } returnValueMap.put(reply.readString(), returnValueTmp); } } return returnValueMap; } finally { data.recycle(); reply.recycle(); } }
@Override public LinkedHashMap<String, Integer> concreteMapMethod(HashMap<Parcelable, SizeF> responder) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(SimpleMap$$AidlServerImpl.DESCRIPTOR); if (responder == null) { data.writeInt(-1); } else { data.writeInt(responder.size()); for (Map.Entry<Parcelable, SizeF> responderEntry: responder.entrySet()) { data.writeParcelable(responderEntry.getKey(), 0); if (responderEntry.getValue() == null) { data.writeByte((byte) -1); } else { data.writeByte((byte) 0); data.writeSizeF(responderEntry.getValue()); } } } delegate.transact(SimpleMap$$AidlServerImpl.TRANSACT_concreteMapMethod, data, reply, 0); reply.readException(); final LinkedHashMap<String, Integer> returnValueMap; final int returnValueSize = reply.readInt(); if (returnValueSize < 0) { returnValueMap = null; } else { returnValueMap = new LinkedHashMap<>(returnValueSize, 1f); for (int k = 0; k < returnValueSize; k++) { final Integer returnValueTmp; if (reply.readByte() == -1) { returnValueTmp = null; } else { returnValueTmp = reply.readInt(); } returnValueMap.put(reply.readString(), returnValueTmp); } } return returnValueMap; } finally { data.recycle(); reply.recycle(); } }
@Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { switch(code) { case TRANSACT_methodWithAbstractListReturn: { data.enforceInterface(this.getInterfaceDescriptor()); final ArrayList<SizeF[][]> sizesCollection; final int sizesSize = data.readInt(); if (sizesSize < 0) { sizesCollection = null; } else { sizesCollection = new ArrayList<>(sizesSize); for (int j = 0; j < sizesSize; j++) { final SizeF[][] sizesArray; final int sizesLength = data.readInt(); if (sizesLength < 0) { sizesArray = null; } else { sizesArray = new SizeF[sizesLength][]; for (int i = 0; i < sizesArray.length; i++) { final SizeF[] sizesArray_; final int sizesLength_ = data.readInt(); if (sizesLength_ < 0) { sizesArray_ = null; } else { sizesArray_ = new SizeF[sizesLength_]; for (int i_ = 0; i_ < sizesArray_.length; i_++) { final SizeF sizesTmp; if (data.readByte() == -1) { sizesTmp = null; } else { sizesTmp = data.readSizeF(); } sizesArray_[i_] = sizesTmp; } } sizesArray[i] = sizesArray_; } } sizesCollection.add(sizesArray); } } final Collection<? extends Collection<? extends Serializable>> returnValue = delegate.methodWithAbstractListReturn(sizesCollection); reply.writeNoException(); if (returnValue == null) { reply.writeInt(-1); } else { reply.writeInt(returnValue.size()); for (Collection<? extends Serializable> returnValueElement : returnValue) { if (returnValueElement == null) { reply.writeInt(-1); } else { reply.writeInt(returnValueElement.size()); for (Serializable returnValueElement_ : returnValueElement) { AidlUtil.writeToObjectStream(reply, returnValueElement_); } } } } return true; } } return super.onTransact(code, data, reply, flags); }
@Override public AbstractList<List<Date>> methodWithAbstractListReturn(List<SizeF[][]> sizes) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(AbstractListSimpleNested$$AidlServerImpl.DESCRIPTOR); if (sizes == null) { data.writeInt(-1); } else { data.writeInt(sizes.size()); for (SizeF[][] sizesElement : sizes) { if (sizesElement == null) { data.writeInt(-1); } else { data.writeInt(sizesElement.length); for (SizeF[] sizesElementComponent : sizesElement) { if (sizesElementComponent == null) { data.writeInt(-1); } else { data.writeInt(sizesElementComponent.length); for (SizeF sizesElementComponent_ : sizesElementComponent) { if (sizesElementComponent_ == null) { data.writeByte((byte) -1); } else { data.writeByte((byte) 0); data.writeSizeF(sizesElementComponent_); } } } } } } } delegate.transact(AbstractListSimpleNested$$AidlServerImpl.TRANSACT_methodWithAbstractListReturn, data, reply, 0); reply.readException(); final ArrayList<List<Date>> returnValueCollection; final int returnValueSize = reply.readInt(); if (returnValueSize < 0) { returnValueCollection = null; } else { returnValueCollection = new ArrayList<>(returnValueSize); for (int j = 0; j < returnValueSize; j++) { final ArrayList<Date> returnValueCollection_; final int returnValueSize_ = reply.readInt(); if (returnValueSize_ < 0) { returnValueCollection_ = null; } else { returnValueCollection_ = new ArrayList<>(returnValueSize_); for (int j_ = 0; j_ < returnValueSize_; j_++) { returnValueCollection_.add(AidlUtil.readFromObjectStream(reply)); } } returnValueCollection.add(returnValueCollection_); } } return returnValueCollection; } finally { data.recycle(); reply.recycle(); } }
@Override public Collection<AbstractListTest> methodWithCollectionReturn(AbstractList<SizeF> abstrList) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(AbstractListTest$$AidlServerImpl.DESCRIPTOR); if (abstrList == null) { data.writeInt(-1); } else { data.writeInt(abstrList.size()); for (SizeF abstrListElement : abstrList) { if (abstrListElement == null) { data.writeByte((byte) -1); } else { data.writeByte((byte) 0); data.writeSizeF(abstrListElement); } } } delegate.transact(AbstractListTest$$AidlServerImpl.TRANSACT_methodWithCollectionReturn, data, reply, 0); reply.readException(); final ArrayList<AbstractListTest> returnValueCollection; final int returnValueSize = reply.readInt(); if (returnValueSize < 0) { returnValueCollection = null; } else { returnValueCollection = new ArrayList<>(returnValueSize); for (int j = 0; j < returnValueSize; j++) { final IBinder returnValueBinder = reply.readStrongBinder(); final AbstractListTest iReturnValue = returnValueBinder == null ? null : InterfaceLoader.asInterface(returnValueBinder, AbstractListTest.class); returnValueCollection.add(iReturnValue); } } return returnValueCollection; } finally { data.recycle(); reply.recycle(); } }
public void putSizeF(java.lang.String key, SizeF value){ throw new RuntimeException("Stub!"); }
public SizeF getSizeF(java.lang.String key){ throw new RuntimeException("Stub!"); }
@Override public void save(Bundle state, String key, SizeF value) { state.putSizeF(key, value); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @NonNull @Override public SizeF readFromParcel(@NonNull Parcel source) { return source.readSizeF(); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void writeToParcel(@NonNull SizeF value, @NonNull Parcel dest, int flags) { dest.writeSizeF(value); }
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null */ @TargetApi(21) public Bundler putSizeF(String key, SizeF value) { bundle.putSizeF(key, value); return this; }
/** * Write a field's value into the saved state {@link Bundle}. * * @param state {@link Bundle} used to save the state * @param key key retrieved from {@code fieldDeclaringClass#fieldName} * @param fieldValue value of field */ @Override public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull SizeF fieldValue) { state.putSizeF(key, fieldValue); }
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public Metadata putSizeF(@Nullable String key, @Nullable SizeF value) { mBundle.putSizeF(key, value); return this; }
/** * Returns the value associated with the given key, or null if * no mapping of the desired type exists for the given key or a null * value is explicitly associated with the key. * * @param key a String, or null * @return a Size value, or null */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Nullable public SizeF getSizeF(@Nullable String key) { return mBundle.getSizeF(key); }
/** * Inserts a value into the mapping of this {@code TypedBundle}, replacing any existing value * for the given key. * * @param key the key * @param value the value * @return the {@code TypedBundle} for chaining */ @TargetApi(21) public TypedBundle put(@NonNull Key<SizeF> key, SizeF value) { bundle.putSizeF(key.name, value); return this; }