Ver código fonte

Push fix

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 8 anos atrás
pai
commit
8b923ad8e7

+ 4 - 24
src/gplay/java/com/owncloud/android/utils/PushUtils.java

@@ -76,7 +76,7 @@ public class PushUtils {
 
     private static ArbitraryDataProvider arbitraryDataProvider;
 
-    private static String generateSHA512Hash(String pushToken) {
+    public static String generateSHA512Hash(String pushToken) {
         MessageDigest messageDigest = null;
         try {
             messageDigest = MessageDigest.getInstance("SHA-512");
@@ -88,7 +88,7 @@ public class PushUtils {
         return "";
     }
 
-    private static String bytesToHex(byte[] bytes) {
+    public static String bytesToHex(byte[] bytes) {
         StringBuilder result = new StringBuilder();
         for (byte individualByte : bytes) {
             result.append(Integer.toString((individualByte & 0xff) + 0x100, 16)
@@ -96,7 +96,7 @@ public class PushUtils {
         }
         return result.toString();
     }
-
+    
     private static int generateRsa2048KeyPair() {
         String keyPath = MainApp.getStoragePath() + File.separator + MainApp.getDataFolder() + File.separator
                 + KEYPAIR_FOLDER;
@@ -241,31 +241,11 @@ public class PushUtils {
                                 remoteOperationResult = registerAccountDeviceForProxyOperation.execute(mClient);
 
                                 if (remoteOperationResult.isSuccess()) {
-<<<<<<< Updated upstream
-                                    PushResponse pushResponse = remoteOperationResult.getPushResponseData();
-
-                                    RemoteOperation registerAccountDeviceForProxyOperation = new
-                                            RegisterAccountDeviceForProxyOperation(
-                                            context.getResources().getString(R.string.push_server_url),
-                                            token, pushResponse.getDeviceIdentifier(), pushResponse.getSignature(),
-                                            pushResponse.getPublicKey());
-
-                                    remoteOperationResult = registerAccountDeviceForProxyOperation.execute(mClient);
-
-                                    if (remoteOperationResult.isSuccess()) {
-                                        PushConfigurationState pushArbitraryData = new PushConfigurationState(token,
-                                                pushResponse.getDeviceIdentifier(), pushResponse.getSignature(),
-                                                pushResponse.getPublicKey(), false);
-                                        arbitraryDataProvider.storeOrUpdateKeyValue(account, KEY_PUSH,
-                                                gson.toJson(pushArbitraryData));
-                                    }
-=======
                                     PushConfigurationState pushArbitraryData = new PushConfigurationState(token,
                                             pushResponse.getDeviceIdentifier(), pushResponse.getSignature(),
                                             pushResponse.getPublicKey(), false);
-                                    arbitraryDataProvider.storeOrUpdateKeyValue(account.name, KEY_PUSH,
+                                    arbitraryDataProvider.storeOrUpdateKeyValue(account, KEY_PUSH,
                                             gson.toJson(pushArbitraryData));
->>>>>>> Stashed changes
                                 }
                             }
                         } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {

+ 1 - 21
src/modified/java/com/owncloud/android/utils/PushUtils.java

@@ -241,31 +241,11 @@ public class PushUtils {
                                 remoteOperationResult = registerAccountDeviceForProxyOperation.execute(mClient);
 
                                 if (remoteOperationResult.isSuccess()) {
-<<<<<<< Updated upstream
-                                    PushResponse pushResponse = remoteOperationResult.getPushResponseData();
-
-                                    RemoteOperation registerAccountDeviceForProxyOperation = new
-                                            RegisterAccountDeviceForProxyOperation(
-                                            context.getResources().getString(R.string.push_server_url),
-                                            token, pushResponse.getDeviceIdentifier(), pushResponse.getSignature(),
-                                            pushResponse.getPublicKey());
-
-                                    remoteOperationResult = registerAccountDeviceForProxyOperation.execute(mClient);
-
-                                    if (remoteOperationResult.isSuccess()) {
-                                        PushConfigurationState pushArbitraryData = new PushConfigurationState(token,
-                                                pushResponse.getDeviceIdentifier(), pushResponse.getSignature(),
-                                                pushResponse.getPublicKey(), false);
-                                        arbitraryDataProvider.storeOrUpdateKeyValue(account, KEY_PUSH,
-                                                gson.toJson(pushArbitraryData));
-                                    }
-=======
                                     PushConfigurationState pushArbitraryData = new PushConfigurationState(token,
                                             pushResponse.getDeviceIdentifier(), pushResponse.getSignature(),
                                             pushResponse.getPublicKey(), false);
-                                    arbitraryDataProvider.storeOrUpdateKeyValue(account.name, KEY_PUSH,
+                                    arbitraryDataProvider.storeOrUpdateKeyValue(account, KEY_PUSH,
                                             gson.toJson(pushArbitraryData));
->>>>>>> Stashed changes
                                 }
                             }
                         } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {