Fix override of setCurrencySymbol in DecimalFormatSymbols

The implementation of fromIcuInstance tries to restore currencySymbol
from the ICU instance, but it's not effective because the subsequent
setting of internationalCurrencySymbol overrides the value of
currencySymbol. This patch just changes the order to avoid that.

Also includes a test to verify that overriding the currency symbol in
DecimalFormatSymbols is preserved in a roundtrip through the
DecimalFormat constructor.

Bug: 28732330
Change-Id: I9961459d9c479975e60c305de37daca58effd3cf
(cherry picked from commit d7f14d4672ba2d07fd7dfa7a74fb31879cd14369)
diff --git a/luni/src/test/java/libcore/java/text/DecimalFormatTest.java b/luni/src/test/java/libcore/java/text/DecimalFormatTest.java
index 2b8b566..ba8cbeb 100644
--- a/luni/src/test/java/libcore/java/text/DecimalFormatTest.java
+++ b/luni/src/test/java/libcore/java/text/DecimalFormatTest.java
@@ -320,6 +320,16 @@
         }
     }
 
+    // Test that overriding the currency symbol survives a roundrip through the
+    // DecimalFormat constructor.
+    // http://b/28732330
+    public void testSetCurrencySymbol() {
+        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.US);
+        decimalFormatSymbols.setCurrencySymbol("¥");
+        DecimalFormat decimalFormat = new DecimalFormat("¤#,##0.00", decimalFormatSymbols);
+        assertEquals("¥", decimalFormat.getDecimalFormatSymbols().getCurrencySymbol());
+    }
+
     private String formatArbitraryCurrencyAmountInLocale(Currency currency, Locale locale) {
         NumberFormat localeCurrencyFormat = NumberFormat.getCurrencyInstance(locale);
         localeCurrencyFormat.setCurrency(currency);
diff --git a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
index 4ae3097..c4cacc1 100755
--- a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
@@ -737,8 +737,8 @@
             result.setCurrency(Currency.getInstance("XXX"));
         }
 
-        result.setCurrencySymbol(dfs.getCurrencySymbol());
         result.setInternationalCurrencySymbol(dfs.getInternationalCurrencySymbol());
+        result.setCurrencySymbol(dfs.getCurrencySymbol());
         return result;
     }