Skip to content

Commit fb0861a

Browse files
committed
Ensure the version server has enough information to manage updates
1 parent 865432a commit fb0861a

File tree

1 file changed

+128
-115
lines changed

1 file changed

+128
-115
lines changed

core/src/com/biglybt/core/versioncheck/VersionCheckClient.java

+128-115
Original file line numberDiff line numberDiff line change
@@ -1486,14 +1486,14 @@ public boolean DHTEnableAllowed() {
14861486
constructVersionCheckMessage(
14871487
String reason )
14881488
{
1489-
1490-
//only send if anonymous-check flag is not set
1491-
1492-
boolean send_info = COConfigurationManager.getBooleanParameter( "Send Version Info" );
1489+
int last_send_time = COConfigurationManager.getIntParameter( "Send Version Info Last Time", -1 );
1490+
int current_send_time = (int)(SystemTime.getCurrentTime()/1000);
1491+
COConfigurationManager.setParameter( "Send Version Info Last Time", current_send_time );
14931492

14941493
Map<String,Object> message = new HashMap<>();
14951494

1496-
//always send
1495+
// always send
1496+
14971497
message.put( "appid", SystemProperties.getApplicationIdentifier());
14981498
message.put( "appname", SystemProperties.getApplicationName());
14991499
message.put( "version", Constants.BIGLYBT_VERSION );
@@ -1521,74 +1521,53 @@ public boolean DHTEnableAllowed() {
15211521
message.put( "os_arch", Constants.OSArch ); //see http://lopica.sourceforge.net/os.html
15221522
message.put( "os_arch_dm", System.getProperty( "sun.arch.data.model" ) ); // might be needed to openjdk on osx
15231523

1524-
boolean using_phe = COConfigurationManager.getBooleanParameter( "network.transport.encrypted.require" );
1525-
message.put( "using_phe", using_phe ? new Long(1) : new Long(0) );
1526-
15271524
message.put( "imode", COConfigurationManager.getStringParameter( "installer.mode", "" ));
15281525

1529-
//swt stuff
1530-
try {
1531-
Class c = Class.forName( "com.biglybt.ui.swt.Utils" );
1526+
if ( Constants.isAndroid ){
15321527

1528+
// Android update process doesn't use version server
15331529

1534-
String swt_platform = (String)c.getMethod( "getSWTPlatform", new Class[]{} ).invoke( null, new Object[]{} );
1535-
message.put( "swt_platform", swt_platform );
1530+
int api_level = Constants.API_LEVEL;
1531+
if ( api_level > 0 ){
1532+
message.put( "api_level", api_level );
1533+
}
15361534

1537-
Integer swt_version = (Integer)c.getMethod( "getSWTVersion", new Class[]{} ).invoke( null, new Object[]{} );
1538-
message.put( "swt_version", new Long( swt_version.longValue() ) );
1535+
}else{
1536+
1537+
// stuff required for the update process
1538+
1539+
// swt stuff
15391540

1540-
Integer swt_revision = (Integer)c.getMethod( "getSWTRevision", new Class[]{} ).invoke( null, new Object[]{} );
1541-
message.put( "swt_revision", new Long( swt_revision.longValue() ) );
1542-
}
1543-
1544-
catch( ClassNotFoundException e ) { /* ignore */ }
1545-
catch( NoClassDefFoundError er ) { /* ignore */ }
1546-
catch( InvocationTargetException err ) { /* ignore */ }
1547-
catch( Throwable t ) { t.printStackTrace(); }
1548-
1549-
1550-
int last_send_time = COConfigurationManager.getIntParameter( "Send Version Info Last Time", -1 );
1551-
int current_send_time = (int)(SystemTime.getCurrentTime()/1000);
1552-
COConfigurationManager.setParameter( "Send Version Info Last Time", current_send_time );
1553-
1554-
1555-
String id = COConfigurationManager.getStringParameter( "ID", null );
1556-
1557-
if( id != null && send_info ) {
1558-
message.put( "id", id );
1559-
15601541
try{
1561-
byte[] id2 = CryptoManagerFactory.getSingleton().getSecureID();
1562-
1563-
message.put( "id2", id2 );
1542+
Class c = Class.forName( "com.biglybt.ui.swt.Utils" );
15641543

1565-
}catch( Throwable e ){
1566-
}
1544+
1545+
String swt_platform = (String)c.getMethod( "getSWTPlatform", new Class[]{} ).invoke( null, new Object[]{} );
1546+
message.put( "swt_platform", swt_platform );
15671547

1568-
if ( last_send_time != -1 && last_send_time < current_send_time ){
1569-
// time since last
1570-
message.put( "tsl", new Long(current_send_time-last_send_time));
1548+
Integer swt_version = (Integer)c.getMethod( "getSWTVersion", new Class[]{} ).invoke( null, new Object[]{} );
1549+
message.put( "swt_version", new Long( swt_version.longValue() ) );
1550+
1551+
Integer swt_revision = (Integer)c.getMethod( "getSWTRevision", new Class[]{} ).invoke( null, new Object[]{} );
1552+
message.put( "swt_revision", new Long( swt_revision.longValue() ) );
15711553
}
1554+
1555+
catch( ClassNotFoundException e ) { /* ignore */ }
1556+
catch( NoClassDefFoundError er ) { /* ignore */ }
1557+
catch( InvocationTargetException err ) { /* ignore */ }
1558+
catch( Throwable t ) { t.printStackTrace(); }
15721559

1573-
message.put( "reason", reason );
1574-
1560+
// java stuff
1561+
15751562
String java_version = Constants.JAVA_VERSION;
15761563
if ( java_version == null ){ java_version = "unknown"; }
15771564
message.put( "java", java_version );
1578-
1579-
1565+
1566+
15801567
String java_vendor = System.getProperty( "java.vm.vendor" );
15811568
if ( java_vendor == null ){ java_vendor = "unknown"; }
15821569
message.put( "javavendor", java_vendor );
1583-
1584-
int api_level = Constants.API_LEVEL;
1585-
if ( api_level > 0 ){
1586-
message.put( "api_level", api_level );
1587-
}
1588-
1589-
long max_mem = Runtime.getRuntime().maxMemory()/(1024*1024);
1590-
message.put( "javamx", new Long( max_mem ) );
1591-
1570+
15921571
String java_rt_name = System.getProperty("java.runtime.name");
15931572
if (java_rt_name != null) {
15941573
message.put( "java_rt_name", java_rt_name);
@@ -1599,64 +1578,8 @@ public boolean DHTEnableAllowed() {
15991578
message.put( "java_rt_version", java_rt_version);
16001579
}
16011580

1602-
OverallStats stats = StatsFactory.getStats();
1603-
1604-
if ( stats != null ){
1605-
1606-
//long total_bytes_downloaded = stats.getDownloadedBytes();
1607-
//long total_bytes_uploaded = stats.getUploadedBytes();
1608-
long total_uptime = stats.getTotalUpTime();
1609-
1610-
//removed due to complaints about anonymous stats collection
1611-
//message.put( "total_bytes_downloaded", new Long( total_bytes_downloaded ) );
1612-
//message.put( "total_bytes_uploaded", new Long( total_bytes_uploaded ) );
1613-
message.put( "total_uptime", new Long( total_uptime ) );
1614-
//message.put( "dlstats", stats.getDownloadStats());
1615-
}
1616-
1617-
try{
1618-
int port = UDPNetworkManager.getSingleton().getUDPNonDataListeningPortNumber();
1619-
1620-
message.put( "dht", port );
1621-
1622-
}catch( Throwable e ){
1623-
1624-
Debug.out( e );
1625-
}
1626-
1627-
try{
1628-
NetworkAdminASN current_asn = NetworkAdmin.getSingleton().getCurrentASN();
1629-
1630-
message.put( "ip_as", current_asn.getAS());
1631-
1632-
String asn = current_asn.getASName();
1633-
1634-
if ( asn.length() > 64 ){
1635-
1636-
asn = asn.substring( 0, 64 );
1637-
}
1638-
1639-
message.put( "ip_asn", asn );
1640-
1641-
}catch( Throwable e ){
1642-
1643-
Debug.out( e );
1644-
}
1645-
1646-
// send locale, so we can determine which languages need attention
1647-
message.put("locale", Locale.getDefault().toString());
1648-
String originalLocale = System.getProperty("user.language") + "_"
1649-
+ System.getProperty("user.country");
1650-
String variant = System.getProperty("user.variant");
1651-
if (variant != null && variant.length() > 0) {
1652-
originalLocale += "_" + variant;
1653-
}
1654-
message.put("orig_locale", originalLocale);
1655-
1656-
// We may want to reply differently if the user is in Beginner mode vs Advanced
1657-
message.put("user_mode",
1658-
COConfigurationManager.getIntParameter("User Mode", -1));
1659-
1581+
// plugin stuff
1582+
16601583
try{
16611584
if ( CoreFactory.isCoreAvailable() &&
16621585
CoreFactory.getSingleton().getPluginManager().isInitialized()){
@@ -1735,8 +1658,98 @@ public boolean DHTEnableAllowed() {
17351658

17361659
Debug.out( e );
17371660
}
1738-
}
1661+
1662+
1663+
String id = COConfigurationManager.getStringParameter( "ID", null );
1664+
1665+
boolean send_info = COConfigurationManager.getBooleanParameter( "Send Version Info" );
17391666

1667+
if ( id != null && send_info ){
1668+
1669+
// stuff not required for managing updates but required for stats
1670+
1671+
message.put( "id", id );
1672+
1673+
try{
1674+
byte[] id2 = CryptoManagerFactory.getSingleton().getSecureID();
1675+
1676+
message.put( "id2", id2 );
1677+
1678+
}catch( Throwable e ){
1679+
}
1680+
1681+
if ( last_send_time != -1 && last_send_time < current_send_time ){
1682+
// time since last
1683+
message.put( "tsl", new Long(current_send_time-last_send_time));
1684+
}
1685+
1686+
message.put( "reason", reason );
1687+
1688+
long max_mem = Runtime.getRuntime().maxMemory()/(1024*1024);
1689+
message.put( "javamx", new Long( max_mem ) );
1690+
1691+
OverallStats stats = StatsFactory.getStats();
1692+
1693+
if ( stats != null ){
1694+
1695+
//long total_bytes_downloaded = stats.getDownloadedBytes();
1696+
//long total_bytes_uploaded = stats.getUploadedBytes();
1697+
long total_uptime = stats.getTotalUpTime();
1698+
1699+
//removed due to complaints about anonymous stats collection
1700+
//message.put( "total_bytes_downloaded", new Long( total_bytes_downloaded ) );
1701+
//message.put( "total_bytes_uploaded", new Long( total_bytes_uploaded ) );
1702+
message.put( "total_uptime", new Long( total_uptime ) );
1703+
//message.put( "dlstats", stats.getDownloadStats());
1704+
}
1705+
1706+
boolean using_phe = COConfigurationManager.getBooleanParameter( "network.transport.encrypted.require" );
1707+
message.put( "using_phe", using_phe ? new Long(1) : new Long(0) );
1708+
1709+
try{
1710+
int port = UDPNetworkManager.getSingleton().getUDPNonDataListeningPortNumber();
1711+
1712+
message.put( "dht", port );
1713+
1714+
}catch( Throwable e ){
1715+
1716+
Debug.out( e );
1717+
}
1718+
1719+
try{
1720+
NetworkAdminASN current_asn = NetworkAdmin.getSingleton().getCurrentASN();
1721+
1722+
message.put( "ip_as", current_asn.getAS());
1723+
1724+
String asn = current_asn.getASName();
1725+
1726+
if ( asn.length() > 64 ){
1727+
1728+
asn = asn.substring( 0, 64 );
1729+
}
1730+
1731+
message.put( "ip_asn", asn );
1732+
1733+
}catch( Throwable e ){
1734+
1735+
Debug.out( e );
1736+
}
1737+
1738+
// send locale, so we can determine which languages need attention
1739+
message.put("locale", Locale.getDefault().toString());
1740+
String originalLocale = System.getProperty("user.language") + "_"
1741+
+ System.getProperty("user.country");
1742+
String variant = System.getProperty("user.variant");
1743+
if (variant != null && variant.length() > 0) {
1744+
originalLocale += "_" + variant;
1745+
}
1746+
message.put("orig_locale", originalLocale);
1747+
1748+
// We may want to reply differently if the user is in Beginner mode vs Advanced
1749+
message.put("user_mode",
1750+
COConfigurationManager.getIntParameter("User Mode", -1));
1751+
}
1752+
}
17401753

17411754
return message;
17421755
}

0 commit comments

Comments
 (0)