docstring_tokens
stringlengths
18
16.9k
code_tokens
stringlengths
75
1.81M
html_url
stringlengths
74
116
file_name
stringlengths
3
311
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> value_type* heap() noexcept { <mask> if (kHasInlineCapacity || !detail::pointerFlagGet(pdata_.heap_)) { <mask> return static_cast<value_type*>(pdata_.heap_); <mask> } <mask> return static_cast<value_type*>( <mask> detail::shiftPointer( <mask> detail::pointerFlagClear(pdata_.heap_), kHeapifyCapacitySize)); <mask> } <mask> value_type const* heap() const noexcept { <mask> return const_cast<Data*>(this)->heap(); <mask> } <mask> </s> [sdk33] Update iOS with RN 0.59 </s> add } else { return static_cast<value_type*>(detail::shiftPointer( detail::pointerFlagClear(pdata_.heap_), kHeapifyCapacitySize)); </s> remove template<class ...Args> </s> add template <class... Args> </s> remove const value_type *first() const { </s> add const value_type* first() const { </s> remove if (parent_) { LockPolicy::unlock(parent_->mutex_); } </s> add assignImpl(*this, rhs); return *this; } </s> remove LockedPtrBase(LockedPtrBase&& rhs) noexcept : parent_(rhs.parent_) { rhs.parent_ = nullptr; } </s> add LockedPtrBase(LockedPtrBase&& rhs) noexcept : parent_{exchange(rhs.parent_, nullptr)} {} </s> remove explicit Data() { pdata_.heap_ = 0; } </s> add explicit Data() { pdata_.heap_ = nullptr; }
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/small_vector.h
keep keep replace keep keep keep keep keep keep keep keep replace replace keep keep keep keep
<mask> return kHasInlineCapacity || detail::pointerFlagGet(pdata_.heap_); <mask> } <mask> InternalSizeType* getCapacity() { <mask> return pdata_.getCapacity(); <mask> } <mask> InternalSizeType* getCapacity() const { <mask> return const_cast<Data*>(this)->getCapacity(); <mask> } <mask> InternalSizeType* getCapacity() { <mask> return pdata_.getCapacity(); <mask> } <mask> InternalSizeType* getCapacity() const { <mask> return const_cast<Data*>(this)->getCapacity(); <mask> } <mask> <mask> void freeHeap() { <mask> auto vp = detail::pointerFlagClear(pdata_.heap_); </s> [sdk33] Update iOS with RN 0.59 </s> remove InternalSizeType* getCapacity() { return &capacity_; </s> add InternalSizeType getCapacity() const { return capacity_; </s> remove private: </s> add private: </s> remove return static_cast<InternalSizeType*>( detail::pointerFlagClear(heap_)); </s> add return *static_cast<InternalSizeType*>(detail::pointerFlagClear(heap_)); } void setCapacity(InternalSizeType c) { *static_cast<InternalSizeType*>(detail::pointerFlagClear(heap_)) = c; </s> remove InternalSizeType* getCapacity() { </s> add InternalSizeType getCapacity() const { </s> remove } FOLLY_PACK_ATTR; </s> add void setCapacity(InternalSizeType c) { capacity_ = c; } } FOLLY_SV_PACK_ATTR;
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/small_vector.h
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> void freeHeap() { <mask> auto vp = detail::pointerFlagClear(pdata_.heap_); <mask> free(vp); <mask> } <mask> } FOLLY_PACK_ATTR u; <mask> } FOLLY_PACK_ATTR; <mask> FOLLY_PACK_POP <mask> <mask> ////////////////////////////////////////////////////////////////////// <mask> <mask> // Basic guarantee only, or provides the nothrow guarantee iff T has a <mask> // nothrow move or copy constructor. </s> [sdk33] Update iOS with RN 0.59 </s> remove template<class T, std::size_t MaxInline, class A, class B, class C> void swap(small_vector<T,MaxInline,A,B,C>& a, small_vector<T,MaxInline,A,B,C>& b) { </s> add template <class T, std::size_t MaxInline, class A, class B, class C> void swap( small_vector<T, MaxInline, A, B, C>& a, small_vector<T, MaxInline, A, B, C>& b) { </s> remove InternalSizeType* getCapacity() const { return const_cast<Data*>(this)->getCapacity(); </s> add void setCapacity(InternalSizeType c) { pdata_.setCapacity(c); </s> remove // We want to make sure the same stuff is uninitialized memory // if we exit via an exception (this is to make sure we provide // the basic exception safety guarantee for insert functions). if (out < lastConstructed) { out = lastConstructed - 1; } for (auto it = out + 1; it != realLast; ++it) { it->~T(); } </s> add out[pos].~T(); </s> remove // move old elements to the left of the new one try { detail::moveToUninitialized(begin(), begin() + pos, newp); } catch (...) { newp[pos].~value_type(); free(newh); throw; } // move old elements to the right of the new one try { if (pos < size-1) { detail::moveToUninitialized(begin() + pos, end(), newp + pos + 1); } } catch (...) { for (size_type i = 0; i <= pos; ++i) { newp[i].~value_type(); } free(newh); throw; } } else { // move without inserting new element try { detail::moveToUninitialized(begin(), end(), newp); } catch (...) { free(newh); throw; </s> add try { if (insert) { // move and insert the new element this->moveToUninitializedEmplace( begin(), end(), newp, pos, std::forward<EmplaceFunc>(emplaceFunc)); } else { // move without inserting new element this->moveToUninitialized(begin(), end(), newp); </s> remove } FOLLY_PACK_ATTR; </s> add void setCapacity(InternalSizeType c) { capacity_ = c; } } FOLLY_SV_PACK_ATTR; </s> remove template<class T> typename std::enable_if< !FOLLY_IS_TRIVIALLY_COPYABLE(T) >::type moveObjectsRight(T* first, T* lastConstructed, T* realLast) { if (lastConstructed == realLast) { return; } T* end = first - 1; // Past the end going backwards. T* out = realLast - 1; T* in = lastConstructed - 1; </s> add template <class T, class EmplaceFunc> void moveToUninitializedEmplace( T* begin, T* end, T* out, SizeType pos, EmplaceFunc&& emplaceFunc) { // Must be called first so that if it throws [begin, end) is unmodified. // We have to support the strong exception guarantee for emplace_back(). emplaceFunc(out + pos); // move old elements to the left of the new one
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/small_vector.h
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> ////////////////////////////////////////////////////////////////////// <mask> <mask> // Basic guarantee only, or provides the nothrow guarantee iff T has a <mask> // nothrow move or copy constructor. <mask> template<class T, std::size_t MaxInline, class A, class B, class C> <mask> void swap(small_vector<T,MaxInline,A,B,C>& a, <mask> small_vector<T,MaxInline,A,B,C>& b) { <mask> a.swap(b); <mask> } <mask> <mask> ////////////////////////////////////////////////////////////////////// <mask> </s> [sdk33] Update iOS with RN 0.59 </s> remove } FOLLY_PACK_ATTR u; } FOLLY_PACK_ATTR; FOLLY_PACK_POP </s> add } u; }; FOLLY_SV_PACK_POP </s> remove template<class T, std::size_t M, class A, class B, class C> </s> add template <class T, std::size_t M, class A, class B, class C> </s> remove } // small_vector_policy </s> add } // namespace small_vector_policy </s> remove : public IndexableTraitsSeq<small_vector<T, M, A, B, C>> { }; </s> add : public IndexableTraitsSeq<small_vector<T, M, A, B, C>> {}; } // namespace detail </s> remove } </s> add } // namespace detail </s> remove template <typename T> constexpr T constexpr_max(T a, T b) { return a > b ? a : b; } template <typename T> constexpr T constexpr_min(T a, T b) { return a < b ? a : b; } </s> add
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/small_vector.h
keep keep replace replace keep replace keep keep
<mask> template <class T, size_t M, class A, class B, class C> <mask> struct IndexableTraits<small_vector<T, M, A, B, C>> <mask> : public IndexableTraitsSeq<small_vector<T, M, A, B, C>> { <mask> }; <mask> <mask> } // namespace detail <mask> <mask> } // namespace folly </s> [sdk33] Update iOS with RN 0.59 </s> remove template<class T, std::size_t M, class A, class B, class C> </s> add template <class T, std::size_t M, class A, class B, class C> </s> remove } // small_vector_policy </s> add } // namespace small_vector_policy </s> remove template<class T, std::size_t MaxInline, class A, class B, class C> void swap(small_vector<T,MaxInline,A,B,C>& a, small_vector<T,MaxInline,A,B,C>& b) { </s> add template <class T, std::size_t MaxInline, class A, class B, class C> void swap( small_vector<T, MaxInline, A, B, C>& a, small_vector<T, MaxInline, A, B, C>& b) { </s> remove #include <type_traits> #include <utility> namespace folly { enum class TLPDestructionMode { THIS_THREAD, ALL_THREADS }; struct AccessModeStrict {}; } // namespace </s> add </s> remove template<typename A, typename B> </s> add template <typename A, typename B>
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/small_vector.h
keep keep keep keep replace keep replace
<mask> }; <mask> <mask> } // namespace detail <mask> <mask> } // namespace folly <mask> <mask> #pragma GCC diagnostic pop </s> [sdk33] Update iOS with RN 0.59 </s> remove } // namespace detail </s> add } // namespace folly </s> remove #pragma GCC diagnostic pop </s> add FOLLY_POP_WARNING </s> remove } // namespace folly </s> add } // namespace folly </s> remove #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" </s> add FOLLY_PUSH_WARNING FOLLY_GNU_DISABLE_WARNING("-Wshadow") </s> remove #include <folly/detail/ExceptionWrapper.h> </s> add #include <folly/FBString.h> #include <folly/Portability.h> #include <folly/Traits.h> #include <folly/Utility.h> #include <folly/lang/Assume.h> #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wpotentially-evaluated-expression" // GCC gets confused about lambda scopes and issues shadow-local warnings for // parameters in totally different functions. FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS #endif #define FOLLY_EXCEPTION_WRAPPER_H_INCLUDED
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/small_vector.h
keep replace keep keep keep keep keep
<mask> /* <mask> * Copyright 2016 Facebook, Inc. <mask> * <mask> * Licensed under the Apache License, Version 2.0 (the "License"); <mask> * you may not use this file except in compliance with the License. <mask> * You may obtain a copy of the License at <mask> * </s> [sdk33] Update iOS with RN 0.59
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep keep keep keep replace keep keep keep keep keep
<mask> * and size() of the passed in vector-esque Container type. An <mask> * example growth policy that grows one element at a time: <mask> * <mask> * struct OneAtATimePolicy { <mask> * template<class Container> <mask> * void increase_capacity(Container& c) { <mask> * if (c.size() == c.capacity()) { <mask> * c.reserve(c.size() + 1); <mask> * } <mask> * } </s> [sdk33] Update iOS with RN 0.59 </s> remove // This wrapper goes around a GrowthPolicy and provides iterator // preservation semantics, but only if the growth policy is not the // default (i.e. nothing). template<class Policy> struct growth_policy_wrapper : private Policy { template<class Container, class Iterator> Iterator increase_capacity(Container& c, Iterator desired_insertion) { typedef typename Container::difference_type diff_t; diff_t d = desired_insertion - c.begin(); Policy::increase_capacity(c); return c.begin() + d; } }; template<> struct growth_policy_wrapper<void> { template<class Container, class Iterator> Iterator increase_capacity(Container&, Iterator it) { return it; } }; </s> add template <typename, typename Compare, typename Key, typename T> struct sorted_vector_enable_if_is_transparent {}; </s> remove makeSize(std::max(size_type(2), 3 * size() / 2), &t, size()); </s> add // Any of args may be references into the vector. // When we are reallocating, we have to be careful to construct the new // element before modifying the data in the old buffer. makeSize( size() + 1, [&](void* p) { new (p) value_type(std::forward<Args>(args)...); }, size()); </s> remove new (end()) value_type(std::move(t)); </s> add new (end()) value_type(std::forward<Args>(args)...); </s> remove void makeSize(size_type size, value_type* v, size_type pos) { if (size > this->max_size()) { </s> add template <typename EmplaceFunc> void makeSizeInternal( size_type newSize, bool insert, EmplaceFunc&& emplaceFunc, size_type pos) { if (newSize > max_size()) { </s> remove * NOTE: If reallocation is not needed, and new element should be * inserted in the middle of vector (not at the end), do the move * objects and insertion outside the function, otherwise exception is thrown. </s> add * NOTE: If reallocation is not needed, insert must be false, * because we only know how to emplace elements into new memory. </s> remove * The relationship between LockedGuardPtr and LockedPtr is similar to that * between std::lock_guard and std::unique_lock. </s> add * For example in the above rlock() produces an implementation defined read * locking helper instance and wlock() a write locking helper * * Subsequent arguments passed to these locking helpers, after the first, will * be passed by const-ref to the corresponding function on the synchronized * instance. This means that if the function accepts these parameters by * value, they will be copied. Note that it is not necessary that the primary * locking function will be invoked at all (for eg. the implementation might * just invoke the try*Lock() method) * * // Try to acquire the lock for one second * synchronized([](auto) { ... }, wlock(one, 1s)); * * // The timed lock acquire might never actually be called, if it is not * // needed by the underlying deadlock avoiding algorithm * synchronized([](auto, auto) { ... }, rlock(one), wlock(two, 1s)); * * Note that the arguments passed to to *lock() calls will be passed by * const-ref to the function invocation, as the implementation might use them * many times
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep keep keep keep replace keep keep keep keep keep
<mask> * OneAtATimePolicy> <mask> * OneAtATimeIntSet; <mask> * <mask> * Important differences from std::set and std::map: <mask> * - insert() and erase() invalidate iterators and references <mask> * - insert() and erase() are O(N) <mask> * - our iterators model RandomAccessIterator <mask> * - sorted_vector_map::value_type is pair<K,V>, not pair<const K,V>. <mask> * (This is basically because we want to store the value_type in <mask> * std::vector<>, which requires it to be Assignable.) </s> [sdk33] Update iOS with RN 0.59 </s> remove * \note `typename = ResultOf<Fun>` prevents this overload from being * selected by overload resolution when `fun` is not a compatible function. </s> add * \note `typename Traits::template ResultOf<Fun>` prevents this overload * from being selected by overload resolution when `fun` is not a compatible * function. * * \note The noexcept requires some explanation. `IsSmall` is true when the * decayed type fits within the internal buffer and is noexcept-movable. But * this ctor might copy, not move. What we need here, if this ctor does a * copy, is that this ctor be noexcept when the copy is noexcept. That is not * checked in `IsSmall`, and shouldn't be, because once the `Function` is * constructed, the contained object is never copied. This check is for this * ctor only, in the case that this ctor does a copy. </s> remove * Construct and inject a mock singleton which should be used only from tests. * Unlike regular singletons which are initialized once per process lifetime, * mock singletons live for the duration of a test. This means that one process * running multiple tests can initialize and register the same singleton * multiple times. This functionality should be used only from tests * since it relaxes validation and performance in order to be able to perform * the injection. The returned mock singleton is functionality identical to * regular singletons. */ static void make_mock(std::nullptr_t /* c */ = nullptr, typename Singleton<T>::TeardownFunc t = nullptr) { </s> add * Construct and inject a mock singleton which should be used only from tests. * Unlike regular singletons which are initialized once per process lifetime, * mock singletons live for the duration of a test. This means that one * process running multiple tests can initialize and register the same * singleton multiple times. This functionality should be used only from tests * since it relaxes validation and performance in order to be able to perform * the injection. The returned mock singleton is functionality identical to * regular singletons. */ static void make_mock( std::nullptr_t /* c */ = nullptr, typename Singleton<T>::TeardownFunc t = nullptr) { </s> remove * Ensure we have a large enough memory region to be size `size'. </s> add * Ensure we have a large enough memory region to be size `newSize'. </s> remove * Takes the difference between two sets of timespec values. The first * two come from a high-resolution clock whereas the other two come * from a low-resolution clock. The crux of the matter is that * high-res values may be bogus as documented in * http://linux.die.net/man/3/clock_gettime. The trouble is when the * running process migrates from one CPU to another, which is more * likely for long-running processes. Therefore we watch for high * differences between the two timings. * * This function is subject to further improvements. </s> add * Adds a benchmark wrapped in a std::function. Only used * internally. Pass by value is intentional. </s> remove * NOTE: If reallocation is not needed, and new element should be * inserted in the middle of vector (not at the end), do the move * objects and insertion outside the function, otherwise exception is thrown. </s> add * NOTE: If reallocation is not needed, insert must be false, * because we only know how to emplace elements into new memory. </s> remove * Move objects in memory to the right into some uninitialized * memory, where the region overlaps. This doesn't just use * std::move_backward because move_backward only works if all the * memory is initialized to type T already. </s> add * Move a range to a range of uninitialized memory. Assumes the * ranges don't overlap. Inserts an element at out + pos using * emplaceFunc(). out will contain (end - begin) + 1 elements on success and * none on failure. If emplaceFunc() throws [begin, end) is unmodified.
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep keep add keep keep keep keep
<mask> #pragma once <mask> <mask> #include <algorithm> <mask> #include <initializer_list> <mask> #include <iterator> <mask> #include <stdexcept> <mask> #include <type_traits> </s> [sdk33] Update iOS with RN 0.59 </s> remove #include <stdexcept> #include <cstdlib> #include <type_traits> </s> add </s> remove #include <iterator> </s> add </s> add #include <cstdlib> #include <cstring> #include <iterator> #include <stdexcept> #include <type_traits> #include <utility> </s> remove #include <boost/iterator/iterator_facade.hpp> </s> add #include <iterator> #include <type_traits> #include <utility> </s> add #include <folly/CPortability.h> </s> remove #include <folly/Hash.h> #include <folly/Memory.h> #include <folly/RWSpinLock.h> #include <folly/Demangle.h> </s> add
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep keep keep keep replace replace keep keep keep keep keep
<mask> #include <type_traits> <mask> #include <utility> <mask> #include <vector> <mask> <mask> #include <boost/operators.hpp> <mask> #include <folly/portability/BitsFunctexcept.h> <mask> <mask> namespace folly { <mask> <mask> ////////////////////////////////////////////////////////////////////// <mask> </s> [sdk33] Update iOS with RN 0.59 </s> remove #include <type_traits> #include <utility> namespace folly { enum class TLPDestructionMode { THIS_THREAD, ALL_THREADS }; struct AccessModeStrict {}; } // namespace </s> add </s> add #include <vector> </s> remove #include <vector> </s> add </s> add #include <folly/Traits.h> #include <folly/functional/Invoke.h> #include <folly/lang/Exception.h> </s> remove #include <boost/iterator/iterator_facade.hpp> </s> add #include <iterator> #include <type_traits> #include <utility> </s> add #include <boost/function_types/function_arity.hpp> #include <glog/logging.h>
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep
<mask> <mask> namespace detail { <mask> <mask> // This wrapper goes around a GrowthPolicy and provides iterator <mask> // preservation semantics, but only if the growth policy is not the <mask> // default (i.e. nothing). <mask> template<class Policy> <mask> struct growth_policy_wrapper : private Policy { <mask> template<class Container, class Iterator> <mask> Iterator increase_capacity(Container& c, Iterator desired_insertion) <mask> { <mask> typedef typename Container::difference_type diff_t; <mask> diff_t d = desired_insertion - c.begin(); <mask> Policy::increase_capacity(c); <mask> return c.begin() + d; <mask> } <mask> }; <mask> template<> <mask> struct growth_policy_wrapper<void> { <mask> template<class Container, class Iterator> <mask> Iterator increase_capacity(Container&, Iterator it) { <mask> return it; <mask> } <mask> }; <mask> <mask> /* <mask> * This helper returns the distance between two iterators if it is <mask> * possible to figure it out without messing up the range <mask> * (i.e. unless they are InputIterators). Otherwise this returns <mask> * -1. <mask> */ <mask> template<class Iterator> <mask> int distance_if_multipass(Iterator first, Iterator last) { <mask> typedef typename std::iterator_traits<Iterator>::iterator_category categ; <mask> if (std::is_same<categ,std::input_iterator_tag>::value) <mask> return -1; <mask> return std::distance(first, last); <mask> } <mask> <mask> template<class OurContainer, class Vector, class GrowthPolicy> <mask> typename OurContainer::iterator <mask> insert_with_hint(OurContainer& sorted, <mask> Vector& cont, <mask> typename OurContainer::iterator hint, <mask> typename OurContainer::value_type&& value, <mask> GrowthPolicy& po) <mask> { <mask> const typename OurContainer::value_compare& cmp(sorted.value_comp()); <mask> if (hint == cont.end() || cmp(value, *hint)) { <mask> if (hint == cont.begin()) { <mask> po.increase_capacity(cont, cont.begin()); <mask> return cont.insert(cont.begin(), std::move(value)); <mask> } <mask> if (cmp(*(hint - 1), value)) { <mask> hint = po.increase_capacity(cont, hint); <mask> return cont.insert(hint, std::move(value)); <mask> } <mask> return sorted.insert(std::move(value)).first; <mask> } </s> [sdk33] Update iOS with RN 0.59 </s> remove if (cmp(*hint, value)) { if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) { typename OurContainer::iterator it = po.increase_capacity(cont, hint + 1); return cont.insert(it, std::move(value)); } </s> add if (cmp(*hint, value)) { if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) { hint = po.increase_capacity(cont, hint + 1); return cont.insert(hint, std::move(value)); } else { return sorted.insert(std::move(value)).first; </s> add } </s> remove internalJoin(Delim delimiter, Iterator begin, Iterator end, String& output) { </s> add internalJoin(Delim delimiter, Iterator begin, Iterator end, String& output) { </s> remove typename std::enable_if<!IsSizableStringContainerIterator<Iterator>::value>::type internalJoin(Delim delimiter, Iterator begin, Iterator end, String& output) { </s> add typename std::enable_if< !IsSizableStringContainerIterator<Iterator>::value>::type internalJoin(Delim delimiter, Iterator begin, Iterator end, String& output) { </s> remove if (std::is_same<categ,std::input_iterator_tag>::value) { </s> add if (std::is_same<categ, std::input_iterator_tag>::value) {
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep keep add keep keep keep keep keep
<mask> } else { <mask> return sorted.insert(std::move(value)).first; <mask> } <mask> <mask> if (cmp(*hint, value)) { <mask> if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) { <mask> hint = po.increase_capacity(cont, hint + 1); <mask> return cont.insert(hint, std::move(value)); </s> [sdk33] Update iOS with RN 0.59 </s> remove if (cmp(*hint, value)) { if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) { typename OurContainer::iterator it = po.increase_capacity(cont, hint + 1); return cont.insert(it, std::move(value)); } </s> add if (cmp(*hint, value)) { if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) { hint = po.increase_capacity(cont, hint + 1); return cont.insert(hint, std::move(value)); } else { return sorted.insert(std::move(value)).first; </s> remove /* * This helper returns the distance between two iterators if it is * possible to figure it out without messing up the range * (i.e. unless they are InputIterators). Otherwise this returns * -1. */ template<class Iterator> int distance_if_multipass(Iterator first, Iterator last) { typedef typename std::iterator_traits<Iterator>::iterator_category categ; if (std::is_same<categ,std::input_iterator_tag>::value) return -1; return std::distance(first, last); } template<class OurContainer, class Vector, class GrowthPolicy> typename OurContainer::iterator insert_with_hint(OurContainer& sorted, Vector& cont, typename OurContainer::iterator hint, typename OurContainer::value_type&& value, GrowthPolicy& po) { const typename OurContainer::value_compare& cmp(sorted.value_comp()); if (hint == cont.end() || cmp(value, *hint)) { if (hint == cont.begin()) { po.increase_capacity(cont, cont.begin()); return cont.insert(cont.begin(), std::move(value)); } if (cmp(*(hint - 1), value)) { hint = po.increase_capacity(cont, hint); return cont.insert(hint, std::move(value)); } </s> add template <typename Compare, typename Key, typename T> struct sorted_vector_enable_if_is_transparent< void_t<typename Compare::is_transparent>, Compare, Key, T> { using type = T; }; // This wrapper goes around a GrowthPolicy and provides iterator // preservation semantics, but only if the growth policy is not the // default (i.e. nothing). template <class Policy> struct growth_policy_wrapper : private Policy { template <class Container, class Iterator> Iterator increase_capacity(Container& c, Iterator desired_insertion) { typedef typename Container::difference_type diff_t; diff_t d = desired_insertion - c.begin(); Policy::increase_capacity(c); return c.begin() + d; } }; template <> struct growth_policy_wrapper<void> { template <class Container, class Iterator> Iterator increase_capacity(Container&, Iterator it) { return it; } }; /* * This helper returns the distance between two iterators if it is * possible to figure it out without messing up the range * (i.e. unless they are InputIterators). Otherwise this returns * -1. */ template <class Iterator> int distance_if_multipass(Iterator first, Iterator last) { typedef typename std::iterator_traits<Iterator>::iterator_category categ; if (std::is_same<categ, std::input_iterator_tag>::value) { return -1; } return std::distance(first, last); } template <class OurContainer, class Vector, class GrowthPolicy> typename OurContainer::iterator insert_with_hint( OurContainer& sorted, Vector& cont, typename OurContainer::iterator hint, typename OurContainer::value_type&& value, GrowthPolicy& po) { const typename OurContainer::value_compare& cmp(sorted.value_comp()); if (hint == cont.end() || cmp(value, *hint)) { if (hint == cont.begin() || cmp(*(hint - 1), value)) { hint = po.increase_capacity(cont, hint); return cont.insert(hint, std::move(value)); } else { </s> remove // Value and *hint did not compare, so they are equal keys. return hint; </s> add </s> remove makeSize(size() + 1); detail::moveObjectsRight(data() + offset, data() + size(), data() + size() + 1); </s> add detail::moveObjectsRight( data() + offset, data() + size(), data() + size() + 1); </s> remove makeSize(size() + 1, &t, offset); </s> add makeSize( size() + 1, [&t](void* ptr) { new (ptr) value_type(std::move(t)); }, offset); </s> remove template <typename T> constexpr auto constexpr_abs(T t) -> decltype(detail::constexpr_abs_helper<T>::go(t)) { return detail::constexpr_abs_helper<T>::go(t); </s> add template <typename Char> constexpr int constexpr_strcmp_internal(const Char* s1, const Char* s2) { return (*s1 == '\0' || *s1 != *s2) ? (static_cast<int>(*s1 - *s2)) : constexpr_strcmp_internal(s1 + 1, s2 + 1);
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep replace replace replace replace replace replace keep replace replace replace
<mask> <mask> if (cmp(*hint, value)) { <mask> if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) { <mask> typename OurContainer::iterator it = <mask> po.increase_capacity(cont, hint + 1); <mask> return cont.insert(it, std::move(value)); <mask> } <mask> } <mask> <mask> // Value and *hint did not compare, so they are equal keys. <mask> return hint; </s> [sdk33] Update iOS with RN 0.59 </s> add } </s> remove /* * This helper returns the distance between two iterators if it is * possible to figure it out without messing up the range * (i.e. unless they are InputIterators). Otherwise this returns * -1. */ template<class Iterator> int distance_if_multipass(Iterator first, Iterator last) { typedef typename std::iterator_traits<Iterator>::iterator_category categ; if (std::is_same<categ,std::input_iterator_tag>::value) return -1; return std::distance(first, last); } template<class OurContainer, class Vector, class GrowthPolicy> typename OurContainer::iterator insert_with_hint(OurContainer& sorted, Vector& cont, typename OurContainer::iterator hint, typename OurContainer::value_type&& value, GrowthPolicy& po) { const typename OurContainer::value_compare& cmp(sorted.value_comp()); if (hint == cont.end() || cmp(value, *hint)) { if (hint == cont.begin()) { po.increase_capacity(cont, cont.begin()); return cont.insert(cont.begin(), std::move(value)); } if (cmp(*(hint - 1), value)) { hint = po.increase_capacity(cont, hint); return cont.insert(hint, std::move(value)); } </s> add template <typename Compare, typename Key, typename T> struct sorted_vector_enable_if_is_transparent< void_t<typename Compare::is_transparent>, Compare, Key, T> { using type = T; }; // This wrapper goes around a GrowthPolicy and provides iterator // preservation semantics, but only if the growth policy is not the // default (i.e. nothing). template <class Policy> struct growth_policy_wrapper : private Policy { template <class Container, class Iterator> Iterator increase_capacity(Container& c, Iterator desired_insertion) { typedef typename Container::difference_type diff_t; diff_t d = desired_insertion - c.begin(); Policy::increase_capacity(c); return c.begin() + d; } }; template <> struct growth_policy_wrapper<void> { template <class Container, class Iterator> Iterator increase_capacity(Container&, Iterator it) { return it; } }; /* * This helper returns the distance between two iterators if it is * possible to figure it out without messing up the range * (i.e. unless they are InputIterators). Otherwise this returns * -1. */ template <class Iterator> int distance_if_multipass(Iterator first, Iterator last) { typedef typename std::iterator_traits<Iterator>::iterator_category categ; if (std::is_same<categ, std::input_iterator_tag>::value) { return -1; } return std::distance(first, last); } template <class OurContainer, class Vector, class GrowthPolicy> typename OurContainer::iterator insert_with_hint( OurContainer& sorted, Vector& cont, typename OurContainer::iterator hint, typename OurContainer::value_type&& value, GrowthPolicy& po) { const typename OurContainer::value_compare& cmp(sorted.value_comp()); if (hint == cont.end() || cmp(value, *hint)) { if (hint == cont.begin() || cmp(*(hint - 1), value)) { hint = po.increase_capacity(cont, hint); return cont.insert(hint, std::move(value)); } else { </s> remove makeSize(size() + 1); detail::moveObjectsRight(data() + offset, data() + size(), data() + size() + 1); </s> add detail::moveObjectsRight( data() + offset, data() + size(), data() + size() + 1); </s> remove makeSize(size() + 1, &t, offset); </s> add makeSize( size() + 1, [&t](void* ptr) { new (ptr) value_type(std::move(t)); }, offset); </s> remove template <typename T> constexpr auto constexpr_abs(T t) -> decltype(detail::constexpr_abs_helper<T>::go(t)) { return detail::constexpr_abs_helper<T>::go(t); </s> add template <typename Char> constexpr int constexpr_strcmp_internal(const Char* s1, const Char* s2) { return (*s1 == '\0' || *s1 != *s2) ? (static_cast<int>(*s1 - *s2)) : constexpr_strcmp_internal(s1 + 1, s2 + 1);
https://github.com/expo/expo/commit/6de1d01531ce3e3388db436409963b83ec2f7911
ios/Pods/Folly/folly/sorted_vector_types.h
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> public class WebBrowserModule extends ReactContextBaseJavaModule { <mask> private final static String ERROR_CODE = "EXWebBrowser"; <mask> <mask> private @Nullable Promise mOpenBrowserPromise; <mask> <mask> public WebBrowserModule(ReactApplicationContext reactContext) { <mask> super(reactContext); <mask> } <mask> </s> [expo-web-browser] Extract WebBrowser API to a universal module (#3374) * [expo-web-browser] Generate universal module from template * [expo-web-browser] Move TS code to expo-web-browser * [expo-web-browser] Move iOS code to expo-web-browser * [expo-web-browser] Move Android code to expo-web-browser * [docs] Add a note about WebBrowser.dismissBrowser() not doing anything on Android * [jest-expo] Update mocks * [expo-facebook] WebBrowser moved to universal modules </s> remove import expolib_v1.com.facebook.infer.annotation.Assertions; </s> add </s> add <activity android:name="abi31_0_0.host.exp.exponent.modules.internal.ChromeTabsManagerActivity"> </activity>
https://github.com/expo/expo/commit/78142f84a3347bbede8f5ea36df30c598a9cc492
android/versioned-abis/expoview-abi30_0_0/src/main/java/abi30_0_0/host/exp/exponent/modules/api/WebBrowserModule.java
keep keep add keep keep keep
<mask> android:name="android.support.FILE_PROVIDER_PATHS" <mask> android:resource="@xml/provider_paths"/> <mask> </provider> <mask> </application> <mask> <mask> </manifest> </s> [expo-web-browser] Extract WebBrowser API to a universal module (#3374) * [expo-web-browser] Generate universal module from template * [expo-web-browser] Move TS code to expo-web-browser * [expo-web-browser] Move iOS code to expo-web-browser * [expo-web-browser] Move Android code to expo-web-browser * [docs] Add a note about WebBrowser.dismissBrowser() not doing anything on Android * [jest-expo] Update mocks * [expo-facebook] WebBrowser moved to universal modules </s> remove import expolib_v1.com.facebook.infer.annotation.Assertions; </s> add </s> remove private @Nullable Promise mOpenBrowserPromise; </s> add private @Nullable Promise mOpenBrowserPromise;
https://github.com/expo/expo/commit/78142f84a3347bbede8f5ea36df30c598a9cc492
android/versioned-abis/expoview-abi31_0_0/src/main/AndroidManifest.xml
keep keep keep keep replace keep keep keep keep keep
<mask> import android.net.Uri; <mask> import android.support.annotation.Nullable; <mask> import android.support.customtabs.CustomTabsIntent; <mask> <mask> import expolib_v1.com.facebook.infer.annotation.Assertions; <mask> import abi31_0_0.com.facebook.react.bridge.Arguments; <mask> import abi31_0_0.com.facebook.react.bridge.Promise; <mask> import abi31_0_0.com.facebook.react.bridge.ReactApplicationContext; <mask> import abi31_0_0.com.facebook.react.bridge.ReactContextBaseJavaModule; <mask> import abi31_0_0.com.facebook.react.bridge.ReactMethod; </s> [expo-web-browser] Extract WebBrowser API to a universal module (#3374) * [expo-web-browser] Generate universal module from template * [expo-web-browser] Move TS code to expo-web-browser * [expo-web-browser] Move iOS code to expo-web-browser * [expo-web-browser] Move Android code to expo-web-browser * [docs] Add a note about WebBrowser.dismissBrowser() not doing anything on Android * [jest-expo] Update mocks * [expo-facebook] WebBrowser moved to universal modules </s> add <activity android:name="abi31_0_0.host.exp.exponent.modules.internal.ChromeTabsManagerActivity"> </activity> </s> remove private @Nullable Promise mOpenBrowserPromise; </s> add private @Nullable Promise mOpenBrowserPromise;
https://github.com/expo/expo/commit/78142f84a3347bbede8f5ea36df30c598a9cc492
android/versioned-abis/expoview-abi31_0_0/src/main/java/abi31_0_0/host/exp/exponent/modules/api/WebBrowserModule.java
keep keep keep replace keep replace keep keep keep
<mask> SoLoader.loadLibrary("fb"); <mask> } <mask> <mask> // Private C++ instance <mask> @DoNotStrip <mask> private long mNativePointer = 0; <mask> <mask> /** <mask> * To explicitly delete the instance, call resetNative(). If the C++ </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public native void resetNative(); protected void finalize() throws Throwable { resetNative(); super.finalize(); </s> add public synchronized void resetNative() { mDestructor.destruct(); </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add </s> remove // be thrown, it aborts the program. This is a noexcept function at C++ level. FBEXPORT void translatePendingCppExceptionToJavaException() noexcept; </s> add // be thrown, it aborts the program. FBEXPORT void translatePendingCppExceptionToJavaException(); #ifndef FBJNI_NO_EXCEPTION_PTR FBEXPORT local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr); #endif FBEXPORT local_ref<JThrowable> getJavaExceptionForCppBackTrace(); </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove * @return true when border colors differs where two border sides meet (e.g. right and top border * colors differ) </s> add * Quickly determine if all the set border colors are equal. Bitwise AND all the set colors * together, then OR them all together. If the AND and the OR are the same, then the colors * are compatible, so return this color. * * Used to avoid expensive path creation and expensive calls to canvas.drawPath * * @return A compatible border color, or zero if the border colors are not compatible.
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/jni/HybridData.java
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> * not called, but timing of deletion and the thread the C++ dtor is called <mask> * on will be at the whim of the Java GC. If you want to control the thread <mask> * and timing of the destructor, you should call resetNative() explicitly. <mask> */ <mask> public native void resetNative(); <mask> <mask> protected void finalize() throws Throwable { <mask> resetNative(); <mask> super.finalize(); <mask> } <mask> <mask> public boolean isValid() { <mask> return mNativePointer != 0; <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private long mNativePointer = 0; </s> add private Destructor mDestructor = new Destructor(this); </s> remove // Private C++ instance </s> add </s> remove * @return true when border colors differs where two border sides meet (e.g. right and top border * colors differ) </s> add * Quickly determine if all the set border colors are equal. Bitwise AND all the set colors * together, then OR them all together. If the AND and the OR are the same, then the colors * are compatible, so return this color. * * Used to avoid expensive path creation and expensive calls to canvas.drawPath * * @return A compatible border color, or zero if the border colors are not compatible. </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add </s> add import com.facebook.react.common.DebugServerException; </s> add public BundleDownloader getBundleDownloader() { return mBundleDownloader; }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/jni/HybridData.java
keep keep keep add keep keep keep keep keep keep
<mask> mUseSeparateUIBackgroundThread = useSeparateUIBackgroundThread; <mask> return this; <mask> } <mask> <mask> /** <mask> * Instantiates a new {@link ReactInstanceManager}. <mask> * Before calling {@code build}, the following must be called: <mask> * <ul> <mask> * <li> {@link #setApplication} <mask> * <li> {@link #setCurrentActivity} if the activity has already resumed </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}. </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}. </s> remove import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; </s> add </s> add import com.facebook.react.common.DebugServerException; </s> remove private long mNativePointer = 0; </s> add private Destructor mDestructor = new Destructor(this); </s> remove * @return true when border colors differs where two border sides meet (e.g. right and top border * colors differ) </s> add * Quickly determine if all the set border colors are equal. Bitwise AND all the set colors * together, then OR them all together. If the AND and the OR are the same, then the colors * are compatible, so return this color. * * Used to avoid expensive path creation and expensive calls to canvas.drawPath * * @return A compatible border color, or zero if the border colors are not compatible.
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java
keep keep keep add keep keep keep keep keep keep
<mask> //number of shakes required to trigger onShake() <mask> private int mMinNumShakes; <mask> <mask> public ShakeDetector(ShakeListener listener) { <mask> mShakeListener = listener; <mask> mMinNumShakes = minNumShakes; <mask> } <mask> <mask> /** <mask> * Start listening for shakes. </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add mMinNumShakes = minNumShakes; </s> add public ReactInstanceManagerBuilder setMinNumShakes(int minNumShakes) { mMinNumShakes = minNumShakes; return this; } </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove final public class ReconnectingWebSocket implements WebSocketListener { </s> add final public class ReconnectingWebSocket extends WebSocketListener { </s> remove // Private C++ instance </s> add </s> remove private static final Matrix sMatrix = new Matrix(); private static final Matrix sInverse = new Matrix(); </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/common/ShakeDetector.java
keep add keep keep keep keep keep keep
<mask> public ShakeDetector(ShakeListener listener, int minNumShakes) { <mask> mShakeListener = listener; <mask> } <mask> <mask> /** <mask> * Start listening for shakes. <mask> */ <mask> public void start(SensorManager manager) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add this(listener, 1); } public ShakeDetector(ShakeListener listener, int minNumShakes) { </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}. </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}. </s> remove final public class ReconnectingWebSocket implements WebSocketListener { </s> add final public class ReconnectingWebSocket extends WebSocketListener { </s> add public ReactInstanceManagerBuilder setMinNumShakes(int minNumShakes) { mMinNumShakes = minNumShakes; return this; } </s> remove public class JSDebuggerWebSocketClient implements WebSocketListener { </s> add public class JSDebuggerWebSocketClient extends WebSocketListener {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/common/ShakeDetector.java
keep keep keep add keep keep keep keep
<mask> mCurrentIndex = 0; <mask> mMagnitudes = new double[MAX_SAMPLES]; <mask> mTimestamps = new long[MAX_SAMPLES]; <mask> mSensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_UI); <mask> } <mask> } <mask> <mask> /** </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove result[i] = new StackFrameImpl( matcher.group(2), matcher.group(1) == null ? "(unknown)" : matcher.group(1), Integer.parseInt(matcher.group(3)), Integer.parseInt(matcher.group(4))); </s> add result[i] = new StackFrameImpl( matcher.group(2), matcher.group(1) == null ? "(unknown)" : matcher.group(1), Integer.parseInt(matcher.group(3)), Integer.parseInt(matcher.group(4))); } </s> remove Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]); if (!matcher.find()) { throw new IllegalArgumentException( </s> add if (stackTrace[i].equals("[native code]")) { result[i] = new StackFrameImpl(null, stackTrace[i], -1, -1); } else { Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]); if (!matcher.find()) { throw new IllegalArgumentException( </s> remove mShakeListener.onShake(); </s> add if (currentTimestamp - mLastShakeTimestamp >= VISIBLE_TIME_RANGE_NS) { mNumShakes++; } mLastShakeTimestamp = currentTimestamp; if (mNumShakes >= mMinNumShakes) { mNumShakes = 0; mLastShakeTimestamp = 0; mShakeListener.onShake(); } } if (currentTimestamp - mLastShakeTimestamp > SHAKING_WINDOW_NS) { mNumShakes = 0; mLastShakeTimestamp = 0; </s> remove mPackagerClient = new JSPackagerClient("devserverhelper", mSettings.getPackagerConnectionSettings(), handlers); </s> add mPackagerClient = new JSPackagerClient(clientId, mSettings.getPackagerConnectionSettings(), handlers); </s> remove float totalFlexBasis = 0; </s> add float totalOuterFlexBasis = 0; </s> remove JSONObject message = new JSONObject(response.string()); </s> add JSONObject message = new JSONObject(text);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/common/ShakeDetector.java
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> @Override <mask> public void onSensorChanged(SensorEvent sensorEvent) { <mask> if (sensorEvent.timestamp - mLastTimestamp < MIN_TIME_BETWEEN_SAMPLES_MS) { <mask> return; <mask> } <mask> <mask> Assertions.assertNotNull(mTimestamps); <mask> Assertions.assertNotNull(mMagnitudes); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove if (currentTimestamp - mTimestamps[index] < VISIBLE_TIME_RANGE_MS) { </s> add if (currentTimestamp - mTimestamps[index] < VISIBLE_TIME_RANGE_NS) { </s> remove return mYogaNode.toString(); </s> add result .append(getLayoutWidth()) .append(",") .append(getLayoutHeight()); } else { result.append("(virtual node)"); } result.append("\n"); if (getChildCount() == 0) { return; </s> add @Override public void onCatalystInstanceDestroy() { super.onCatalystInstanceDestroy(); getReactApplicationContext().removeLifecycleEventListener(this); } </s> remove public synchronized void onPong(Buffer payload) { } </s> add public synchronized void onMessage(WebSocket webSocket, ByteString bytes) { if (mMessageCallback != null) { mMessageCallback.onMessage(bytes); } } </s> remove mMessageCallback.onMessage(message); </s> add mMessageCallback.onMessage(text); </s> remove handlePokeSamplingProfiler(responder); </s> add if (mCurrentContext == null) { responder.error("JSCContext is missing, unable to profile"); return; } try { long jsContext = mCurrentContext.getJavaScriptContext(); Class clazz = Class.forName("com.facebook.react.packagerconnection.SamplingProfilerPackagerMethod"); RequestHandler handler = (RequestHandler) clazz.getConstructor(long.class).newInstance(jsContext); handler.onRequest(null, responder); } catch (Exception e) { }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/common/ShakeDetector.java
keep keep keep keep replace keep keep keep keep keep
<mask> int numOverThreshold = 0; <mask> int total = 0; <mask> for (int i = 0; i < MAX_SAMPLES; i++) { <mask> int index = (mCurrentIndex - i + MAX_SAMPLES) % MAX_SAMPLES; <mask> if (currentTimestamp - mTimestamps[index] < VISIBLE_TIME_RANGE_MS) { <mask> total++; <mask> if (mMagnitudes[index] >= MAGNITUDE_THRESHOLD) { <mask> numOverThreshold++; <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove float totalFlexBasis = 0; </s> add float totalOuterFlexBasis = 0; </s> remove return getClass().getSimpleName() + " (virtual node)"; </s> add for (int i = 0; i < getChildCount(); i++) { getChildAt(i).toStringWithIndentation(result, level + 1); } </s> remove mShakeListener.onShake(); </s> add if (currentTimestamp - mLastShakeTimestamp >= VISIBLE_TIME_RANGE_NS) { mNumShakes++; } mLastShakeTimestamp = currentTimestamp; if (mNumShakes >= mMinNumShakes) { mNumShakes = 0; mLastShakeTimestamp = 0; mShakeListener.onShake(); } } if (currentTimestamp - mLastShakeTimestamp > SHAKING_WINDOW_NS) { mNumShakes = 0; mLastShakeTimestamp = 0; </s> remove marginAxisColumn)) { </s> add marginAxisColumn, config)) { </s> remove YGRoundValueToPixelGrid(absoluteNodeBottom, pointScaleFactor, hasMeasure, false) - YGRoundValueToPixelGrid(absoluteNodeTop, pointScaleFactor, false, hasMeasure); </s> add YGRoundValueToPixelGrid(absoluteNodeBottom, pointScaleFactor, textRounding, false) - YGRoundValueToPixelGrid(absoluteNodeTop, pointScaleFactor, false, textRounding); </s> add StringBuilder sb = new StringBuilder(); toStringWithIndentation(sb, 0); return sb.toString(); } private void toStringWithIndentation(StringBuilder result, int level) { // Spaces and tabs are dropped by IntelliJ logcat integration, so rely on __ instead. for (int i = 0; i < level; ++i) { result.append("__"); } result .append(getClass().getSimpleName()) .append(" ");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/common/ShakeDetector.java
keep keep keep keep replace keep keep keep
<mask> } <mask> } <mask> <mask> if (((double) numOverThreshold) / total > PERCENT_OVER_THRESHOLD_FOR_SHAKE / 100.0) { <mask> mShakeListener.onShake(); <mask> } <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove YGNodeAlignItem(node, child) == YGAlignFlexEnd) { </s> add ((YGNodeAlignItem(node, child) == YGAlignFlexEnd) ^ (node->style.flexWrap == YGWrapWrapReverse))) { </s> remove config->pointScaleFactor = 1.0f / pixelsInPoint; } } static float YGRoundValueToPixelGrid(const float value, const float pointScaleFactor, const bool forceCeil, const bool forceFloor) { float fractial = fmodf(value, pointScaleFactor); if (YGFloatsEqual(fractial, 0)) { // Still remove fractial as fractial could be extremely small. return value - fractial; } if (forceCeil) { return value - fractial + pointScaleFactor; } else if (forceFloor) { return value - fractial; } else { return value - fractial + (fractial >= pointScaleFactor / 2.0f ? pointScaleFactor : 0); </s> add config->pointScaleFactor = pixelsInPoint; </s> add // Root nodes flexGrow should always be 0 if (node->parent == NULL) { return 0.0; } </s> remove YGNodeTrailingPosition(child, crossAxis, width); </s> add YGNodeTrailingMargin(child, crossAxis, width) - YGNodeTrailingPosition(child, crossAxis, isMainAxisRow ? height : width); </s> remove boolean isDrawPathRequired = isBorderColorDifferentAtIntersectionPoints(); if (isDrawPathRequired && mPathForBorder == null) { mPathForBorder = new Path(); } </s> add // Check for fast path to border drawing. int fastBorderColor = fastBorderCompatibleColorOrZero( borderLeft, borderTop, borderRight, borderBottom, leftColor, topColor, rightColor, bottomColor); if (fastBorderColor != 0) { // Fast border color draw. if (Color.alpha(fastBorderColor) != 0) { // Border color is not transparent. // Draw center. if (Color.alpha(mBackgroundColor) != 0) { PAINT.setColor(mBackgroundColor); if (Color.alpha(fastBorderColor) == 255) { // The border will draw over the edges, so only draw the inset background. canvas.drawRect(leftInset, topInset, rightInset, bottomInset, PAINT); } else { // The border is opaque, so we have to draw the entire background color. canvas.drawRect(left, top, right, bottom, PAINT); } } PAINT.setColor(fastBorderColor); if (borderLeft > 0) { canvas.drawRect(left, top, leftInset, bottom - borderBottom, PAINT); } if (borderTop > 0) { canvas.drawRect(left + borderLeft, top, right, topInset, PAINT); } if (borderRight > 0) { canvas.drawRect(rightInset, top + borderTop, right, bottom, PAINT); } if (borderBottom > 0) { canvas.drawRect(left, bottomInset, right - borderRight, bottom, PAINT); } } } else { if (mPathForBorder == null) { mPathForBorder = new Path(); } </s> remove YGNodeTrailingPosition(child, mainAxis, width); </s> add YGNodeTrailingMargin(child, mainAxis, width) - YGNodeTrailingPosition(child, mainAxis, isMainAxisRow ? width : height);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/common/ShakeDetector.java
keep add keep keep
<mask> deps = [ <mask> react_native_dep("third-party/java/okhttp:okhttp3"), <mask> ], <mask> ) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove react_native_target("java/com/facebook/react/bridge:bridge"), </s> add </s> remove deps = [ react_native_target("jni/xreact/jni:jni"), ], </s> add xcode_public_headers_symlinks = True, deps = ([ "//native/third-party/android-ndk:android", "//xplat/folly:molly", "//xplat/fbgloginit:fbgloginit", "//xplat/fbsystrace:fbsystrace", react_native_xplat_target("cxxreact:bridge"), react_native_xplat_target("cxxreact:module"), FBJNI_TARGET, ] + JSC_DEPS) if not IS_OSS_BUILD else [], </s> remove def react_library(**kwargs): fb_apple_library( name = 'bridge', header_path_prefix = "cxxreact", inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS, frameworks = [ '$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework', ], tests = [ react_native_xplat_target('cxxreact/tests:tests') ], **kwargs_add( kwargs, preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS + INSPECTOR_FLAGS, deps = [ '//xplat/folly:molly', ], visibility = [ 'PUBLIC' ], ) ) cxx_library( </s> add rn_xplat_cxx_library( </s> remove exported_headers = [ "CxxModule.h", "JsArgumentHelpers.h", "JsArgumentHelpers-inl.h", </s> add exported_headers = subdir_glob( [ ("", "CxxModule.h"), ("", "JsArgumentHelpers.h"), ("", "JsArgumentHelpers-inl.h"), ], prefix = "cxxreact", ), force_static = True, header_namespace = "", visibility = [ "PUBLIC", ], xcode_public_headers_symlinks = True, deps = [ "//xplat/folly:molly", ], ) rn_xplat_cxx_library( name = "jsbigstring", srcs = [ "JSBigString.cpp", </s> add react_native_dep("java/com/facebook/jni:jni"), react_native_dep("java/com/facebook/proguard/annotations:annotations"), </s> remove header_namespace = "cxxreact", labels = ["accounts_for_platform_and_build_mode_flags"], </s> add header_namespace = "",
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/common/network/BUCK
keep keep keep keep replace keep keep keep keep keep
<mask> react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), <mask> react_native_dep("third-party/java/infer-annotations:infer-annotations"), <mask> react_native_dep("third-party/java/jsr-305:jsr-305"), <mask> react_native_dep("third-party/java/okhttp:okhttp3"), <mask> react_native_dep("third-party/java/okhttp:okhttp3-ws"), <mask> react_native_dep("third-party/java/okio:okio"), <mask> react_native_target("java/com/facebook/react/bridge:bridge"), <mask> react_native_target("java/com/facebook/react/common:common"), <mask> react_native_target("java/com/facebook/react/common/network:network"), <mask> react_native_target("java/com/facebook/react/devsupport:interfaces"), </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> add react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"), </s> add react_native_dep("third-party/java/okio:okio"), </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add react_native_dep("third-party/java/okio:okio"),
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK
keep keep keep keep replace replace keep keep keep keep keep
<mask> import java.util.List; <mask> import java.util.Locale; <mask> import java.util.Map; <mask> import java.util.concurrent.TimeUnit; <mask> import java.util.regex.Matcher; <mask> import java.util.regex.Pattern; <mask> import android.content.Context; <mask> import android.os.AsyncTask; <mask> import android.os.Handler; <mask> import com.facebook.common.logging.FLog; <mask> import com.facebook.infer.annotation.Assertions; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add import android.os.AsyncTask; </s> add import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; </s> remove import java.lang.IllegalStateException; import javax.annotation.Nullable; </s> add import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; </s> remove import com.facebook.yoga.YogaDirection; </s> add </s> remove import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import javax.annotation.Nullable; </s> add </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import java.net.URISyntaxException; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.concurrent.TimeUnit; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace replace keep keep keep keep keep
<mask> import okhttp3.Request; <mask> import okhttp3.RequestBody; <mask> import okhttp3.Response; <mask> import okhttp3.ResponseBody; <mask> import okio.Buffer; <mask> import okio.BufferedSource; <mask> import okio.Okio; <mask> import okio.Sink; <mask> <mask> /** <mask> * Helper class for all things about the debug server running in the engineer's host machine. </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; import okio.ByteString; </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import java.net.URISyntaxException; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.concurrent.TimeUnit; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> public static int LONG_POLL_FAILURE_DELAY_MS = 5000; <mask> <mask> public static int HTTP_CONNECT_TIMEOUT_MS = 5000; <mask> <mask> public interface BundleDownloadCallback { <mask> <mask> void onSuccess(); <mask> <mask> void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total); <mask> <mask> void onFailure(Exception cause); <mask> } <mask> <mask> public interface OnServerContentChangeListener { <mask> <mask> void onServerContentChanged(); <mask> } <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove void onMessage(ResponseBody message); </s> add void onMessage(String text); void onMessage(ByteString bytes); </s> remove @Nullable public Call mDownloadBundleFromURLCall; </s> add </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove final public class ReconnectingWebSocket implements WebSocketListener { </s> add final public class ReconnectingWebSocket extends WebSocketListener { </s> remove public void onMessage(ResponseBody response) throws IOException { if (response.contentType() != WebSocket.TEXT) { FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); return; } </s> add public void onMessage(WebSocket webSocket, String text) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep replace keep replace keep keep keep
<mask> <mask> void onCaptureHeapCommand(@Nullable final Responder responder); <mask> <mask> void onPokeSamplingProfilerCommand(@Nullable final Responder responder); <mask> } <mask> <mask> public interface SymbolicationListener { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onPokeSamplingProfilerCommand(@Nullable final Responder responder) { </s> add public void onPokeSamplingProfilerCommand(final Responder responder) { </s> remove handlePokeSamplingProfiler(responder); </s> add if (mCurrentContext == null) { responder.error("JSCContext is missing, unable to profile"); return; } try { long jsContext = mCurrentContext.getJavaScriptContext(); Class clazz = Class.forName("com.facebook.react.packagerconnection.SamplingProfilerPackagerMethod"); RequestHandler handler = (RequestHandler) clazz.getConstructor(long.class).newInstance(jsContext); handler.onRequest(null, responder); } catch (Exception e) { } </s> remove void onMessage(ResponseBody message); </s> add void onMessage(String text); void onMessage(ByteString bytes); </s> remove private void handlePokeSamplingProfiler(@Nullable final Responder responder) { </s> add private void handlePokeSamplingProfiler() { </s> remove final public class ReconnectingWebSocket implements WebSocketListener { </s> add final public class ReconnectingWebSocket extends WebSocketListener {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep add keep keep keep keep keep keep
<mask> public final OkHttpClient mClient; <mask> <mask> public final Handler mRestartOnChangePollingHandler; <mask> <mask> public boolean mOnChangePollingEnabled; <mask> <mask> @Nullable <mask> public JSPackagerClient mPackagerClient; <mask> <mask> @Nullable </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add private OkHttpClient mHttpClient; </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> remove @Nullable public Call mDownloadBundleFromURLCall; </s> add </s> remove boolean enableOnCreate) { </s> add boolean enableOnCreate, int minNumShakes) { </s> remove public interface BundleDownloadCallback { void onSuccess(); void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total); void onFailure(Exception cause); } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <mask> @Nullable <mask> public OnServerContentChangeListener mOnServerContentChangeListener; <mask> <mask> @Nullable <mask> public Call mDownloadBundleFromURLCall; <mask> <mask> public DevServerHelper(DevInternalSettings settings) { <mask> mSettings = settings; <mask> mClient = new OkHttpClient.Builder().connectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS).readTimeout(0, TimeUnit.MILLISECONDS).writeTimeout(0, TimeUnit.MILLISECONDS).build(); <mask> mRestartOnChangePollingHandler = new Handler(); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add mBundleDownloader = new BundleDownloader(mClient); </s> remove public void openPackagerConnection(final PackagerCommandListener commandListener) { </s> add public void openPackagerConnection(final String clientId, final PackagerCommandListener commandListener) { </s> remove public interface BundleDownloadCallback { void onSuccess(); void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total); void onFailure(Exception cause); } </s> add </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> add public final BundleDownloader mBundleDownloader;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep add keep keep keep keep keep keep
<mask> mSettings = settings; <mask> mClient = new OkHttpClient.Builder().connectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS).readTimeout(0, TimeUnit.MILLISECONDS).writeTimeout(0, TimeUnit.MILLISECONDS).build(); <mask> mRestartOnChangePollingHandler = new Handler(); <mask> } <mask> <mask> public void openPackagerConnection(final String clientId, final PackagerCommandListener commandListener) { <mask> if (mPackagerClient != null) { <mask> FLog.w(ReactConstants.TAG, "Packager connection already open, nooping."); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void openPackagerConnection(final PackagerCommandListener commandListener) { </s> add public void openPackagerConnection(final String clientId, final PackagerCommandListener commandListener) { </s> remove @Nullable public Call mDownloadBundleFromURLCall; </s> add </s> remove private void handleConnect(JSONObject payload) throws JSONException, IOException { </s> add private void handleConnect(JSONObject payload) throws JSONException { </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> remove private void handleWrappedEvent(JSONObject payload) throws JSONException, IOException { </s> add private void handleWrappedEvent(JSONObject payload) throws JSONException { </s> remove mAccessibilityManager = (AccessibilityManager) getReactApplicationContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); </s> add Context appContext = context.getApplicationContext(); mAccessibilityManager = (AccessibilityManager) appContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace keep keep keep keep keep
<mask> mClient = new OkHttpClient.Builder().connectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS).readTimeout(0, TimeUnit.MILLISECONDS).writeTimeout(0, TimeUnit.MILLISECONDS).build(); <mask> mRestartOnChangePollingHandler = new Handler(); <mask> } <mask> <mask> public void openPackagerConnection(final PackagerCommandListener commandListener) { <mask> if (mPackagerClient != null) { <mask> FLog.w(ReactConstants.TAG, "Packager connection already open, nooping."); <mask> return; <mask> } <mask> new AsyncTask<Void, Void, Void>() { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add mBundleDownloader = new BundleDownloader(mClient); </s> remove @Nullable public Call mDownloadBundleFromURLCall; </s> add </s> remove Map<String, RequestHandler> handlers = new HashMap<String, RequestHandler>(); </s> add Map<String, RequestHandler> handlers = new HashMap<>(); </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove public synchronized void sendMessage(RequestBody message) throws IOException { </s> add public synchronized void sendMessage(String message) throws IOException { if (mWebSocket != null) { mWebSocket.send(message); } else { throw new ClosedChannelException(); } } public synchronized void sendMessage(ByteString message) throws IOException { </s> remove mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException e) { </s> add mWebSocket.send(message); } catch (Exception e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace keep keep keep keep keep
<mask> new AsyncTask<Void, Void, Void>() { <mask> <mask> @Override <mask> protected Void doInBackground(Void... backgroundParams) { <mask> Map<String, RequestHandler> handlers = new HashMap<String, RequestHandler>(); <mask> handlers.put("reload", new NotificationOnlyHandler() { <mask> <mask> @Override <mask> public void onNotification(@Nullable Object params) { <mask> commandListener.onPackagerReloadCommand(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void openPackagerConnection(final PackagerCommandListener commandListener) { </s> add public void openPackagerConnection(final String clientId, final PackagerCommandListener commandListener) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove handleProxyMessage(new JSONObject(message.string())); } catch (JSONException e) { throw new IOException(e); } finally { message.close(); </s> add handleProxyMessage(new JSONObject(text)); } catch (Exception e) { throw new RuntimeException(e); </s> remove }); </s> add }, minNumShakes); </s> remove WebSocketCall.create(client, builder.build()).enqueue(new WebSocketListener() { </s> add client.newWebSocket(builder.build(), new WebSocketListener() { </s> remove handlePokeSamplingProfiler(null); </s> add handlePokeSamplingProfiler();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace keep keep keep keep keep
<mask> commandListener.onPokeSamplingProfilerCommand(responder); <mask> } <mask> }); <mask> handlers.putAll(new FileIoHandler().handlers()); <mask> mPackagerClient = new JSPackagerClient("devserverhelper", mSettings.getPackagerConnectionSettings(), handlers); <mask> mPackagerClient.init(); <mask> return null; <mask> } <mask> }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove public void onMessage(ResponseBody response) throws IOException { if (response.contentType() != WebSocket.TEXT) { FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); return; } </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove registerNatives("com/facebook/jni/HybridData", { makeNativeMethod("resetNative", resetNative), </s> add registerNatives("com/facebook/jni/HybridData$Destructor", { makeNativeMethod("deleteNative", deleteNative),
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep add keep keep keep keep keep keep
<mask> return String.format(Locale.US, INSPECTOR_DEVICE_URL_FORMAT, mSettings.getPackagerConnectionSettings().getDebugServerHost(), AndroidInfoHelpers.getFriendlyDeviceName()); <mask> } <mask> <mask> /** <mask> * @return the host to use when connecting to the bundle server from the host itself. <mask> */ <mask> /** <mask> * @return the host to use when connecting to the bundle server from the host itself. <mask> */ </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove import okio.Buffer; import okio.BufferedSource; </s> add </s> remove * @return true when border colors differs where two border sides meet (e.g. right and top border * colors differ) </s> add * Quickly determine if all the set border colors are equal. Bitwise AND all the set colors * together, then OR them all together. If the AND and the OR are the same, then the colors * are compatible, so return this color. * * Used to avoid expensive path creation and expensive calls to canvas.drawPath * * @return A compatible border color, or zero if the border colors are not compatible. </s> add import com.facebook.react.common.DebugServerException; </s> remove public native void resetNative(); protected void finalize() throws Throwable { resetNative(); super.finalize(); </s> add public synchronized void resetNative() { mDestructor.destruct(); </s> remove static auto android_sdk = ([] { char sdk_version_str[PROP_VALUE_MAX]; __system_property_get("ro.build.version.sdk", sdk_version_str); return atoi(sdk_version_str); })(); static auto is_bad_android = android_sdk == 23; </s> add static auto is_bad_android = build::Build::getAndroidSdk() == 23;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace replace keep keep keep keep keep
<mask> */ <mask> /** <mask> * @return the host to use when connecting to the bundle server from the host itself. <mask> */ <mask> private static String getHostForJSProxy() { <mask> return AndroidInfoHelpers.DEVICE_LOCALHOST; <mask> } <mask> <mask> /** <mask> * @return whether we should enable dev mode when requesting JS bundles. <mask> */ </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add public BundleDownloader getBundleDownloader() { return mBundleDownloader; } </s> remove * @return true when border colors differs where two border sides meet (e.g. right and top border * colors differ) </s> add * Quickly determine if all the set border colors are equal. Bitwise AND all the set colors * together, then OR them all together. If the AND and the OR are the same, then the colors * are compatible, so return this color. * * Used to avoid expensive path creation and expensive calls to canvas.drawPath * * @return A compatible border color, or zero if the border colors are not compatible. </s> remove import okio.Buffer; import okio.BufferedSource; </s> add </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}. </s> remove private static final Matrix sMatrix = new Matrix(); private static final Matrix sInverse = new Matrix(); </s> add </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}.
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> public String getDevServerBundleURL(final String jsModulePath) { <mask> return createBundleURL(mSettings.getPackagerConnectionSettings().getDebugServerHost(), jsModulePath, getDevMode(), getHMR(), getJSMinifyMode()); <mask> } <mask> <mask> public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { <mask> final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); <mask> mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); <mask> mDownloadBundleFromURLCall.enqueue(new Callback() { <mask> <mask> @Override <mask> public void onFailure(Call call, IOException e) { <mask> // ignore callback if call was cancelled <mask> if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { <mask> mDownloadBundleFromURLCall = null; <mask> return; <mask> } <mask> mDownloadBundleFromURLCall = null; <mask> callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); <mask> } <mask> <mask> @Override <mask> public void onResponse(Call call, final Response response) throws IOException { <mask> // ignore callback if call was cancelled <mask> if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { <mask> mDownloadBundleFromURLCall = null; <mask> return; <mask> } <mask> mDownloadBundleFromURLCall = null; <mask> final String url = response.request().url().toString(); <mask> // Make sure the result is a multipart response and parse the boundary. <mask> String contentType = response.header("content-type"); <mask> Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); <mask> Matcher match = regex.matcher(contentType); <mask> if (match.find()) { <mask> String boundary = match.group(1); <mask> MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); <mask> boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { <mask> <mask> @Override <mask> public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { <mask> // encoded as JSON. <mask> if (finished) { <mask> // The http status code for each separate chunk is in the X-Http-Status header. <mask> int status = response.code(); <mask> if (headers.containsKey("X-Http-Status")) { <mask> status = Integer.parseInt(headers.get("X-Http-Status")); <mask> } <mask> processBundleResult(url, status, body, outputFile, callback); <mask> } else { <mask> if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { <mask> return; <mask> } <mask> try { <mask> JSONObject progress = new JSONObject(body.readUtf8()); <mask> String status = null; <mask> if (progress.has("status")) { <mask> status = progress.getString("status"); <mask> } <mask> Integer done = null; <mask> if (progress.has("done")) { <mask> done = progress.getInt("done"); <mask> } <mask> Integer total = null; <mask> if (progress.has("total")) { <mask> total = progress.getInt("total"); <mask> } <mask> callback.onProgress(status, done, total); <mask> } catch (JSONException e) { <mask> FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); <mask> } <mask> } <mask> } <mask> }); <mask> if (!completed) { <mask> callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); <mask> } <mask> } else { <mask> /** <mask> * In case the server doesn't support multipart/mixed responses, <mask> * fallback to normal download. <mask> */ <mask> processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); <mask> } <mask> } <mask> }); <mask> } <mask> <mask> private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { <mask> // Check for server errors. If the server error has the expected form, fail with more info. <mask> if (statusCode != 200) { <mask> String bodyString = body.readUtf8(); <mask> DebugServerException debugServerException = DebugServerException.parse(bodyString); <mask> if (debugServerException != null) { <mask> callback.onFailure(debugServerException); <mask> } else { <mask> StringBuilder sb = new StringBuilder(); <mask> sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); <mask> callback.onFailure(new DebugServerException(sb.toString())); <mask> } <mask> return; <mask> } <mask> Sink output = null; <mask> try { <mask> output = Okio.sink(outputFile); <mask> body.readAll(output); <mask> callback.onSuccess(); <mask> } finally { <mask> if (output != null) { <mask> output.close(); <mask> } <mask> } <mask> } <mask> <mask> public void cancelDownloadBundleFromURL() { <mask> if (mDownloadBundleFromURLCall != null) { <mask> mDownloadBundleFromURLCall.cancel(); <mask> mDownloadBundleFromURLCall = null; <mask> } <mask> } <mask> <mask> public void isPackagerRunning(final PackagerStatusCallback callback) { <mask> String statusURL = createPackagerStatusURL(mSettings.getPackagerConnectionSettings().getDebugServerHost()); <mask> Request request = new Request.Builder().url(statusURL).build(); <mask> mClient.newCall(request).enqueue(new Callback() { <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onMessage(ResponseBody response) throws IOException { if (response.contentType() != WebSocket.TEXT) { FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); return; } </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove public void onMessage(ResponseBody response) throws IOException { String message; try { if (response.contentType() == WebSocket.BINARY) { message = Base64.encodeToString(response.source().readByteArray(), Base64.NO_WRAP); } else { message = response.source().readUtf8(); } } catch (IOException e) { notifyWebSocketFailed(id, e.getMessage()); return; } try { response.source().close(); } catch (IOException e) { FLog.e( ReactConstants.TAG, "Could not close BufferedSource for WebSocket id " + id, e); } </s> add public void onMessage(WebSocket webSocket, ByteString bytes) { String text = bytes.utf8(); </s> remove private void handleConnect(JSONObject payload) throws JSONException, IOException { </s> add private void handleConnect(JSONObject payload) throws JSONException { </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public void onMessage(ResponseBody response) { if (response.contentType() != WebSocket.TEXT) { FLog.w( TAG, "Websocket received message with payload of unexpected type " + response.contentType()); return; } </s> add public void onMessage(String text) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
keep add keep keep keep keep keep keep
<mask> <mask> import com.facebook.react.R; <mask> <mask> /** <mask> * Activity that display developers settings. Should be added to the debug manifest of the app. Can <mask> * be triggered through the developers option menu displayed by {@link DevSupportManager}. <mask> */ <mask> public class DevSettingsActivity extends PreferenceActivity { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; </s> add </s> add public ReactInstanceManagerBuilder setMinNumShakes(int minNumShakes) { mMinNumShakes = minNumShakes; return this; } </s> remove import okio.Buffer; import okio.BufferedSource; </s> add </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}. </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}. </s> remove public native void resetNative(); protected void finalize() throws Throwable { resetNative(); super.finalize(); </s> add public synchronized void resetNative() { mDestructor.destruct();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSettingsActivity.java
keep keep keep keep replace keep keep keep keep keep
<mask> public static DevSupportManager create( <mask> Context applicationContext, <mask> ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, <mask> @Nullable String packagerPathForJSBundleName, <mask> boolean enableOnCreate) { <mask> <mask> return create( <mask> applicationContext, <mask> reactInstanceCommandsHandler, <mask> packagerPathForJSBundleName, </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove null); </s> add null, minNumShakes); </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove @Nullable RedBoxHandler redBoxHandler) { </s> add @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove RedBoxHandler.class); </s> add RedBoxHandler.class, int.class); </s> remove redBoxHandler); </s> add redBoxHandler, minNumShakes);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.java
keep keep keep keep replace keep keep keep keep keep
<mask> applicationContext, <mask> reactInstanceCommandsHandler, <mask> packagerPathForJSBundleName, <mask> enableOnCreate, <mask> null); <mask> } <mask> <mask> public static DevSupportManager create( <mask> Context applicationContext, <mask> ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove boolean enableOnCreate) { </s> add boolean enableOnCreate, int minNumShakes) { </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove @Nullable RedBoxHandler redBoxHandler) { </s> add @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove RedBoxHandler.class); </s> add RedBoxHandler.class, int.class); </s> remove redBoxHandler); </s> add redBoxHandler, minNumShakes);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.java
keep keep keep keep replace keep keep keep keep keep
<mask> Context applicationContext, <mask> ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, <mask> @Nullable String packagerPathForJSBundleName, <mask> boolean enableOnCreate, <mask> @Nullable RedBoxHandler redBoxHandler) { <mask> if (!enableOnCreate) { <mask> return new DisabledDevSupportManager(); <mask> } <mask> try { <mask> // ProGuard is surprisingly smart in this case and will keep a class if it detects a call to </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove boolean enableOnCreate) { </s> add boolean enableOnCreate, int minNumShakes) { </s> remove null); </s> add null, minNumShakes); </s> remove static jniType toJniRet(global_ref<jniType> t) { </s> add static jniType toJniRet(global_ref<jniType>&& t) { // If this gets called, ownership the global_ref was passed in here. (It's // probably a copy of a persistent global_ref made when a function was // declared to return a global_ref, but it could moved out or otherwise not // referenced elsewhere. Doesn't matter.) Either way, the only safe way // to return it is to make a local_ref, release it, and return the // underlying local jobject. auto ret = make_local(t); return ret.release(); } static jniType toJniRet(const global_ref<jniType>& t) { // If this gets called, the function was declared to return const&. We // have a ref to a global_ref whose lifetime will exceed this call, so we // can just get the underlying jobject and return it to java without // needing to make a local_ref. </s> remove throw; </s> add std::rethrow_exception(ptr);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.java
keep keep keep keep replace keep keep keep keep keep
<mask> Context.class, <mask> ReactInstanceDevCommandsHandler.class, <mask> String.class, <mask> boolean.class, <mask> RedBoxHandler.class); <mask> return (DevSupportManager) constructor.newInstance( <mask> applicationContext, <mask> reactInstanceCommandsHandler, <mask> packagerPathForJSBundleName, <mask> true, </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> remove boolean enableOnCreate) { </s> add boolean enableOnCreate, int minNumShakes) { </s> remove null); </s> add null, minNumShakes); </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove redBoxHandler); </s> add redBoxHandler, minNumShakes); </s> remove @Nullable RedBoxHandler redBoxHandler) { </s> add @Nullable RedBoxHandler redBoxHandler, int minNumShakes) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.java
keep keep keep keep replace keep keep keep keep keep
<mask> applicationContext, <mask> reactInstanceCommandsHandler, <mask> packagerPathForJSBundleName, <mask> true, <mask> redBoxHandler); <mask> } catch (Exception e) { <mask> throw new RuntimeException( <mask> "Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found" + <mask> " or could not be created", <mask> e); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException | IllegalStateException e) { </s> add client.send(message); } catch (Exception e) { </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, int minNumShakes) { this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null, minNumShakes); </s> remove client.sendMessage( RequestBody.create(WebSocket.BINARY, ByteString.decodeBase64(base64String))); } catch (IOException | IllegalStateException e) { </s> add client.send(ByteString.decodeBase64(base64String)); } catch (Exception e) { </s> remove public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { </s> add public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove RedBoxHandler.class); </s> add RedBoxHandler.class, int.class); </s> remove Buffer buffer = new Buffer(); client.sendPing(buffer); } catch (IOException | IllegalStateException e) { </s> add client.send(ByteString.EMPTY); } catch (Exception e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.java
keep add keep keep keep keep
<mask> package com.facebook.react.devsupport; <mask> <mask> import android.app.ActivityManager; <mask> import android.app.AlertDialog; <mask> import android.content.BroadcastReceiver; <mask> import android.content.Context; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import java.util.regex.Matcher; import java.util.regex.Pattern; </s> add </s> remove import android.util.Base64; </s> add import javax.annotation.Nullable; </s> remove import java.util.regex.Matcher; import java.util.regex.Pattern; </s> add </s> add import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; </s> remove import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import javax.annotation.Nullable; </s> add </s> remove import java.lang.IllegalStateException; import javax.annotation.Nullable; </s> add import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep add keep keep keep keep keep
<mask> import com.facebook.react.bridge.ReactContext; <mask> import com.facebook.react.bridge.ReadableArray; <mask> import com.facebook.react.bridge.UiThreadUtil; <mask> import com.facebook.react.common.ReactConstants; <mask> import com.facebook.react.common.ShakeDetector; <mask> import com.facebook.react.common.futures.SimpleSettableFuture; <mask> import com.facebook.react.devsupport.DevServerHelper.PackagerCommandListener; <mask> import com.facebook.react.devsupport.interfaces.DevOptionHandler; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import com.facebook.react.uimanager.FloatUtil; </s> add import com.facebook.react.common.build.ReactBuildConfig; </s> remove import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableType; import com.facebook.react.devsupport.interfaces.DevSupportManager; </s> add </s> add import com.facebook.react.devsupport.interfaces.DevSupportManager; </s> remove import java.lang.IllegalStateException; import javax.annotation.Nullable; </s> add import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; </s> add import android.webkit.CookieManager; </s> remove import java.util.regex.Matcher; import java.util.regex.Pattern; </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep keep replace keep replace replace replace replace replace replace replace replace replace replace replace keep keep
<mask> import com.facebook.react.devsupport.interfaces.PackagerStatusCallback; <mask> import com.facebook.react.devsupport.interfaces.StackFrame; <mask> import com.facebook.react.modules.debug.interfaces.DeveloperSettings; <mask> import com.facebook.react.packagerconnection.JSPackagerClient; <mask> import com.facebook.react.packagerconnection.Responder; <mask> import java.io.File; <mask> import java.io.IOException; <mask> import java.net.MalformedURLException; <mask> import java.net.URL; <mask> import java.util.LinkedHashMap; <mask> import java.util.List; <mask> import java.util.Locale; <mask> import java.util.concurrent.ExecutionException; <mask> import java.util.concurrent.TimeUnit; <mask> import java.util.concurrent.TimeoutException; <mask> import javax.annotation.Nullable; <mask> import okhttp3.MediaType; <mask> import okhttp3.OkHttpClient; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; </s> remove import java.lang.IllegalStateException; import javax.annotation.Nullable; </s> add import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; </s> remove import java.util.regex.Matcher; import java.util.regex.Pattern; </s> add </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import java.net.URISyntaxException; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.concurrent.TimeUnit; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> add import java.io.StringReader;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep keep keep replace replace keep keep replace keep
<mask> return null; <mask> } <mask> } <mask> <mask> public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { <mask> this(applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); <mask> } <mask> <mask> public DevSupportManagerImpl(Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate, @Nullable RedBoxHandler redBoxHandler) { <mask> mReactInstanceCommandsHandler = reactInstanceCommandsHandler; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove boolean enableOnCreate) { </s> add boolean enableOnCreate, int minNumShakes) { </s> remove @Nullable RedBoxHandler redBoxHandler) { </s> add @Nullable RedBoxHandler redBoxHandler, int minNumShakes) { </s> remove null); </s> add null, minNumShakes); </s> remove RedBoxHandler.class); </s> add RedBoxHandler.class, int.class); </s> remove redBoxHandler); </s> add redBoxHandler, minNumShakes);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Override <mask> public void onShake() { <mask> showDevOptionsDialog(); <mask> } <mask> }); <mask> // Prepare reload APP broadcast receiver (will be registered/unregistered from #reload) <mask> mReloadAppBroadcastReceiver = new BroadcastReceiver() { <mask> <mask> @Override <mask> public void onReceive(Context context, Intent intent) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onPokeSamplingProfilerCommand(@Nullable final Responder responder) { </s> add public void onPokeSamplingProfilerCommand(final Responder responder) { </s> remove handlePokeSamplingProfiler(null); </s> add handlePokeSamplingProfiler(); </s> remove url.startsWith("file://")) { </s> add url.startsWith("file://") || url.equals("about:blank")) { </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public void onPong(Buffer payload) { } @Override public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> add @Override public void onCatalystInstanceDestroy() { super.onCatalystInstanceDestroy(); getReactApplicationContext().removeLifecycleEventListener(this); }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep keep keep replace keep keep keep keep keep
<mask> options.put(mApplicationContext.getString(R.string.catalyst_poke_sampling_profiler), new DevOptionHandler() { <mask> <mask> @Override <mask> public void onOptionSelected() { <mask> handlePokeSamplingProfiler(null); <mask> } <mask> }); <mask> ; <mask> if (mCustomDevOptions.size() > 0) { <mask> options.putAll(mCustomDevOptions); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onPokeSamplingProfilerCommand(@Nullable final Responder responder) { </s> add public void onPokeSamplingProfilerCommand(final Responder responder) { </s> remove }); </s> add }, minNumShakes); </s> remove handleProxyMessage(new JSONObject(message.string())); } catch (JSONException e) { throw new IOException(e); } finally { message.close(); </s> add handleProxyMessage(new JSONObject(text)); } catch (Exception e) { throw new RuntimeException(e); </s> remove boolean isDrawPathRequired = isBorderColorDifferentAtIntersectionPoints(); if (isDrawPathRequired && mPathForBorder == null) { mPathForBorder = new Path(); } </s> add // Check for fast path to border drawing. int fastBorderColor = fastBorderCompatibleColorOrZero( borderLeft, borderTop, borderRight, borderBottom, leftColor, topColor, rightColor, bottomColor); if (fastBorderColor != 0) { // Fast border color draw. if (Color.alpha(fastBorderColor) != 0) { // Border color is not transparent. // Draw center. if (Color.alpha(mBackgroundColor) != 0) { PAINT.setColor(mBackgroundColor); if (Color.alpha(fastBorderColor) == 255) { // The border will draw over the edges, so only draw the inset background. canvas.drawRect(leftInset, topInset, rightInset, bottomInset, PAINT); } else { // The border is opaque, so we have to draw the entire background color. canvas.drawRect(left, top, right, bottom, PAINT); } } PAINT.setColor(fastBorderColor); if (borderLeft > 0) { canvas.drawRect(left, top, leftInset, bottom - borderBottom, PAINT); } if (borderTop > 0) { canvas.drawRect(left + borderLeft, top, right, topInset, PAINT); } if (borderRight > 0) { canvas.drawRect(rightInset, top + borderTop, right, bottom, PAINT); } if (borderBottom > 0) { canvas.drawRect(left, bottomInset, right - borderRight, bottom, PAINT); } } } else { if (mPathForBorder == null) { mPathForBorder = new Path(); } </s> remove handlePokeSamplingProfiler(responder); </s> add if (mCurrentContext == null) { responder.error("JSCContext is missing, unable to profile"); return; } try { long jsContext = mCurrentContext.getJavaScriptContext(); Class clazz = Class.forName("com.facebook.react.packagerconnection.SamplingProfilerPackagerMethod"); RequestHandler handler = (RequestHandler) clazz.getConstructor(long.class).newInstance(jsContext); handler.onRequest(null, responder); } catch (Exception e) { } </s> remove public void onMessage(ResponseBody message) throws IOException { </s> add public void onMessage(WebSocket webSocket, String text) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep replace keep keep keep keep replace keep keep
<mask> @Override <mask> public void onPokeSamplingProfilerCommand(@Nullable final Responder responder) { <mask> UiThreadUtil.runOnUiThread(new Runnable() { <mask> <mask> @Override <mask> public void run() { <mask> handlePokeSamplingProfiler(responder); <mask> } <mask> }); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove void onCaptureHeapCommand(@Nullable final Responder responder); </s> add void onCaptureHeapCommand(final Responder responder); </s> remove void onPokeSamplingProfilerCommand(@Nullable final Responder responder); </s> add void onPokeSamplingProfilerCommand(final Responder responder); </s> remove private void handlePokeSamplingProfiler(@Nullable final Responder responder) { </s> add private void handlePokeSamplingProfiler() { </s> remove }); </s> add }, minNumShakes); </s> remove handlePokeSamplingProfiler(null); </s> add handlePokeSamplingProfiler();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep replace keep keep keep keep replace replace replace replace replace replace replace replace keep keep
<mask> } <mask> <mask> private void handlePokeSamplingProfiler(@Nullable final Responder responder) { <mask> try { <mask> List<String> pokeResults = JSCSamplingProfiler.poke(60000); <mask> for (String result : pokeResults) { <mask> Toast.makeText(mCurrentContext, result == null ? "Started JSC Sampling Profiler" : "Stopped JSC Sampling Profiler", Toast.LENGTH_LONG).show(); <mask> if (responder != null) { <mask> // Responder is provided, so there is a client waiting our response <mask> responder.respond(result == null ? "started" : result); <mask> } else if (result != null) { <mask> // The profile was not initiated by external client, so process the <mask> // profile if there is one in the result <mask> new JscProfileTask(getSourceUrl()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, result); <mask> } <mask> } <mask> } catch (JSCSamplingProfiler.ProfilerException e) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add JNIEnv* env; // We should be able to just get the JNIEnv* by just calling // AttachCurrentThread, but the spec is unclear (and using getEnv is probably // generally more reliable). auto result = getEnv(&env); // We don't know how to deal with anything other than JNI_OK or JNI_DETACHED. FBASSERT(result == JNI_OK || result == JNI_EDETACHED); if (result == JNI_EDETACHED) { // The thread should not be detached while a ThreadScope is in the stack. FBASSERT(!scope); env = attachCurrentThread(); } FBASSERT(env); </s> remove handlePokeSamplingProfiler(responder); </s> add if (mCurrentContext == null) { responder.error("JSCContext is missing, unable to profile"); return; } try { long jsContext = mCurrentContext.getJavaScriptContext(); Class clazz = Class.forName("com.facebook.react.packagerconnection.SamplingProfilerPackagerMethod"); RequestHandler handler = (RequestHandler) clazz.getConstructor(long.class).newInstance(jsContext); handler.onRequest(null, responder); } catch (Exception e) { } </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> add StringBuilder sb = new StringBuilder(); toStringWithIndentation(sb, 0); return sb.toString(); } private void toStringWithIndentation(StringBuilder result, int level) { // Spaces and tabs are dropped by IntelliJ logcat integration, so rely on __ instead. for (int i = 0; i < level; ++i) { result.append("__"); } result .append(getClass().getSimpleName()) .append(" "); </s> remove boolean isDrawPathRequired = isBorderColorDifferentAtIntersectionPoints(); if (isDrawPathRequired && mPathForBorder == null) { mPathForBorder = new Path(); } </s> add // Check for fast path to border drawing. int fastBorderColor = fastBorderCompatibleColorOrZero( borderLeft, borderTop, borderRight, borderBottom, leftColor, topColor, rightColor, bottomColor); if (fastBorderColor != 0) { // Fast border color draw. if (Color.alpha(fastBorderColor) != 0) { // Border color is not transparent. // Draw center. if (Color.alpha(mBackgroundColor) != 0) { PAINT.setColor(mBackgroundColor); if (Color.alpha(fastBorderColor) == 255) { // The border will draw over the edges, so only draw the inset background. canvas.drawRect(leftInset, topInset, rightInset, bottomInset, PAINT); } else { // The border is opaque, so we have to draw the entire background color. canvas.drawRect(left, top, right, bottom, PAINT); } } PAINT.setColor(fastBorderColor); if (borderLeft > 0) { canvas.drawRect(left, top, leftInset, bottom - borderBottom, PAINT); } if (borderTop > 0) { canvas.drawRect(left + borderLeft, top, right, topInset, PAINT); } if (borderRight > 0) { canvas.drawRect(rightInset, top + borderTop, right, bottom, PAINT); } if (borderBottom > 0) { canvas.drawRect(left, bottomInset, right - borderRight, bottom, PAINT); } } } else { if (mPathForBorder == null) { mPathForBorder = new Path(); }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> public void reloadJSFromServer(final String bundleURL) { <mask> mDevLoadingViewController.showForUrl(bundleURL); <mask> mDevLoadingViewVisible = true; <mask> mDevServerHelper.downloadBundleFromURL(new DevServerHelper.BundleDownloadCallback() { <mask> <mask> @Override <mask> public void onSuccess() { <mask> mDevLoadingViewController.hide(); <mask> mDevLoadingViewVisible = false; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public void onPong(Buffer payload) { } @Override public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public synchronized void onClose(int code, String reason) { </s> add public synchronized void onClosed(WebSocket webSocket, int code, String reason) { </s> remove url.startsWith("file://")) { </s> add url.startsWith("file://") || url.equals("about:blank")) { </s> remove public void onPong(Buffer buffer) { </s> add public void onMessage(WebSocket webSocket, String text) { WritableMap params = Arguments.createMap(); params.putInt("id", id); params.putString("data", text); params.putString("type", "text"); sendEvent("websocketMessage", params); </s> remove public synchronized void onPong(Buffer payload) { } </s> add public synchronized void onMessage(WebSocket webSocket, ByteString bytes) { if (mMessageCallback != null) { mMessageCallback.onMessage(bytes); } }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep keep keep keep replace keep keep keep keep keep
<mask> // show the dev loading if it should be <mask> if (mDevLoadingViewVisible) { <mask> mDevLoadingViewController.show(); <mask> } <mask> mDevServerHelper.openPackagerConnection(this); <mask> mDevServerHelper.openInspectorConnection(); <mask> if (mDevSettings.isReloadOnJSChangeEnabled()) { <mask> mDevServerHelper.startPollingOnChangeEndpoint(new DevServerHelper.OnServerContentChangeListener() { <mask> <mask> @Override </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add // Root nodes flexGrow should always be 0 if (node->parent == NULL) { return 0.0; } </s> add auto& storage = scopeStorage(); // ThreadScopes should be destroyed in the reverse order they are created // (that is, just put them on the stack). FBASSERT(this == storage.get()); storage.reset(previous_); </s> add // Root nodes flexShrink should always be 0 if (node->parent == NULL) { return 0.0; } </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove env = facebook::jni::Environment::ensureCurrentThreadIsAttached(); FBASSERT(env); </s> add // Check if the thread is attached by someone else. auto result = getEnv(&env); if (result == JNI_OK) { return; } // We don't know how to deal with anything other than JNI_OK or JNI_DETACHED. FBASSERT(result == JNI_EDETACHED); // If there's already a ThreadScope on the stack, then the thread should be attached. FBASSERT(!previous_); attachCurrentThread(); </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
keep add keep keep keep keep keep
<mask> import java.util.concurrent.TimeUnit; <mask> <mask> import android.os.Handler; <mask> import android.os.Looper; <mask> <mask> import com.facebook.common.logging.FLog; <mask> import com.facebook.react.bridge.Inspector; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import java.util.regex.Matcher; import java.util.regex.Pattern; </s> add </s> remove import java.lang.IllegalStateException; import javax.annotation.Nullable; </s> add import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; </s> remove import okhttp3.RequestBody; </s> add </s> add import java.io.StringReader; </s> add import android.webkit.CookieManager; </s> remove import okhttp3.RequestBody; </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep replace keep replace replace replace replace replace keep keep keep keep
<mask> import okhttp3.OkHttpClient; <mask> import okhttp3.Request; <mask> import okhttp3.RequestBody; <mask> import okhttp3.Response; <mask> import okhttp3.ResponseBody; <mask> import okhttp3.ws.WebSocket; <mask> import okhttp3.ws.WebSocketCall; <mask> import okhttp3.ws.WebSocketListener; <mask> import okio.Buffer; <mask> import org.json.JSONArray; <mask> import org.json.JSONException; <mask> import org.json.JSONObject; <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; import okio.ByteString; </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> public void sendOpenEvent(String pageId) { <mask> try { <mask> JSONObject payload = makePageIdPayload(pageId); <mask> sendEvent("open", payload); <mask> } catch (JSONException | IOException e) { <mask> FLog.e(TAG, "Failed to open page", e); <mask> } <mask> } <mask> <mask> void handleProxyMessage(JSONObject message) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) { </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) { </s> remove public void onMessage(ResponseBody message) throws IOException { </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove handleProxyMessage(new JSONObject(message.string())); } catch (JSONException e) { throw new IOException(e); } finally { message.close(); </s> add handleProxyMessage(new JSONObject(text)); } catch (Exception e) { throw new RuntimeException(e); </s> remove private void sendWrappedEvent(String pageId, String message) throws IOException, JSONException { </s> add private void sendWrappedEvent(String pageId, String message) throws JSONException { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> mInspectorConnections.clear(); <mask> } <mask> <mask> private void handleConnect(JSONObject payload) throws JSONException, IOException { <mask> final String pageId = payload.getString("pageId"); <mask> Inspector.LocalConnection inspectorConnection = mInspectorConnections.remove(pageId); <mask> if (inspectorConnection != null) { <mask> throw new IllegalStateException("Already connected: " + pageId); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private void handleWrappedEvent(JSONObject payload) throws JSONException, IOException { </s> add private void handleWrappedEvent(JSONObject payload) throws JSONException { </s> remove throws JSONException, IOException { </s> add throws JSONException { </s> remove public synchronized void sendMessage(RequestBody message) throws IOException { </s> add public synchronized void sendMessage(String message) throws IOException { if (mWebSocket != null) { mWebSocket.send(message); } else { throw new ClosedChannelException(); } } public synchronized void sendMessage(ByteString message) throws IOException { </s> remove public void onMessage(ResponseBody response) throws IOException { if (response.contentType() != WebSocket.TEXT) { FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); return; } </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove mWebSocket.sendMessage(message); </s> add mWebSocket.send(message); </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Override <mask> public void onMessage(String message) { <mask> try { <mask> sendWrappedEvent(pageId, message); <mask> } catch (IOException | JSONException e) { <mask> FLog.w(TAG, "Couldn't send event to packager", e); <mask> } <mask> } <mask> <mask> @Override </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove } catch (JSONException | IOException e) { </s> add } catch (JSONException e) { </s> remove Buffer buffer = new Buffer(); client.sendPing(buffer); } catch (IOException | IllegalStateException e) { </s> add client.send(ByteString.EMPTY); } catch (Exception e) { </s> remove handleProxyMessage(new JSONObject(message.string())); } catch (JSONException e) { throw new IOException(e); } finally { message.close(); </s> add handleProxyMessage(new JSONObject(text)); } catch (Exception e) { throw new RuntimeException(e); </s> remove public void onMessage(ResponseBody response) throws IOException { String message; try { if (response.contentType() == WebSocket.BINARY) { message = Base64.encodeToString(response.source().readByteArray(), Base64.NO_WRAP); } else { message = response.source().readUtf8(); } } catch (IOException e) { notifyWebSocketFailed(id, e.getMessage()); return; } try { response.source().close(); } catch (IOException e) { FLog.e( ReactConstants.TAG, "Could not close BufferedSource for WebSocket id " + id, e); } </s> add public void onMessage(WebSocket webSocket, ByteString bytes) { String text = bytes.utf8();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> public void onDisconnect() { <mask> try { <mask> mInspectorConnections.remove(pageId); <mask> sendEvent("disconnect", makePageIdPayload(pageId)); <mask> } catch (IOException | JSONException e) { <mask> FLog.w(TAG, "Couldn't send event to packager", e); <mask> } <mask> } <mask> }); <mask> mInspectorConnections.put(pageId, inspectorConnection); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove } catch (JSONException | IOException e) { </s> add } catch (JSONException e) { </s> remove client.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException | IllegalStateException e) { </s> add client.send(message); } catch (Exception e) { </s> remove client.sendMessage( RequestBody.create(WebSocket.BINARY, ByteString.decodeBase64(base64String))); } catch (IOException | IllegalStateException e) { </s> add client.send(ByteString.decodeBase64(base64String)); } catch (Exception e) { </s> remove Buffer buffer = new Buffer(); client.sendPing(buffer); } catch (IOException | IllegalStateException e) { </s> add client.send(ByteString.EMPTY); } catch (Exception e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> inspectorConnection.disconnect(); <mask> } <mask> <mask> private void handleWrappedEvent(JSONObject payload) throws JSONException, IOException { <mask> final String pageId = payload.getString("pageId"); <mask> String wrappedEvent = payload.getString("wrappedEvent"); <mask> Inspector.LocalConnection inspectorConnection = mInspectorConnections.get(pageId); <mask> if (inspectorConnection == null) { <mask> throw new IllegalStateException("Not connected: " + pageId); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private void handleConnect(JSONObject payload) throws JSONException, IOException { </s> add private void handleConnect(JSONObject payload) throws JSONException { </s> remove throws JSONException, IOException { </s> add throws JSONException { </s> remove private void sendWrappedEvent(String pageId, String message) throws IOException, JSONException { </s> add private void sendWrappedEvent(String pageId, String message) throws JSONException { </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> remove public void onMessage(ResponseBody response) throws IOException { if (response.contentType() != WebSocket.TEXT) { FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); return; } </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove public void onMessage(ResponseBody response) throws IOException { String message; try { if (response.contentType() == WebSocket.BINARY) { message = Base64.encodeToString(response.source().readByteArray(), Base64.NO_WRAP); } else { message = response.source().readUtf8(); } } catch (IOException e) { notifyWebSocketFailed(id, e.getMessage()); return; } try { response.source().close(); } catch (IOException e) { FLog.e( ReactConstants.TAG, "Could not close BufferedSource for WebSocket id " + id, e); } </s> add public void onMessage(WebSocket webSocket, ByteString bytes) { String text = bytes.utf8();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> return array; <mask> } <mask> <mask> private void sendWrappedEvent(String pageId, String message) throws IOException, JSONException { <mask> JSONObject payload = new JSONObject(); <mask> payload.put("pageId", pageId); <mask> payload.put("wrappedEvent", message); <mask> sendEvent("wrappedEvent", payload); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove throws JSONException, IOException { </s> add throws JSONException { </s> remove private void handleConnect(JSONObject payload) throws JSONException, IOException { </s> add private void handleConnect(JSONObject payload) throws JSONException { </s> remove } catch (JSONException | IOException e) { </s> add } catch (JSONException e) { </s> remove private void handleWrappedEvent(JSONObject payload) throws JSONException, IOException { </s> add private void handleWrappedEvent(JSONObject payload) throws JSONException { </s> remove private class Connection implements WebSocketListener { </s> add private class Connection extends WebSocketListener { </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> sendEvent("wrappedEvent", payload); <mask> } <mask> <mask> private void sendEvent(String name, Object payload) <mask> throws JSONException, IOException { <mask> JSONObject jsonMessage = new JSONObject(); <mask> jsonMessage.put("event", name); <mask> jsonMessage.put("payload", payload); <mask> mConnection.send(jsonMessage); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private void sendWrappedEvent(String pageId, String message) throws IOException, JSONException { </s> add private void sendWrappedEvent(String pageId, String message) throws JSONException { </s> remove private void handleConnect(JSONObject payload) throws JSONException, IOException { </s> add private void handleConnect(JSONObject payload) throws JSONException { </s> remove private void handleWrappedEvent(JSONObject payload) throws JSONException, IOException { </s> add private void handleWrappedEvent(JSONObject payload) throws JSONException { </s> remove } catch (JSONException | IOException e) { </s> add } catch (JSONException e) { </s> remove JSONObject message = new JSONObject(response.string()); </s> add JSONObject message = new JSONObject(text); </s> remove handleProxyMessage(new JSONObject(message.string())); } catch (JSONException e) { throw new IOException(e); } finally { message.close(); </s> add handleProxyMessage(new JSONObject(text)); } catch (Exception e) { throw new RuntimeException(e);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> payload.put("pageId", pageId); <mask> return payload; <mask> } <mask> <mask> private class Connection implements WebSocketListener { <mask> private static final int RECONNECT_DELAY_MS = 2000; <mask> <mask> private final String mUrl; <mask> <mask> private @Nullable WebSocket mWebSocket; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add private OkHttpClient mHttpClient; </s> remove final public class ReconnectingWebSocket implements WebSocketListener { </s> add final public class ReconnectingWebSocket extends WebSocketListener { </s> remove public class JSDebuggerWebSocketClient implements WebSocketListener { </s> add public class JSDebuggerWebSocketClient extends WebSocketListener { </s> remove void onMessage(ResponseBody message); </s> add void onMessage(String text); void onMessage(ByteString bytes); </s> remove private void sendWrappedEvent(String pageId, String message) throws IOException, JSONException { </s> add private void sendWrappedEvent(String pageId, String message) throws JSONException { </s> remove private float mContentWidth; private float mContentHeight; </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep add keep keep keep keep
<mask> private static final int RECONNECT_DELAY_MS = 2000; <mask> <mask> private final String mUrl; <mask> <mask> private @Nullable WebSocket mWebSocket; <mask> private final Handler mHandler; <mask> private boolean mClosed; <mask> private boolean mSuppressConnectionErrors; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private class Connection implements WebSocketListener { </s> add private class Connection extends WebSocketListener { </s> remove private String mConnectivity = ""; </s> add private String mConnectivity = CONNECTION_TYPE_UNKNOWN; </s> remove final public class ReconnectingWebSocket implements WebSocketListener { </s> add final public class ReconnectingWebSocket extends WebSocketListener { </s> add // ~0 == 0xFFFFFFFF, all bits set to 1. private static final int ALL_BITS_SET = ~0; // 0 == 0x00000000, all bits set to 0. private static final int ALL_BITS_UNSET = 0; </s> remove private float mContentWidth; private float mContentHeight; </s> add </s> add // ~0 == 0xFFFFFFFF, all bits set to 1. private static final int ALL_BITS_SET = ~0; // 0 == 0x00000000, all bits set to 0. private static final int ALL_BITS_UNSET = 0;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep replace keep replace keep keep keep
<mask> <mask> @Override <mask> public void onFailure(IOException e, Response response) { <mask> if (mWebSocket != null) { <mask> abort("Websocket exception", e); <mask> } <mask> if (!mClosed) { <mask> reconnect(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove abort("Websocket exception", e); </s> add abort("Websocket exception", t); </s> remove public synchronized void onFailure(IOException e, Response response) { </s> add public synchronized void onFailure(WebSocket webSocket, Throwable t, Response response) { </s> remove public void onFailure(IOException e, Response response) { abort("Websocket exception", e); </s> add public void onFailure(WebSocket webSocket, Throwable t, Response response) { abort("Websocket exception", t); </s> remove } finally { response.close(); </s> add </s> remove public void onFailure(IOException e, Response response) { notifyWebSocketFailed(id, e.getMessage()); </s> add public void onFailure(WebSocket webSocket, Throwable t, Response response) { notifyWebSocketFailed(id, t.getMessage());
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep replace keep replace replace replace replace replace keep
<mask> <mask> @Override <mask> public void onMessage(ResponseBody message) throws IOException { <mask> try { <mask> handleProxyMessage(new JSONObject(message.string())); <mask> } catch (JSONException e) { <mask> throw new IOException(e); <mask> } finally { <mask> message.close(); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (JSONException | IOException e) { </s> add } catch (JSONException e) { </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) { </s> remove public synchronized void sendMessage(RequestBody message) throws IOException { </s> add public synchronized void sendMessage(String message) throws IOException { if (mWebSocket != null) { mWebSocket.send(message); } else { throw new ClosedChannelException(); } } public synchronized void sendMessage(ByteString message) throws IOException { </s> remove mWebSocket.sendMessage(message); </s> add mWebSocket.send(message); </s> remove public void onMessage(ResponseBody response) throws IOException { String message; try { if (response.contentType() == WebSocket.BINARY) { message = Base64.encodeToString(response.source().readByteArray(), Base64.NO_WRAP); } else { message = response.source().readUtf8(); } } catch (IOException e) { notifyWebSocketFailed(id, e.getMessage()); return; } try { response.source().close(); } catch (IOException e) { FLog.e( ReactConstants.TAG, "Could not close BufferedSource for WebSocket id " + id, e); } </s> add public void onMessage(WebSocket webSocket, ByteString bytes) { String text = bytes.utf8();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> } <mask> } <mask> <mask> @Override <mask> public void onPong(Buffer payload) { <mask> } <mask> <mask> @Override <mask> public void onClose(int code, String reason) { <mask> mWebSocket = null; <mask> closeAllConnections(); <mask> if (!mClosed) { <mask> reconnect(); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public synchronized void onClose(int code, String reason) { </s> add public synchronized void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public synchronized void onPong(Buffer payload) { } </s> add public synchronized void onMessage(WebSocket webSocket, ByteString bytes) { if (mMessageCallback != null) { mMessageCallback.onMessage(bytes); } } </s> remove @Override public void onPong(Buffer payload) { // ignore } </s> add </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public void onFailure(IOException e, Response response) { </s> add public void onFailure(WebSocket webSocket, Throwable t, Response response) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace replace replace replace replace keep keep replace replace
<mask> public void connect() { <mask> if (mClosed) { <mask> throw new IllegalStateException("Can't connect closed client"); <mask> } <mask> OkHttpClient httpClient = new OkHttpClient.Builder() <mask> .connectTimeout(10, TimeUnit.SECONDS) <mask> .writeTimeout(10, TimeUnit.SECONDS) <mask> .readTimeout(0, TimeUnit.MINUTES) // Disable timeouts for read <mask> .build(); <mask> <mask> Request request = new Request.Builder().url(mUrl).build(); <mask> WebSocketCall call = WebSocketCall.create(httpClient, request); <mask> call.enqueue(this); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove WebSocketCall call = WebSocketCall.create(httpClient, request); call.enqueue(this); </s> add httpClient.newWebSocket(request, this); </s> remove WebSocketCall call = WebSocketCall.create(mHttpClient, request); call.enqueue(this); </s> add mHttpClient.newWebSocket(request, this); </s> remove Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]); if (!matcher.find()) { throw new IllegalArgumentException( </s> add if (stackTrace[i].equals("[native code]")) { result[i] = new StackFrameImpl(null, stackTrace[i], -1, -1); } else { Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]); if (!matcher.find()) { throw new IllegalArgumentException( </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> add mBundleDownloader = new BundleDownloader(mClient);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> mClosed = true; <mask> if (mWebSocket != null) { <mask> try { <mask> mWebSocket.close(1000, "End of session"); <mask> } catch (IOException e) { <mask> // swallow, no need to handle it here <mask> } <mask> mWebSocket = null; <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException e) { </s> add mWebSocket.send(message); } catch (Exception e) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> mWebSocket = null; <mask> } <mask> } <mask> <mask> public void send(JSONObject object) throws IOException { <mask> if (mWebSocket == null) { <mask> return; <mask> } <mask> <mask> mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); <mask> } <mask> <mask> private void abort(String message, Throwable cause) { <mask> FLog.e(TAG, "Error occurred, shutting down websocket connection: " + message, cause); <mask> closeAllConnections(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove @Override public void onPong(Buffer payload) { // ignore } </s> add </s> remove public synchronized void sendMessage(RequestBody message) throws IOException { </s> add public synchronized void sendMessage(String message) throws IOException { if (mWebSocket != null) { mWebSocket.send(message); } else { throw new ClosedChannelException(); } } public synchronized void sendMessage(ByteString message) throws IOException { </s> remove mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException e) { </s> add mWebSocket.send(message); } catch (Exception e) { </s> remove public void onMessage(ResponseBody response) throws IOException { if (response.contentType() != WebSocket.TEXT) { FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); return; } </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove private void handleConnect(JSONObject payload) throws JSONException, IOException { </s> add private void handleConnect(JSONObject payload) throws JSONException { </s> remove public void onPong(Buffer payload) { } @Override public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep keep replace keep keep keep keep keep
<mask> private void closeWebSocketQuietly() { <mask> if (mWebSocket != null) { <mask> try { <mask> mWebSocket.close(1000, "End of session"); <mask> } catch (IOException e) { <mask> // swallow, no need to handle it here <mask> } <mask> mWebSocket = null; <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException e) { </s> add mWebSocket.send(message); } catch (Exception e) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java
keep keep keep add keep keep keep keep
<mask> import com.facebook.infer.annotation.Assertions; <mask> import com.facebook.react.common.JavascriptException; <mask> <mask> import java.io.IOException; <mask> import java.io.StringWriter; <mask> import java.util.HashMap; <mask> import java.util.concurrent.ConcurrentHashMap; <mask> import java.util.concurrent.TimeUnit; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import java.lang.IllegalStateException; import javax.annotation.Nullable; </s> add import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; </s> remove import java.util.regex.Matcher; import java.util.regex.Pattern; </s> add </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; </s> add import okio.ByteString; </s> add import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; </s> remove import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import javax.annotation.Nullable; </s> add </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import java.net.URISyntaxException; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.concurrent.TimeUnit; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep replace keep replace replace replace replace replace keep keep keep
<mask> import okhttp3.Request; <mask> import okhttp3.RequestBody; <mask> import okhttp3.Response; <mask> import okhttp3.ResponseBody; <mask> import okhttp3.ws.WebSocket; <mask> import okhttp3.ws.WebSocketCall; <mask> import okhttp3.ws.WebSocketListener; <mask> import okio.Buffer; <mask> <mask> /** <mask> * A wrapper around WebSocketClient that recognizes RN debugging message format. </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; import okio.ByteString; </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> /** <mask> * A wrapper around WebSocketClient that recognizes RN debugging message format. <mask> */ <mask> public class JSDebuggerWebSocketClient implements WebSocketListener { <mask> <mask> private static final String TAG = "JSDebuggerWebSocketClient"; <mask> <mask> public interface JSDebuggerCallback { <mask> void onSuccess(@Nullable String response); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove final public class ReconnectingWebSocket implements WebSocketListener { </s> add final public class ReconnectingWebSocket extends WebSocketListener { </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; import okio.ByteString; </s> remove private class Connection implements WebSocketListener { </s> add private class Connection extends WebSocketListener { </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove public static Pattern mJsModuleIdPattern = Pattern.compile("(?:^|[/\\\\])(\\d+\\.js)$"); </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep keep replace replace keep keep keep keep keep
<mask> .readTimeout(0, TimeUnit.MINUTES) // Disable timeouts for read <mask> .build(); <mask> <mask> Request request = new Request.Builder().url(url).build(); <mask> WebSocketCall call = WebSocketCall.create(mHttpClient, request); <mask> call.enqueue(this); <mask> } <mask> <mask> public void prepareJSRuntime(JSDebuggerCallback callback) { <mask> int requestID = mRequestID.getAndIncrement(); <mask> mCallbacks.put(requestID, callback); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove WebSocketCall call = WebSocketCall.create(httpClient, request); call.enqueue(this); </s> add mHttpClient.newWebSocket(request, this); </s> remove OkHttpClient httpClient = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) .writeTimeout(10, TimeUnit.SECONDS) .readTimeout(0, TimeUnit.MINUTES) // Disable timeouts for read .build(); </s> add if (mHttpClient == null) { mHttpClient = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) .writeTimeout(10, TimeUnit.SECONDS) .readTimeout(0, TimeUnit.MINUTES) // Disable timeouts for read .build(); } </s> remove WebSocketCall call = WebSocketCall.create(httpClient, request); call.enqueue(this); </s> add httpClient.newWebSocket(request, this); </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> add mMinNumShakes = minNumShakes; </s> add this(listener, 1); } public ShakeDetector(ShakeListener listener, int minNumShakes) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep keep replace keep keep keep keep keep
<mask> public void closeQuietly() { <mask> if (mWebSocket != null) { <mask> try { <mask> mWebSocket.close(1000, "End of session"); <mask> } catch (IOException e) { <mask> // swallow, no need to handle it here <mask> } <mask> mWebSocket = null; <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException e) { </s> add mWebSocket.send(message); } catch (Exception e) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep keep replace replace keep keep keep keep keep
<mask> new IllegalStateException("WebSocket connection no longer valid")); <mask> return; <mask> } <mask> try { <mask> mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message)); <mask> } catch (IOException e) { <mask> triggerRequestFailure(requestID, e); <mask> } <mask> } <mask> <mask> private void triggerRequestFailure(int requestID, Throwable cause) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove client.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException | IllegalStateException e) { </s> add client.send(message); } catch (Exception e) { </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> } <mask> } <mask> <mask> @Override <mask> public void onMessage(ResponseBody response) throws IOException { <mask> if (response.contentType() != WebSocket.TEXT) { <mask> FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); <mask> return; <mask> } <mask> <mask> Integer replyID = null; <mask> <mask> try { <mask> JsonReader reader = new JsonReader(response.charStream()); <mask> String result = null; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onMessage(ResponseBody response) { if (response.contentType() != WebSocket.TEXT) { FLog.w( TAG, "Websocket received message with payload of unexpected type " + response.contentType()); return; } </s> add public void onMessage(String text) { </s> remove JsonReader reader = new JsonReader(response.charStream()); </s> add JsonReader reader = new JsonReader(new StringReader(text)); </s> add @Override public void onMessage(ByteString bytes) { FLog.w(TAG, "Websocket received message with payload of unexpected type binary"); } </s> remove public void onMessage(ResponseBody response) throws IOException { String message; try { if (response.contentType() == WebSocket.BINARY) { message = Base64.encodeToString(response.source().readByteArray(), Base64.NO_WRAP); } else { message = response.source().readUtf8(); } } catch (IOException e) { notifyWebSocketFailed(id, e.getMessage()); return; } try { response.source().close(); } catch (IOException e) { FLog.e( ReactConstants.TAG, "Could not close BufferedSource for WebSocket id " + id, e); } </s> add public void onMessage(WebSocket webSocket, ByteString bytes) { String text = bytes.utf8(); </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> Integer replyID = null; <mask> <mask> try { <mask> JsonReader reader = new JsonReader(response.charStream()); <mask> String result = null; <mask> reader.beginObject(); <mask> while (reader.hasNext()) { <mask> String field = reader.nextName(); <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onMessage(ResponseBody response) throws IOException { if (response.contentType() != WebSocket.TEXT) { FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType()); return; } </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove public void downloadBundleFromURL(final BundleDownloadCallback callback, final File outputFile, final String bundleURL) { final Request request = new Request.Builder().url(bundleURL).addHeader("Accept", "multipart/mixed").build(); mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request)); mDownloadBundleFromURLCall.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; callback.onFailure(DebugServerException.makeGeneric("Could not connect to development server.", "URL: " + call.request().url().toString(), e)); } @Override public void onResponse(Call call, final Response response) throws IOException { // ignore callback if call was cancelled if (mDownloadBundleFromURLCall == null || mDownloadBundleFromURLCall.isCanceled()) { mDownloadBundleFromURLCall = null; return; } mDownloadBundleFromURLCall = null; final String url = response.request().url().toString(); // Make sure the result is a multipart response and parse the boundary. String contentType = response.header("content-type"); Pattern regex = Pattern.compile("multipart/mixed;.*boundary=\"([^\"]+)\""); Matcher match = regex.matcher(contentType); if (match.find()) { String boundary = match.group(1); MultipartStreamReader bodyReader = new MultipartStreamReader(response.body().source(), boundary); boolean completed = bodyReader.readAllParts(new MultipartStreamReader.ChunkCallback() { @Override public void execute(Map<String, String> headers, Buffer body, boolean finished) throws IOException { // encoded as JSON. if (finished) { // The http status code for each separate chunk is in the X-Http-Status header. int status = response.code(); if (headers.containsKey("X-Http-Status")) { status = Integer.parseInt(headers.get("X-Http-Status")); } processBundleResult(url, status, body, outputFile, callback); } else { if (!headers.containsKey("Content-Type") || !headers.get("Content-Type").equals("application/json")) { return; } try { JSONObject progress = new JSONObject(body.readUtf8()); String status = null; if (progress.has("status")) { status = progress.getString("status"); } Integer done = null; if (progress.has("done")) { done = progress.getInt("done"); } Integer total = null; if (progress.has("total")) { total = progress.getInt("total"); } callback.onProgress(status, done, total); } catch (JSONException e) { FLog.e(ReactConstants.TAG, "Error parsing progress JSON. " + e.toString()); } } } }); if (!completed) { callback.onFailure(new DebugServerException("Error while reading multipart response.\n\nResponse code: " + response.code() + "\n\n" + "URL: " + call.request().url().toString() + "\n\n")); } } else { /** * In case the server doesn't support multipart/mixed responses, * fallback to normal download. */ processBundleResult(url, response.code(), Okio.buffer(response.body().source()), outputFile, callback); } } }); } private void processBundleResult(String url, int statusCode, BufferedSource body, File outputFile, BundleDownloadCallback callback) throws IOException { // Check for server errors. If the server error has the expected form, fail with more info. if (statusCode != 200) { String bodyString = body.readUtf8(); DebugServerException debugServerException = DebugServerException.parse(bodyString); if (debugServerException != null) { callback.onFailure(debugServerException); } else { StringBuilder sb = new StringBuilder(); sb.append("The development server returned response error code: ").append(statusCode).append("\n\n").append("URL: ").append(url).append("\n\n").append("Body:\n").append(bodyString); callback.onFailure(new DebugServerException(sb.toString())); } return; } Sink output = null; try { output = Okio.sink(outputFile); body.readAll(output); callback.onSuccess(); } finally { if (output != null) { output.close(); } } } public void cancelDownloadBundleFromURL() { if (mDownloadBundleFromURLCall != null) { mDownloadBundleFromURLCall.cancel(); mDownloadBundleFromURLCall = null; } } </s> add </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public void onPong(Buffer payload) { } @Override public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove JSONObject message = new JSONObject(response.string()); </s> add JSONObject message = new JSONObject(text); </s> remove public synchronized void onClose(int code, String reason) { </s> add public synchronized void onClosed(WebSocket webSocket, int code, String reason) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep replace replace keep keep keep keep replace replace keep keep keep
<mask> abort("Parsing response message from websocket failed", e); <mask> } <mask> } finally { <mask> response.close(); <mask> } <mask> } <mask> <mask> @Override <mask> public void onFailure(IOException e, Response response) { <mask> abort("Websocket exception", e); <mask> } <mask> <mask> @Override </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove abort("Websocket exception", e); </s> add abort("Websocket exception", t); </s> remove abort("Websocket exception", e); </s> add abort("Websocket exception", t); </s> remove public void onFailure(IOException e, Response response) { </s> add public void onFailure(WebSocket webSocket, Throwable t, Response response) { </s> remove public synchronized void onFailure(IOException e, Response response) { </s> add public synchronized void onFailure(WebSocket webSocket, Throwable t, Response response) { </s> remove public void onFailure(IOException e, Response response) { notifyWebSocketFailed(id, e.getMessage()); </s> add public void onFailure(WebSocket webSocket, Throwable t, Response response) { notifyWebSocketFailed(id, t.getMessage());
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep replace keep keep keep replace replace replace replace replace keep
<mask> } <mask> <mask> @Override <mask> public void onClose(int code, String reason) { <mask> mWebSocket = null; <mask> } <mask> <mask> @Override <mask> public void onPong(Buffer payload) { <mask> // ignore <mask> } <mask> <mask> private void abort(String message, Throwable cause) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove public void onPong(Buffer payload) { } @Override public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public synchronized void onClose(int code, String reason) { </s> add public synchronized void onClosed(WebSocket webSocket, int code, String reason) { </s> remove public synchronized void onPong(Buffer payload) { } </s> add public synchronized void onMessage(WebSocket webSocket, ByteString bytes) { if (mMessageCallback != null) { mMessageCallback.onMessage(bytes); } } </s> remove public void send(JSONObject object) throws IOException { if (mWebSocket == null) { return; } mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, object.toString())); </s> add public void send(final JSONObject object) { new AsyncTask<WebSocket, Void, Void>() { @Override protected Void doInBackground(WebSocket... sockets) { if (sockets == null || sockets.length == 0) { return null; } try { sockets[0].send(object.toString()); } catch (Exception e) { FLog.w(TAG, "Couldn't send event to packager", e); } return null; } }.execute(mWebSocket); </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java
keep keep keep replace replace replace keep replace
<mask> String[] stackTrace = stack.split("\n"); <mask> StackFrame[] result = new StackFrame[stackTrace.length]; <mask> for (int i = 0; i < stackTrace.length; ++i) { <mask> Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]); <mask> if (!matcher.find()) { <mask> throw new IllegalArgumentException( <mask> "Unexpected stack frame format: " + stackTrace[i]); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove result[i] = new StackFrameImpl( matcher.group(2), matcher.group(1) == null ? "(unknown)" : matcher.group(1), Integer.parseInt(matcher.group(3)), Integer.parseInt(matcher.group(4))); </s> add result[i] = new StackFrameImpl( matcher.group(2), matcher.group(1) == null ? "(unknown)" : matcher.group(1), Integer.parseInt(matcher.group(3)), Integer.parseInt(matcher.group(4))); } </s> remove if (currentTimestamp - mTimestamps[index] < VISIBLE_TIME_RANGE_MS) { </s> add if (currentTimestamp - mTimestamps[index] < VISIBLE_TIME_RANGE_NS) { </s> add StringBuilder sb = new StringBuilder(); toStringWithIndentation(sb, 0); return sb.toString(); } private void toStringWithIndentation(StringBuilder result, int level) { // Spaces and tabs are dropped by IntelliJ logcat integration, so rely on __ instead. for (int i = 0; i < level; ++i) { result.append("__"); } result .append(getClass().getSimpleName()) .append(" "); </s> remove return getClass().getSimpleName() + " (virtual node)"; </s> add for (int i = 0; i < getChildCount(); i++) { getChildAt(i).toStringWithIndentation(result, level + 1); } </s> remove float totalFlexBasis = 0; </s> add float totalOuterFlexBasis = 0;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.java
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> throw new IllegalArgumentException( <mask> "Unexpected stack frame format: " + stackTrace[i]); <mask> } <mask> <mask> result[i] = new StackFrameImpl( <mask> matcher.group(2), <mask> matcher.group(1) == null ? "(unknown)" : matcher.group(1), <mask> Integer.parseInt(matcher.group(3)), <mask> Integer.parseInt(matcher.group(4))); <mask> } <mask> return result; <mask> } <mask> <mask> /** </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } </s> add } </s> remove Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]); if (!matcher.find()) { throw new IllegalArgumentException( </s> add if (stackTrace[i].equals("[native code]")) { result[i] = new StackFrameImpl(null, stackTrace[i], -1, -1); } else { Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]); if (!matcher.find()) { throw new IllegalArgumentException( </s> remove if (responder != null) { // Responder is provided, so there is a client waiting our response responder.respond(result == null ? "started" : result); } else if (result != null) { // The profile was not initiated by external client, so process the // profile if there is one in the result new JscProfileTask(getSourceUrl()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, result); } </s> add new JscProfileTask(getSourceUrl()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, result); </s> remove // re-enable anti alias mPaint.setAntiAlias(true); </s> add </s> remove // If the file name of a stack frame is numeric (+ ".js"), we assume it's a lazily injected module // coming from a "random access bundle". We are using special source maps for these bundles, so // that we can symbolicate stack traces for multiple injected files with a single source map. // We have to include the module id in the stack for that, though. The ".js" suffix is kept to // avoid ambiguities between "module-id:line" and "line:column". private static String stackFrameToModuleId(ReadableMap frame) { if (frame.hasKey("file") && !frame.isNull("file") && frame.getType("file") == ReadableType.String) { final Matcher matcher = mJsModuleIdPattern.matcher(frame.getString("file")); if (matcher.find()) { return matcher.group(1) + ":"; } } return ""; } private String stackTraceToString(String message, ReadableArray stack) { StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n"); for (int i = 0; i < stack.size(); i++) { ReadableMap frame = stack.getMap(i); stringBuilder.append(frame.getString("methodName")).append("@").append(stackFrameToModuleId(frame)).append(frame.getInt("lineNumber")); if (frame.hasKey("column") && !frame.isNull("column") && frame.getType("column") == ReadableType.Number) { stringBuilder.append(":").append(frame.getInt("column")); } stringBuilder.append("\n"); } return stringBuilder.toString(); } </s> add </s> remove Buffer buffer = new Buffer(); client.sendPing(buffer); } catch (IOException | IllegalStateException e) { </s> add client.send(ByteString.EMPTY); } catch (Exception e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.java
keep keep add keep keep keep keep
<mask> private static final int BORDER_BOTTOM_COLOR_SET = 1 << 4; <mask> private static final int BORDER_PATH_EFFECT_DIRTY = 1 << 5; <mask> <mask> private float mBorderLeftWidth; <mask> private float mBorderTopWidth; <mask> private float mBorderRightWidth; <mask> private float mBorderBottomWidth; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private float mContentWidth; private float mContentHeight; </s> add </s> add // ~0 == 0xFFFFFFFF, all bits set to 1. private static final int ALL_BITS_SET = ~0; // 0 == 0x00000000, all bits set to 0. private static final int ALL_BITS_UNSET = 0; </s> add private OkHttpClient mHttpClient; </s> remove private void updatePathForBottomBorder( </s> add private static void updatePathForBottomBorder( Path path, </s> remove private void updatePathForLeftBorder( </s> add private static void updatePathForLeftBorder( Path path, </s> remove private void updatePathForRightBorder( </s> add private static void updatePathForRightBorder( Path path,
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep keep keep replace replace keep replace replace replace replace replace keep keep keep keep
<mask> drawBorders(canvas); <mask> } <mask> <mask> /** <mask> * @return true when border colors differs where two border sides meet (e.g. right and top border <mask> * colors differ) <mask> */ <mask> private boolean isBorderColorDifferentAtIntersectionPoints() { <mask> return isFlagSet(BORDER_TOP_COLOR_SET) || <mask> isFlagSet(BORDER_BOTTOM_COLOR_SET) || <mask> isFlagSet(BORDER_LEFT_COLOR_SET) || <mask> isFlagSet(BORDER_RIGHT_COLOR_SET); <mask> } <mask> <mask> private void drawRectangularBorders(Canvas canvas) { <mask> int defaultColor = getBorderColor(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove url.startsWith("file://")) { </s> add url.startsWith("file://") || url.equals("about:blank")) { </s> add public BundleDownloader getBundleDownloader() { return mBundleDownloader; } </s> remove boolean isDrawPathRequired = isBorderColorDifferentAtIntersectionPoints(); if (isDrawPathRequired && mPathForBorder == null) { mPathForBorder = new Path(); } </s> add // Check for fast path to border drawing. int fastBorderColor = fastBorderCompatibleColorOrZero( borderLeft, borderTop, borderRight, borderBottom, leftColor, topColor, rightColor, bottomColor); if (fastBorderColor != 0) { // Fast border color draw. if (Color.alpha(fastBorderColor) != 0) { // Border color is not transparent. // Draw center. if (Color.alpha(mBackgroundColor) != 0) { PAINT.setColor(mBackgroundColor); if (Color.alpha(fastBorderColor) == 255) { // The border will draw over the edges, so only draw the inset background. canvas.drawRect(leftInset, topInset, rightInset, bottomInset, PAINT); } else { // The border is opaque, so we have to draw the entire background color. canvas.drawRect(left, top, right, bottom, PAINT); } } PAINT.setColor(fastBorderColor); if (borderLeft > 0) { canvas.drawRect(left, top, leftInset, bottom - borderBottom, PAINT); } if (borderTop > 0) { canvas.drawRect(left + borderLeft, top, right, topInset, PAINT); } if (borderRight > 0) { canvas.drawRect(rightInset, top + borderTop, right, bottom, PAINT); } if (borderBottom > 0) { canvas.drawRect(left, bottomInset, right - borderRight, bottom, PAINT); } } } else { if (mPathForBorder == null) { mPathForBorder = new Path(); } </s> remove * See {@link UIManagerModule#addMeasuredRootView}. </s> add * See {@link UIManagerModule#addRootView}.
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep replace replace keep keep keep replace replace keep
<mask> float top = getTop(); <mask> float topWidth = resolveWidth(mBorderTopWidth, defaultWidth); <mask> float bottomOfTheTop = top + topWidth; <mask> int topColor = resolveBorderColor(BORDER_TOP_COLOR_SET, mBorderTopColor, defaultColor); <mask> <mask> float bottom = getBottom(); <mask> float bottomWidth = resolveWidth(mBorderBottomWidth, defaultWidth); <mask> float topOfTheBottom = bottom - bottomWidth; <mask> int bottomColor = resolveBorderColor(BORDER_BOTTOM_COLOR_SET, mBorderBottomColor, defaultColor); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove float leftWidth = resolveWidth(mBorderLeftWidth, defaultWidth); float rightOfTheLeft = left + leftWidth; </s> add float borderLeft = resolveWidth(mBorderLeftWidth, defaultWidth); float leftInset = left + borderLeft; </s> remove float rightWidth = resolveWidth(mBorderRightWidth, defaultWidth); float leftOfTheRight = right - rightWidth; </s> add float borderRight = resolveWidth(mBorderRightWidth, defaultWidth); float rightInset = right - borderRight; </s> remove protected int mLineHeightInput = UNSET; </s> add protected float mLineHeightInput = UNSET; </s> remove float contentSizeWidth, float contentSizeHeight, </s> add </s> add // ~0 == 0xFFFFFFFF, all bits set to 1. private static final int ALL_BITS_SET = ~0; // 0 == 0x00000000, all bits set to 0. private static final int ALL_BITS_UNSET = 0;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep keep replace replace keep keep keep replace replace
<mask> int bottomColor = resolveBorderColor(BORDER_BOTTOM_COLOR_SET, mBorderBottomColor, defaultColor); <mask> <mask> float left = getLeft(); <mask> float leftWidth = resolveWidth(mBorderLeftWidth, defaultWidth); <mask> float rightOfTheLeft = left + leftWidth; <mask> int leftColor = resolveBorderColor(BORDER_LEFT_COLOR_SET, mBorderLeftColor, defaultColor); <mask> <mask> float right = getRight(); <mask> float rightWidth = resolveWidth(mBorderRightWidth, defaultWidth); <mask> float leftOfTheRight = right - rightWidth; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove float bottomWidth = resolveWidth(mBorderBottomWidth, defaultWidth); float topOfTheBottom = bottom - bottomWidth; </s> add float borderBottom = resolveWidth(mBorderBottomWidth, defaultWidth); float bottomInset = bottom - borderBottom; </s> remove float topWidth = resolveWidth(mBorderTopWidth, defaultWidth); float bottomOfTheTop = top + topWidth; </s> add float borderTop = resolveWidth(mBorderTopWidth, defaultWidth); float topInset = top + borderTop; </s> remove protected int mLineHeightInput = UNSET; </s> add protected float mLineHeightInput = UNSET; </s> remove float contentSizeWidth, float contentSizeHeight, </s> add </s> remove boolean isDrawPathRequired = isBorderColorDifferentAtIntersectionPoints(); if (isDrawPathRequired && mPathForBorder == null) { mPathForBorder = new Path(); } </s> add // Check for fast path to border drawing. int fastBorderColor = fastBorderCompatibleColorOrZero( borderLeft, borderTop, borderRight, borderBottom, leftColor, topColor, rightColor, bottomColor); if (fastBorderColor != 0) { // Fast border color draw. if (Color.alpha(fastBorderColor) != 0) { // Border color is not transparent. // Draw center. if (Color.alpha(mBackgroundColor) != 0) { PAINT.setColor(mBackgroundColor); if (Color.alpha(fastBorderColor) == 255) { // The border will draw over the edges, so only draw the inset background. canvas.drawRect(leftInset, topInset, rightInset, bottomInset, PAINT); } else { // The border is opaque, so we have to draw the entire background color. canvas.drawRect(left, top, right, bottom, PAINT); } } PAINT.setColor(fastBorderColor); if (borderLeft > 0) { canvas.drawRect(left, top, leftInset, bottom - borderBottom, PAINT); } if (borderTop > 0) { canvas.drawRect(left + borderLeft, top, right, topInset, PAINT); } if (borderRight > 0) { canvas.drawRect(rightInset, top + borderTop, right, bottom, PAINT); } if (borderBottom > 0) { canvas.drawRect(left, bottomInset, right - borderRight, bottom, PAINT); } } } else { if (mPathForBorder == null) { mPathForBorder = new Path(); }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep keep replace replace replace replace keep replace replace replace keep keep keep keep
<mask> float leftOfTheRight = right - rightWidth; <mask> int rightColor = resolveBorderColor(BORDER_RIGHT_COLOR_SET, mBorderRightColor, defaultColor); <mask> <mask> boolean isDrawPathRequired = isBorderColorDifferentAtIntersectionPoints(); <mask> if (isDrawPathRequired && mPathForBorder == null) { <mask> mPathForBorder = new Path(); <mask> } <mask> <mask> // draw top <mask> if (Color.alpha(topColor) != 0 && topWidth != 0) { <mask> PAINT.setColor(topColor); <mask> <mask> if (isDrawPathRequired) { <mask> updatePathForTopBorder( <mask> top, </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove float rightWidth = resolveWidth(mBorderRightWidth, defaultWidth); float leftOfTheRight = right - rightWidth; </s> add float borderRight = resolveWidth(mBorderRightWidth, defaultWidth); float rightInset = right - borderRight; </s> remove if (isDrawPathRequired) { </s> add // Draw top. if (borderTop != 0 && Color.alpha(topColor) != 0) { PAINT.setColor(topColor); </s> remove if (isDrawPathRequired) { </s> add // Draw right. if (borderRight != 0 && Color.alpha(rightColor) != 0) { PAINT.setColor(rightColor); </s> remove float rightOfTheLeft, </s> add float leftInset, </s> remove if (borderBottom > 0 && colorBottom != Color.TRANSPARENT) { mPaint.setColor(colorBottom); mPathForBorder.reset(); mPathForBorder.moveTo(left, top + height); mPathForBorder.lineTo(left + width, top + height); mPathForBorder.lineTo(left + width - borderRight, top + height - borderBottom); mPathForBorder.lineTo(left + borderLeft, top + height - borderBottom); mPathForBorder.lineTo(left, top + height); canvas.drawPath(mPathForBorder, mPaint); </s> add // Check for fast path to border drawing. int fastBorderColor = fastBorderCompatibleColorOrZero( borderLeft, borderTop, borderRight, borderBottom, colorLeft, colorTop, colorRight, colorBottom); if (fastBorderColor != 0) { if (Color.alpha(fastBorderColor) != 0) { // Border color is not transparent. int right = bounds.right; int bottom = bounds.bottom; mPaint.setColor(fastBorderColor); if (borderLeft > 0) { int leftInset = left + borderLeft; canvas.drawRect(left, top, leftInset, bottom - borderBottom, mPaint); } if (borderTop > 0) { int topInset = top + borderTop; canvas.drawRect(left + borderLeft, top, right, topInset, mPaint); } if (borderRight > 0) { int rightInset = right - borderRight; canvas.drawRect(rightInset, top + borderTop, right, bottom, mPaint); } if (borderBottom > 0) { int bottomInset = bottom - borderBottom; canvas.drawRect(left, bottomInset, right - borderRight, bottom, mPaint); } } } else { if (mPathForBorder == null) { mPathForBorder = new Path(); } // If the path drawn previously is of the same color, // there would be a slight white space between borders // with anti-alias set to true. // Therefore we need to disable anti-alias, and // after drawing is done, we will re-enable it. mPaint.setAntiAlias(false); int width = bounds.width(); int height = bounds.height(); if (borderLeft > 0 && colorLeft != Color.TRANSPARENT) { mPaint.setColor(colorLeft); mPathForBorder.reset(); mPathForBorder.moveTo(left, top); mPathForBorder.lineTo(left + borderLeft, top + borderTop); mPathForBorder.lineTo(left + borderLeft, top + height - borderBottom); mPathForBorder.lineTo(left, top + height); mPathForBorder.lineTo(left, top); canvas.drawPath(mPathForBorder, mPaint); } if (borderTop > 0 && colorTop != Color.TRANSPARENT) { mPaint.setColor(colorTop); mPathForBorder.reset(); mPathForBorder.moveTo(left, top); mPathForBorder.lineTo(left + borderLeft, top + borderTop); mPathForBorder.lineTo(left + width - borderRight, top + borderTop); mPathForBorder.lineTo(left + width, top); mPathForBorder.lineTo(left, top); canvas.drawPath(mPathForBorder, mPaint); } if (borderRight > 0 && colorRight != Color.TRANSPARENT) { mPaint.setColor(colorRight); mPathForBorder.reset(); mPathForBorder.moveTo(left + width, top); mPathForBorder.lineTo(left + width, top + height); mPathForBorder.lineTo(left + width - borderRight, top + height - borderBottom); mPathForBorder.lineTo(left + width - borderRight, top + borderTop); mPathForBorder.lineTo(left + width, top); canvas.drawPath(mPathForBorder, mPaint); } if (borderBottom > 0 && colorBottom != Color.TRANSPARENT) { mPaint.setColor(colorBottom); mPathForBorder.reset(); mPathForBorder.moveTo(left, top + height); mPathForBorder.lineTo(left + width, top + height); mPathForBorder.lineTo(left + width - borderRight, top + height - borderBottom); mPathForBorder.lineTo(left + borderLeft, top + height - borderBottom); mPathForBorder.lineTo(left, top + height); canvas.drawPath(mPathForBorder, mPaint); } // re-enable anti alias mPaint.setAntiAlias(true);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep keep keep replace keep keep keep keep keep
<mask> // draw top <mask> if (Color.alpha(topColor) != 0 && topWidth != 0) { <mask> PAINT.setColor(topColor); <mask> <mask> if (isDrawPathRequired) { <mask> updatePathForTopBorder( <mask> top, <mask> bottomOfTheTop, <mask> left, <mask> rightOfTheLeft, </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // draw top if (Color.alpha(topColor) != 0 && topWidth != 0) { PAINT.setColor(topColor); </s> add // Draw center. Any of the borders might be opaque or transparent, so we need to draw this. if (Color.alpha(mBackgroundColor) != 0) { PAINT.setColor(mBackgroundColor); canvas.drawRect(left, top, right, bottom, PAINT); } </s> remove if (isDrawPathRequired) { </s> add // Draw bottom. if (borderBottom != 0 && Color.alpha(bottomColor) != 0) { PAINT.setColor(bottomColor); </s> remove } // draw right if (Color.alpha(rightColor) != 0 && rightWidth != 0) { PAINT.setColor(rightColor); </s> add </s> add mPathForBorder, </s> remove if (isDrawPathRequired) { </s> add // Draw right. if (borderRight != 0 && Color.alpha(rightColor) != 0) { PAINT.setColor(rightColor); </s> remove if (isDrawPathRequired) { </s> add // Draw left. if (borderLeft != 0 && Color.alpha(leftColor) != 0) { PAINT.setColor(leftColor);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep keep add keep keep keep keep keep keep
<mask> // Draw top. <mask> if (borderTop != 0 && Color.alpha(topColor) != 0) { <mask> PAINT.setColor(topColor); <mask> updatePathForTopBorder( <mask> top, <mask> topInset, <mask> left, <mask> leftInset, <mask> right, <mask> rightInset); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove if (isDrawPathRequired) { </s> add // Draw top. if (borderTop != 0 && Color.alpha(topColor) != 0) { PAINT.setColor(topColor); </s> add mPathForBorder, </s> remove // draw top if (Color.alpha(topColor) != 0 && topWidth != 0) { PAINT.setColor(topColor); </s> add // Draw center. Any of the borders might be opaque or transparent, so we need to draw this. if (Color.alpha(mBackgroundColor) != 0) { PAINT.setColor(mBackgroundColor); canvas.drawRect(left, top, right, bottom, PAINT); } </s> remove if (isDrawPathRequired) { </s> add // Draw bottom. if (borderBottom != 0 && Color.alpha(bottomColor) != 0) { PAINT.setColor(bottomColor); </s> remove if (isDrawPathRequired) { </s> add // Draw left. if (borderLeft != 0 && Color.alpha(leftColor) != 0) { PAINT.setColor(leftColor); </s> remove if (isDrawPathRequired) { </s> add // Draw right. if (borderRight != 0 && Color.alpha(rightColor) != 0) { PAINT.setColor(rightColor);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep replace keep replace keep keep
<mask> updatePathForTopBorder( <mask> top, <mask> bottomOfTheTop, <mask> left, <mask> rightOfTheLeft, <mask> right, <mask> leftOfTheRight); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove leftOfTheRight); </s> add rightInset); </s> remove private void updatePathForTopBorder( </s> add private static void updatePathForTopBorder( Path path, </s> remove float bottomOfTheTop, </s> add float topInset, </s> remove float rightOfTheLeft, </s> add float leftInset, </s> remove } else { canvas.drawRect(left, top, right, bottomOfTheTop, PAINT); </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep replace keep replace replace
<mask> rightOfTheLeft, <mask> right, <mask> leftOfTheRight); <mask> canvas.drawPath(mPathForBorder, PAINT); <mask> } else { <mask> canvas.drawRect(left, top, right, bottomOfTheTop, PAINT); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove rightOfTheLeft, </s> add leftInset, </s> remove leftOfTheRight); </s> add rightInset); </s> remove rightOfTheLeft, </s> add leftInset, </s> remove topOfTheBottom, </s> add bottomInset, </s> remove } else { canvas.drawRect(left, topOfTheBottom, right, bottom, PAINT); </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep replace replace replace replace replace keep replace keep keep keep keep
<mask> canvas.drawRect(left, top, right, bottomOfTheTop, PAINT); <mask> } <mask> } <mask> <mask> // draw bottom <mask> if (Color.alpha(bottomColor) != 0 && bottomWidth != 0) { <mask> PAINT.setColor(bottomColor); <mask> <mask> if (isDrawPathRequired) { <mask> updatePathForBottomBorder( <mask> bottom, <mask> topOfTheBottom, <mask> left, </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove } else { canvas.drawRect(left, top, right, bottomOfTheTop, PAINT); </s> add </s> remove } // draw left if (Color.alpha(leftColor) != 0 && leftWidth != 0) { PAINT.setColor(leftColor); </s> add </s> remove } // draw right if (Color.alpha(rightColor) != 0 && rightWidth != 0) { PAINT.setColor(rightColor); </s> add </s> remove } else { canvas.drawRect(left, bottomOfTheTop, rightOfTheLeft, topOfTheBottom, PAINT); </s> add </s> remove } else { canvas.drawRect(left, topOfTheBottom, right, bottom, PAINT); </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep add keep keep keep keep keep keep
<mask> PAINT.setColor(bottomColor); <mask> updatePathForBottomBorder( <mask> bottom, <mask> bottomInset, <mask> left, <mask> leftInset, <mask> right, <mask> rightInset); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove rightOfTheLeft, </s> add leftInset, </s> remove topOfTheBottom, </s> add bottomInset, </s> remove float topOfTheBottom, </s> add float bottomInset, </s> remove float rightOfTheLeft, </s> add float leftInset, </s> add mPathForBorder, </s> remove leftOfTheRight); </s> add rightInset);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep keep keep replace keep replace keep keep keep keep
<mask> <mask> if (isDrawPathRequired) { <mask> updatePathForBottomBorder( <mask> bottom, <mask> topOfTheBottom, <mask> left, <mask> rightOfTheLeft, <mask> right, <mask> leftOfTheRight); <mask> canvas.drawPath(mPathForBorder, PAINT); <mask> } else { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove leftOfTheRight); </s> add rightInset); </s> remove } else { canvas.drawRect(left, topOfTheBottom, right, bottom, PAINT); </s> add </s> remove bottomOfTheTop, </s> add topInset, </s> remove } // draw bottom if (Color.alpha(bottomColor) != 0 && bottomWidth != 0) { PAINT.setColor(bottomColor); </s> add </s> remove leftOfTheRight); </s> add rightInset);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java
keep keep keep replace keep replace replace keep keep keep
<mask> left, <mask> rightOfTheLeft, <mask> right, <mask> leftOfTheRight); <mask> canvas.drawPath(mPathForBorder, PAINT); <mask> } else { <mask> canvas.drawRect(left, topOfTheBottom, right, bottom, PAINT); <mask> } <mask> } <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove rightOfTheLeft, </s> add leftInset, </s> remove leftOfTheRight); </s> add rightInset); </s> remove rightOfTheLeft, </s> add leftInset, </s> remove leftOfTheRight); </s> add rightInset); </s> remove rightOfTheLeft); </s> add leftInset);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/java/com/facebook/react/flat/DrawBorder.java