@@ -73,7 +73,10 @@ public class TdlibSettingsManager implements CleanupStartupDelegate {
7373 public static final String DEVICE_TOKEN_TYPE_KEY = "registered_device_token_type" ;
7474 public static final String DEVICE_UID_KEY = "registered_device_uid" ;
7575 public static final String DEVICE_OTHER_UID_KEY = "registered_device_uid_other" ;
76- public static final String DEVICE_TDLIB_VERSION_KEY = "registered_device_tdlib" ;
76+ @ Deprecated
77+ @ SuppressWarnings ("DeprecatedIsStillUsed" )
78+ public static final String __DEVICE_TDLIB_VERSION_KEY = "registered_device_tdlib" ;
79+ public static final String DEVICE_TDLIB_VERSION2_KEY = "registered_device_td" ;
7780
7881 public static final String NOTIFICATION_ERROR_KEY = "notification_error" ;
7982 public static final String NOTIFICATION_VERSION_KEY = "notification_version" ;
@@ -587,8 +590,8 @@ private static long getRegisteredDeviceUserId (int accountId) {
587590 return Settings .instance ().getLong (key (DEVICE_UID_KEY , accountId ), 0 );
588591 }
589592
590- private static int getRegisteredDeviceTdlibVersion (int accountId ) {
591- return Settings .instance ().getInt (key (DEVICE_TDLIB_VERSION_KEY , accountId ), 0 );
593+ private static String getRegisteredDeviceTdlibVersion2 (int accountId ) {
594+ return Settings .instance ().getString (key (DEVICE_TDLIB_VERSION2_KEY , accountId ), "" );
592595 }
593596
594597 @ Nullable
@@ -629,7 +632,7 @@ public static void setRegisteredDevice (int accountId, long userId, TdApi.Device
629632 }
630633 }
631634 pmc .putLong (key (DEVICE_UID_KEY , accountId ), userId );
632- pmc .putInt (key (DEVICE_TDLIB_VERSION_KEY , accountId ), BuildConfig .TDLIB_VERSION );
635+ pmc .putString (key (DEVICE_TDLIB_VERSION2_KEY , accountId ), BuildConfig .TDLIB_VERSION );
633636 if (otherUserIds != null && otherUserIds .length > 0 ) {
634637 pmc .putLongArray (key (DEVICE_OTHER_UID_KEY , accountId ), otherUserIds );
635638 } else {
@@ -641,7 +644,7 @@ public static void setRegisteredDevice (int accountId, long userId, TdApi.Device
641644
642645 public static boolean checkRegisteredDeviceToken (int accountId , long userId , TdApi .DeviceToken token , long [] otherUserIds , boolean skipOtherUserIdsCheck ) {
643646 return
644- getRegisteredDeviceTdlibVersion ( accountId ) == BuildConfig .TDLIB_VERSION &&
647+ BuildConfig .TDLIB_VERSION . equals ( getRegisteredDeviceTdlibVersion2 ( accountId )) &&
645648 getRegisteredDeviceUserId (accountId ) == userId &&
646649 Td .equalsTo (getRegisteredDeviceToken (accountId ), token ) &&
647650 (skipOtherUserIdsCheck || Arrays .equals (getRegisteredDeviceOtherUserIds (accountId ), otherUserIds != null && otherUserIds .length > 0 ? otherUserIds : null ));
@@ -653,7 +656,7 @@ public static void unregisterDevice (int accountId) {
653656 .remove (key (DEVICE_TOKEN_TYPE_KEY , accountId ))
654657 .remove (key (DEVICE_UID_KEY , accountId ))
655658 .remove (key (DEVICE_OTHER_UID_KEY , accountId ))
656- .remove (key (DEVICE_TDLIB_VERSION_KEY , accountId ))
659+ .remove (key (DEVICE_TDLIB_VERSION2_KEY , accountId ))
657660 .apply ();
658661 }
659662
0 commit comments