support custom peer
MODIFY
bither-android/AndroidManifest.xml
bither-android/AndroidManifest.xml
android:screenOrientation="portrait"
android:theme="@style/BitherTransparentBgTheme"
android:windowSoftInputMode="stateAlwaysHidden" />
+ <activity
+ android:name="net.bither.activity.hot.NetworkCustomPeerActivity"
+ android:screenOrientation="portrait"
+ android:theme="@style/BitherTransparentBgTheme"
+ android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name="net.bither.activity.hot.MarketDetailActivity"
android:screenOrientation="portrait"

MODIFY
bither-android/res/layout/activity_hot_advance_options.xml
bither-android/res/layout/activity_hot_advance_options.xml
<include layout="@layout/layout_vertical_seperator" />
+ <Button
+ android:id="@+id/btn_network_custom_peer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ui_touchable_bg"
+ android:gravity="left"
+ android:padding="10dp"
+ android:text="@string/network_custom_peer_title"
+ android:textColor="@color/text_field_text_color"
+ android:textSize="18sp" />
+
+ <include layout="@layout/layout_vertical_seperator"/>
+
<Button
android:id="@+id/btn_network_monitor"
android:layout_width="match_parent"

ADD
bither-android/res/layout/activity_network_custom_peer.xml
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="@dimen/title_bar_below_margin"
+ android:background="#ffffffff">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingLeft="@dimen/horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingRight="@dimen/horizontal_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin">
+
+ <TextView
+ android:id="@+id/tv_current_custom_peer_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="3dp"
+ android:layout_marginRight="3dp"
+ android:text="@string/network_custom_peer_used"
+ android:textColor="@color/text_field_light_text_color"
+ android:textSize="14sp"
+ android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/tv_current_custom_peer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="3dp"
+ android:layout_marginTop="@dimen/card_list_padding"
+ android:layout_marginRight="3dp"
+ android:layout_marginBottom="@dimen/horizontal_edge_padding"
+ android:textColor="@color/text_field_text_color"
+ android:textSize="16sp"
+ android:textStyle="bold"
+ android:visibility="gone" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="3dp"
+ android:layout_marginRight="3dp"
+ android:text="@string/network_custom_peer_dns_or_ip"
+ android:textColor="@color/text_field_light_text_color"
+ android:textSize="14sp" />
+
+ <EditText
+ android:id="@+id/et_dns_or_ip"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="2dp"
+ android:background="@drawable/text_field_holo_light_background"
+ android:hint="@string/network_custom_peer_dns_or_ip_empty"
+ android:imeOptions="flagNoExtractUi"
+ android:textSize="16sp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="3dp"
+ android:layout_marginTop="5dp"
+ android:layout_marginRight="3dp"
+ android:text="@string/network_custom_peer_port"
+ android:textColor="@color/text_field_light_text_color"
+ android:textSize="14sp" />
+
+ <EditText
+ android:id="@+id/et_port"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="2dp"
+ android:background="@drawable/text_field_holo_light_background"
+ android:imeOptions="flagNoExtractUi"
+ android:inputType="number"
+ android:textSize="16sp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="3dp"
+ android:layout_marginTop="5dp"
+ android:layout_marginRight="3dp"
+ android:text="@string/network_custom_peer_tips"
+ android:textColor="@color/password_strength_weak"
+ android:textSize="12sp" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/title_bar_below_margin"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/btn_confirm"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:layout_weight="1"
+ android:background="@drawable/btn_small_send_selector"
+ android:padding="10dp"
+ android:text="@string/OK"
+ android:textColor="@color/white"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+ </LinearLayout>
+ </LinearLayout>
+ </ScrollView>
+
+ <include layout="@layout/layout_dropdown_message" />
+
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/fl_title_bar"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/title_bar_height"
+ android:layout_alignParentTop="true"
+ android:background="@drawable/title_bar_bg"
+ android:paddingBottom="3dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/tab_button_background"
+ android:duplicateParentState="true"
+ android:orientation="horizontal">
+
+ <ImageButton
+ android:id="@+id/ibtn_back"
+ android:layout_width="@dimen/title_bar_height"
+ android:layout_height="match_parent"
+ android:background="@drawable/tab_button_background"
+ android:src="@drawable/title_bar_back" />
+
+ <ImageView
+ android:layout_width="2dp"
+ android:layout_height="match_parent"
+ android:background="@drawable/title_bar_seperator" />
+
+ <TextView
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="5dp"
+ android:layout_weight="1"
+ android:gravity="center_vertical"
+ android:shadowColor="@color/text_field_text_color"
+ android:shadowDx="1"
+ android:shadowDy="-1"
+ android:shadowRadius="0.5"
+ android:text="@string/network_custom_peer_title"
+ android:textColor="@color/white"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+
+ <ImageView
+ android:id="@+id/iv_option_line"
+ android:layout_width="2dp"
+ android:layout_height="match_parent"
+ android:background="@drawable/title_bar_seperator"
+ android:visibility="gone" />
+
+ <ImageButton
+ android:id="@+id/ibtn_option"
+ android:layout_width="@dimen/title_bar_height"
+ android:layout_height="match_parent"
+ android:background="@drawable/tab_button_background"
+ android:src="@drawable/title_bar_option_icon"
+ android:visibility="gone" />
+
+ </LinearLayout>
+ </FrameLayout>
+
+</FrameLayout>
\ No newline at end of file

MODIFY
bither-android/res/values/dimens.xml
bither-android/res/values/dimens.xml
<dimen name="title_bar_height">52dp</dimen>
<dimen name="title_bar_below_margin">49dp</dimen>
<dimen name="vertical_margin">10dp</dimen>
+ <dimen name="horizontal_margin">12dp</dimen>
<dimen name="card_list_padding">6dp</dimen>
<dimen name="horizontal_edge_padding">25dp</dimen>
<dimen name="avatar_size_in_list">40dp</dimen>

MODIFY
bither-android/src/net/bither/NotificationAndroidImpl.java
bither-android/src/net/bither/NotificationAndroidImpl.java
@@ -73,6 +73,7 @@ public class NotificationAndroidImpl implements NotificationService {
@Override
public void sendLastBlockChange() {
Intent broadcast = new Intent(ACTION_SYNC_LAST_BLOCK_CHANGE);
+ broadcast.setPackage(BitherApplication.mContext.getPackageName());
BitherApplication.mContext.sendBroadcast(broadcast);
}
@@ -85,6 +86,7 @@ public class NotificationAndroidImpl implements NotificationService {
broadcast.putExtra(MESSAGE_TX, tx.getTxHash());
}
broadcast.putExtra(MESSAGE_TX_NOTIFICATION_TYPE, txNotificationType.getValue());
+ broadcast.setPackage(BitherApplication.mContext.getPackageName());
BitherApplication.mContext.sendBroadcast(broadcast);
log.debug("address " + address
+ " balance updated " + deltaBalance
@@ -122,6 +124,7 @@ public class NotificationAndroidImpl implements NotificationService {
public void sendConnectedChangeBroadcast(String connectedChangeBroadcast, boolean isConnected) {
Intent intent = new Intent(connectedChangeBroadcast);
intent.putExtra(connectedChangeBroadcast, isConnected);
+ intent.setPackage(BitherApplication.mContext.getPackageName());
BitherApplication.mContext.sendBroadcast(intent);
}
@@ -130,6 +133,7 @@ public class NotificationAndroidImpl implements NotificationService {
final Intent broadcast = new Intent(ACTION_SYNC_BLOCK_AND_WALLET_STATE);
broadcast.putExtra(ACTION_PROGRESS_INFO, value);
broadcast.putExtra(ACTION_UNSYNC_BLOCK_NUMBER_INFO, unsyncBlockNumber);
+ broadcast.setPackage(BitherApplication.mContext.getPackageName());
BitherApplication.mContext.sendBroadcast(broadcast);
}

MODIFY
bither-android/src/net/bither/activity/hot/HotActivity.java
bither-android/src/net/bither/activity/hot/HotActivity.java
@@ -73,6 +73,7 @@ import java.util.ArrayList;
import java.util.List;
import static net.bither.NotificationAndroidImpl.ACTION_UNSYNC_BLOCK_NUMBER_INFO;
+import static net.bither.bitherj.core.PeerManager.ConnectedChangeBroadcast;
public class HotActivity extends BaseFragmentActivity {
private TabButton tbtnMessage;
@@ -91,6 +92,7 @@ public class HotActivity extends BaseFragmentActivity {
private final ProgressBroadcastReceiver broadcastReceiver = new ProgressBroadcastReceiver();
private final AddressIsLoadedReceiver addressIsLoadedReceiver = new AddressIsLoadedReceiver();
private final AddressTxLoadingReceiver addressIsLoadingReceiver = new AddressTxLoadingReceiver();
+ private final PeerConnectedChangeReceiver peerConnectedChangeReceiver = new PeerConnectedChangeReceiver();
protected void onCreate(Bundle savedInstanceState) {
AbstractApp.notificationService.removeProgressState();
@@ -140,6 +142,7 @@ public class HotActivity extends BaseFragmentActivity {
registerReceiver(addressIsLoadedReceiver,
new IntentFilter(NotificationAndroidImpl.ACTION_ADDRESS_LOAD_COMPLETE_STATE));
registerReceiver(addressIsLoadingReceiver, new IntentFilter(NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_STATE));
+ registerReceiver(peerConnectedChangeReceiver, new IntentFilter(ConnectedChangeBroadcast));
}
@Override
@@ -487,12 +490,14 @@ public class HotActivity extends BaseFragmentActivity {
llAlert.setVisibility(View.VISIBLE);
}
} else {
+ if (unsyncBlockNumber != -2) {
llAlert.setVisibility(View.GONE);
}
}
}
}
}
+ }
private final class TxAndBlockBroadcastReceiver extends BroadcastReceiver {
@@ -549,6 +554,21 @@ public class HotActivity extends BaseFragmentActivity {
}
}
+ private final class PeerConnectedChangeReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent == null || !Utils.compareString(intent.getAction(), ConnectedChangeBroadcast)) {
+ return;
+ }
+ if (!intent.hasExtra(ConnectedChangeBroadcast)) {
+ return;
+ }
+ if (PeerManager.instance().getConnectedPeers().size() > 0 && llAlert.getVisibility() == View.VISIBLE && tvAlert.getText().toString().equals(getString(R.string.tip_no_peers_connected_scan))) {
+ llAlert.setVisibility(View.GONE);
+ }
+ }
+ }
+
// private void addNewPrivateKey() {
// final AppSharedPreference preference = AppSharedPreference.getInstance();
// if (!preference.hasPrivateKey()) {

MODIFY
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
@@ -186,6 +186,7 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
// btnResetTx.setOnClickListener(selDialog);
btnExportAddress = (Button) findViewById(R.id.btn_export_address);
btnExportAddress.setOnClickListener(exportAddressClick);
+ findViewById(R.id.btn_network_custom_peer).setOnClickListener(networkCustomPeerClick);
findViewById(R.id.btn_network_monitor).setOnClickListener(networkMonitorClick);
findViewById(R.id.ll_bither_address).setOnClickListener(bitherAddressQrClick);
findViewById(R.id.ibtn_bither_address_qr).setOnClickListener(bitherAddressQrClick);
@@ -242,7 +243,6 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
};
private View.OnClickListener networkMonitorClick = new View.OnClickListener() {
-
@Override
public void onClick(View v) {
Intent intent = new Intent(HotAdvanceActivity.this, NetworkMonitorActivity.class);
@@ -250,6 +250,14 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
}
};
+ private View.OnClickListener networkCustomPeerClick = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(HotAdvanceActivity.this, NetworkCustomPeerActivity.class);
+ startActivity(intent);
+ }
+ };
+
private View.OnClickListener rawPrivateKeyClick = new View.OnClickListener() {
private int clickedTime;

ADD
bither-android/src/net/bither/activity/hot/NetworkCustomPeerActivity.java
+package net.bither.activity.hot;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.bither.R;
+import net.bither.bitherj.BitherjSettings;
+import net.bither.bitherj.core.PeerManager;
+import net.bither.bitherj.db.AbstractDb;
+import net.bither.bitherj.utils.DnsDiscovery;
+import net.bither.bitherj.utils.Utils;
+import net.bither.preference.AppSharedPreference;
+import net.bither.runnable.ThreadNeedService;
+import net.bither.service.BlockchainService;
+import net.bither.ui.base.BaseFragmentActivity;
+import net.bither.ui.base.DropdownMessage;
+import net.bither.ui.base.dialog.DialogConfirmTask;
+import net.bither.ui.base.dialog.DialogWithActions;
+import net.bither.ui.base.listener.IBackClickListener;
+import net.bither.util.ThreadUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+public class NetworkCustomPeerActivity extends BaseFragmentActivity {
+
+ private ImageButton ibtnBack;
+ private TextView tvCurrentCustomPeerTitle;
+ private TextView tvCurrentCustomPeer;
+ private EditText etDnsOrIp;
+ private EditText etPort;
+ private ImageView ivOptionLine;
+ private ImageButton ibtnOption;
+ private Button btnConfirm;
+ private InputMethodManager imm;
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_network_custom_peer);
+ imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ ibtnBack = findViewById(R.id.ibtn_back);
+ ibtnBack.setOnClickListener(new IBackClickListener());
+ etDnsOrIp = findViewById(R.id.et_dns_or_ip);
+ etPort = findViewById(R.id.et_port);
+ etPort.setHint(getString(R.string.network_custom_peer_port_hint, BitherjSettings.port));
+ btnConfirm = findViewById(R.id.btn_confirm);
+ btnConfirm.setOnClickListener(confirmClick);
+ String customDnsOrIp = AppSharedPreference.getInstance().getNetworkCustomPeerDnsOrIp();
+ if (Utils.isEmpty(customDnsOrIp)) {
+ return;
+ }
+ tvCurrentCustomPeerTitle = findViewById(R.id.tv_current_custom_peer_title);
+ tvCurrentCustomPeer = findViewById(R.id.tv_current_custom_peer);
+ tvCurrentCustomPeer.setText(customDnsOrIp + ":" + AppSharedPreference.getInstance().getNetworkCustomPeerPort());
+ ivOptionLine = findViewById(R.id.iv_option_line);
+ ibtnOption = findViewById(R.id.ibtn_option);
+ findViewById(R.id.ibtn_option).setOnClickListener(optionClick);
+ showCurrentCustomPeer(true);
+ }
+
+ private void showCurrentCustomPeer(boolean isShow) {
+ int visibility = isShow ? View.VISIBLE : View.GONE;
+ tvCurrentCustomPeerTitle.setVisibility(visibility);
+ tvCurrentCustomPeer.setVisibility(visibility);
+ ivOptionLine.setVisibility(visibility);
+ ibtnOption.setVisibility(visibility);
+ }
+
+ private View.OnClickListener confirmClick = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String dnsOrIp = etDnsOrIp.getText().toString();
+ if (Utils.isEmpty(dnsOrIp)) {
+ DropdownMessage.showDropdownMessage(NetworkCustomPeerActivity.this, R.string.network_custom_peer_dns_or_ip_empty);
+ return;
+ }
+ int port;
+ String portStr = etPort.getText().toString();
+ if (Utils.isEmpty(portStr)) {
+ port = BitherjSettings.port;
+ } else {
+ try {
+ port = Integer.valueOf(portStr);
+ } catch (Exception exception) {
+ DropdownMessage.showDropdownMessage(NetworkCustomPeerActivity.this, R.string.network_custom_peer_port_invalid);
+ return;
+ }
+ }
+ imm.hideSoftInputFromWindow(etDnsOrIp.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+ DnsDiscovery.instance().getPeers(dnsOrIp, port, 5, TimeUnit.SECONDS);
+ String getPeersErrorMsg = DnsDiscovery.instance().getPeersErrorMsg();
+ if (!Utils.isEmpty(getPeersErrorMsg)) {
+ DropdownMessage.showDropdownMessage(NetworkCustomPeerActivity.this, getPeersErrorMsg);
+ return;
+ }
+ AppSharedPreference.getInstance().setNetworkCustomPeer(dnsOrIp, port);
+ new ThreadNeedService(null, NetworkCustomPeerActivity.this) {
+ @Override
+ public void runWithService(BlockchainService service) {
+ if (service != null) {
+ service.stopAndUnregister();
+ }
+ AbstractDb.peerProvider.recreate();
+ if (service != null) {
+ service.startAndRegister();
+ }
+ ThreadUtil.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(NetworkCustomPeerActivity.this, getString(R.string.network_custom_peer_success), new Runnable() {
+ @Override
+ public void run() {
+ finish();
+ }
+ }, false);
+ dialogConfirmTask.setCanceledOnTouchOutside(false);
+ dialogConfirmTask.show();
+ }
+ });
+ }
+ }.start();
+ }
+ };
+
+ private View.OnClickListener optionClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ new DialogWithActions(v.getContext()) {
+
+ @Override
+ protected List<Action> getActions() {
+ ArrayList<Action> actions = new ArrayList<Action>();
+ actions.add(new Action(R.string.network_custom_peer_clear, new Runnable() {
+ @Override
+ public void run() {
+ AppSharedPreference.getInstance().removeNetworkCustomPeer();
+ PeerManager.instance().setCustomPeer(null, BitherjSettings.port);
+ new ThreadNeedService(null, NetworkCustomPeerActivity.this) {
+
+ @Override
+ public void runWithService(BlockchainService service) {
+ if (service != null) {
+ service.stopAndUnregister();
+ }
+ AbstractDb.peerProvider.recreate();
+ if (service != null) {
+ service.startAndRegister();
+ }
+ }
+ }.start();
+ showCurrentCustomPeer(false);
+ }
+ }));
+ return actions;
+ }
+ }.show();
+ }
+ };
+
+}

MODIFY
bither-android/src/net/bither/preference/AppSharedPreference.java
bither-android/src/net/bither/preference/AppSharedPreference.java
@@ -90,6 +90,8 @@ public class AppSharedPreference {
private static final String IS_USE_DYNAMIC_MINER_FEE = "is_use_dynamic_miner_fee";
+ private static final String NETWORK_CUSTOM_PEER_DNS_OR_IP = "network_custom_peer_dns_or_ip";
+ private static final String NETWORK_CUSTOM_PEER_PORT = "network_custom_peer_port";
private static AppSharedPreference mInstance = new AppSharedPreference();
@@ -497,4 +499,20 @@ public class AppSharedPreference {
return mPreferences.getBoolean(IS_USE_DYNAMIC_MINER_FEE,true);
}
+ public void setNetworkCustomPeer(String dnsOrIp, int port) {
+ mPreferences.edit().putString(NETWORK_CUSTOM_PEER_DNS_OR_IP, dnsOrIp).putInt(NETWORK_CUSTOM_PEER_PORT, port).commit();
+ }
+
+ public String getNetworkCustomPeerDnsOrIp() {
+ return mPreferences.getString(NETWORK_CUSTOM_PEER_DNS_OR_IP,"");
+ }
+
+ public int getNetworkCustomPeerPort() {
+ return mPreferences.getInt(NETWORK_CUSTOM_PEER_PORT, BitherjSettings.port);
+ }
+
+ public void removeNetworkCustomPeer() {
+ mPreferences.edit().remove(NETWORK_CUSTOM_PEER_DNS_OR_IP).remove(NETWORK_CUSTOM_PEER_PORT).commit();
+ }
+
}

MODIFY
bither-android/src/net/bither/service/BlockchainService.java
bither-android/src/net/bither/service/BlockchainService.java
@@ -40,6 +40,7 @@ import net.bither.bitherj.core.PeerManager;
import net.bither.bitherj.exception.BlockStoreException;
import net.bither.bitherj.utils.BlockUtil;
import net.bither.bitherj.utils.TransactionsUtil;
+import net.bither.bitherj.utils.Utils;
import net.bither.preference.AppSharedPreference;
import net.bither.runnable.DownloadSpvRunnable;
import net.bither.util.BitherTimer;
@@ -340,10 +341,15 @@ public class BlockchainService extends android.app.Service {
return;
}
}
+ PeerManager peerManager = PeerManager.instance();
+ String customPeerDnsOrIp = AppSharedPreference.getInstance().getNetworkCustomPeerDnsOrIp();
+ if (!Utils.isEmpty(customPeerDnsOrIp)) {
+ peerManager.setCustomPeer(customPeerDnsOrIp, AppSharedPreference.getInstance().getNetworkCustomPeerPort());
+ }
if (AppSharedPreference.getInstance().getAppMode() != BitherjSettings.AppMode.COLD) {
if (!AppSharedPreference.getInstance().getBitherjDoneSyncFromSpv()) {
- if (!PeerManager.instance().isConnected()) {
- PeerManager.instance().start();
+ if (!peerManager.isConnected()) {
+ peerManager.start();
if (!spvFinishedReceivered) {
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(NotificationAndroidImpl.ACTION_SYNC_FROM_SPV_FINISHED);
@@ -357,7 +363,6 @@ public class BlockchainService extends android.app.Service {
TransactionsUtil.getMyTxFromBither();
}
startPeerManager();
-
}
}
} catch (Exception e) {

MODIFY
bither-android/src/net/bither/util/BroadcastUtil.java
bither-android/src/net/bither/util/BroadcastUtil.java
@@ -38,6 +38,7 @@ public class BroadcastUtil {
public static void sendBroadcastStartPeer() {
final Intent broadcast = new Intent(ACTION_START_PEER_MANAGER);
+ broadcast.setPackage(BitherApplication.mContext.getPackageName());
BitherApplication.mContext.sendBroadcast(broadcast);
}
@@ -46,6 +47,7 @@ public class BroadcastUtil {
if (tickers != null && tickers.size() > 0) {
MarketUtil.setTickerList(tickers);
final Intent broadcast = new Intent(ACTION_MARKET);
+ broadcast.setPackage(BitherApplication.mContext.getPackageName());
BitherApplication.mContext.sendBroadcast(broadcast);
}
}

MODIFY
bitherj
bitherj
-Subproject commit b8346e6c6d6d1bd1364ecbb2dac6a9ae2f76b850
+Subproject commit 1f063f6127fe5724bc9b04c116c15b6de7f517bd

support custom peer