Bug 1240579 - Rename Assert to ReleaseAssert. r?margaret draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 18 Jan 2016 11:29:26 -0800
changeset 322459 f23e08aeb614d7d4d7eedc7fd74f1f8435c1d476
parent 322458 9f9b83007c01f8e86cf65148c193d8aec7369d35
child 513118 76c98f351fa7ffc316471cb1f5c3bcf0997f3aa8
push id9620
push usernalexander@mozilla.com
push dateMon, 18 Jan 2016 19:31:06 +0000
reviewersmargaret
bugs1240579
milestone46.0a1
Bug 1240579 - Rename Assert to ReleaseAssert. r?margaret Having org.mozilla.gecko.Assert in both the main APK and the androidTest APK is not well supported by the Android toolchain. It's much simpler to rename the one in the main APK.
mobile/android/base/java/org/mozilla/gecko/Assert.java
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/ReleaseAssert.java
mobile/android/base/java/org/mozilla/gecko/db/LocalURLMetadata.java
mobile/android/base/java/org/mozilla/gecko/overlays/service/OverlayActionService.java
mobile/android/base/java/org/mozilla/gecko/overlays/ui/SendTabDeviceListArrayAdapter.java
mobile/android/base/java/org/mozilla/gecko/overlays/ui/SendTabList.java
mobile/android/base/java/org/mozilla/gecko/overlays/ui/ShareDialog.java
mobile/android/base/java/org/mozilla/gecko/webapp/InstallListener.java
mobile/android/base/moz.build
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -133,16 +133,17 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewStub;
 import android.view.ViewTreeObserver;
 import android.view.Window;
 import android.view.animation.Interpolator;
 import android.widget.Button;
 import android.widget.ListView;
 import android.widget.RelativeLayout;
+import android.widget.Toast;
 import android.widget.ViewFlipper;
 import com.keepsafe.switchboard.AsyncConfigLoader;
 import com.keepsafe.switchboard.SwitchBoard;
 import com.nineoldandroids.animation.Animator;
 import com.nineoldandroids.animation.ObjectAnimator;
 import org.json.JSONException;
 import org.json.JSONObject;
 
rename from mobile/android/base/java/org/mozilla/gecko/Assert.java
rename to mobile/android/base/java/org/mozilla/gecko/ReleaseAssert.java
--- a/mobile/android/base/java/org/mozilla/gecko/Assert.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ReleaseAssert.java
@@ -7,19 +7,19 @@ package org.mozilla.gecko;
  * poor behaviour w.r.t bytecode bloat (and to a lesser extent, runtime performance when disabled)
  *
  * Calls to methods in this class will be stripped by Proguard for release builds, so may be used
  * arbitrarily liberally at zero cost.
  * Under no circumstances should the argument expressions to methods in this class have side effects
  * relevant to the correctness of execution of the program. Such side effects shall not be checked
  * for when stripping assertions.
  */
-public class Assert {
+public class ReleaseAssert {
     // Static helper class.
-    private Assert() {}
+    private ReleaseAssert() {}
 
     /**
      * Verify that two objects are equal according to their equals method.
      */
     public static void equal(Object a, Object b) {
         equal(a, b, "Assertion failure: !" + a + ".equals(" + b + ')');
     }
     public static void equal(Object a, Object b, String message) {
--- a/mobile/android/base/java/org/mozilla/gecko/db/LocalURLMetadata.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/LocalURLMetadata.java
@@ -11,17 +11,17 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.json.JSONException;
 import org.json.JSONObject;
-import org.mozilla.gecko.Assert;
+import org.mozilla.gecko.ReleaseAssert;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.database.Cursor;
 import android.net.Uri;
@@ -104,17 +104,17 @@ public class LocalURLMetadata implements
                 }
 
                 String iconURL = icons.getString(Integer.toString(bestSizeFound));
 
                 data.put(URLMetadataTable.TOUCH_ICON_COLUMN, iconURL);
             }
         } catch (JSONException e) {
             Log.w(LOGTAG, "Exception processing touchIconList for LocalURLMetadata; ignoring.", e);
-            Assert.isTrue(false);
+            ReleaseAssert.isTrue(false);
         }
 
         return Collections.unmodifiableMap(data);
     }
 
     /**
      * Converts a Cursor into a unmodifiable Map of known metadata properties.
      * Will throw away any properties that aren't stored in the database.
--- a/mobile/android/base/java/org/mozilla/gecko/overlays/service/OverlayActionService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/overlays/service/OverlayActionService.java
@@ -6,17 +6,17 @@
 package org.mozilla.gecko.overlays.service;
 
 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.os.IBinder;
 import android.util.Log;
 
-import org.mozilla.gecko.Assert;
+import org.mozilla.gecko.ReleaseAssert;
 import org.mozilla.gecko.overlays.service.sharemethods.AddBookmark;
 import org.mozilla.gecko.overlays.service.sharemethods.AddToReadingList;
 import org.mozilla.gecko.overlays.service.sharemethods.SendTab;
 import org.mozilla.gecko.overlays.service.sharemethods.ShareMethod;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import java.util.EnumMap;
 import java.util.Map;
@@ -117,15 +117,15 @@ public class OverlayActionService extend
                         Log.d(LOGTAG, "Share was successful");
                         break;
                     case TRANSIENT_FAILURE:
                         // Fall-through
                     case PERMANENT_FAILURE:
                         Log.e(LOGTAG, "Share failed: " + result);
                         break;
                     default:
-                        Assert.fail("Unknown share method result code: " + result);
+                        ReleaseAssert.fail("Unknown share method result code: " + result);
                         break;
                 }
             }
         });
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/overlays/ui/SendTabDeviceListArrayAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/overlays/ui/SendTabDeviceListArrayAdapter.java
@@ -2,30 +2,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.overlays.ui;
 
 import java.util.Collection;
 
 import org.mozilla.gecko.AppConstants;
-import org.mozilla.gecko.Assert;
+import org.mozilla.gecko.ReleaseAssert;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.db.RemoteClient;
 import org.mozilla.gecko.overlays.ui.SendTabList.State;
 
 import android.app.AlertDialog;
 import android.content.Context;
 import android.graphics.drawable.Drawable;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
 
 public class SendTabDeviceListArrayAdapter extends ArrayAdapter<RemoteClient> {
     @SuppressWarnings("unused")
     private static final String LOGTAG = "GeckoSendTabAdapter";
 
     private State currentState;
 
     // String to display when in a "button-like" special state. Instead of using a
@@ -169,17 +167,17 @@ public class SendTabDeviceListArrayAdapt
                 break;
             case NONE:
                 showDummyRecord(getContext().getResources().getString(R.string.overlay_share_send_tab_btn_label));
                 break;
             case SHOW_DEVICES:
                 showDummyRecord(getContext().getResources().getString(R.string.overlay_share_send_other));
                 break;
             default:
-                Assert.fail("Unexpected state transition: " + newState);
+                ReleaseAssert.fail("Unexpected state transition: " + newState);
         }
     }
 
     /**
      * Set the dummy override string to the given value and clear the list.
      */
     private void showDummyRecord(String name) {
         dummyRecordName = name;
--- a/mobile/android/base/java/org/mozilla/gecko/overlays/ui/SendTabList.java
+++ b/mobile/android/base/java/org/mozilla/gecko/overlays/ui/SendTabList.java
@@ -4,18 +4,17 @@
 
 package org.mozilla.gecko.overlays.ui;
 
 import static org.mozilla.gecko.overlays.ui.SendTabList.State.LOADING;
 import static org.mozilla.gecko.overlays.ui.SendTabList.State.SHOW_DEVICES;
 
 import java.util.Arrays;
 
-import org.mozilla.gecko.AppConstants.Versions;
-import org.mozilla.gecko.Assert;
+import org.mozilla.gecko.ReleaseAssert;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.RemoteClient;
 
 import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -82,17 +81,17 @@ public class SendTabList extends ListVie
     }
 
     public SendTabList(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
     @Override
     public void setAdapter(ListAdapter adapter) {
-        Assert.isTrue(adapter instanceof SendTabDeviceListArrayAdapter);
+        ReleaseAssert.isTrue(adapter instanceof SendTabDeviceListArrayAdapter);
 
         clientListAdapter = (SendTabDeviceListArrayAdapter) adapter;
         super.setAdapter(adapter);
     }
 
     public void setSendTabTargetSelectedListener(SendTabTargetSelectedListener aListener) {
         listener = aListener;
     }
--- a/mobile/android/base/java/org/mozilla/gecko/overlays/ui/ShareDialog.java
+++ b/mobile/android/base/java/org/mozilla/gecko/overlays/ui/ShareDialog.java
@@ -3,17 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.overlays.ui;
 
 import java.net.URISyntaxException;
 
 import org.mozilla.gecko.AppConstants;
-import org.mozilla.gecko.Assert;
+import org.mozilla.gecko.ReleaseAssert;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.Locales;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.LocalBrowserDB;
 import org.mozilla.gecko.db.RemoteClient;
 import org.mozilla.gecko.overlays.OverlayConstants;
@@ -364,26 +364,26 @@ public class ShareDialog extends Locales
      * Button handlers. Send intents to the background service responsible for processing requests
      * on Fennec in the background. (a nice extensible mechanism for "doing stuff without properly
      * launching Fennec").
      */
 
     @Override
     public void onSendTabActionSelected() {
         // This requires an override intent.
-        Assert.isTrue(sendTabOverrideIntent != null);
+        ReleaseAssert.isTrue(sendTabOverrideIntent != null);
 
         startActivity(sendTabOverrideIntent);
         finish();
     }
 
     @Override
     public void onSendTabTargetSelected(String targetGUID) {
         // targetGUID being null with no override intent should be an impossible state.
-        Assert.isTrue(targetGUID != null);
+        ReleaseAssert.isTrue(targetGUID != null);
 
         Intent serviceIntent = getServiceIntent(ShareMethod.Type.SEND_TAB);
 
         // Currently, only one extra parameter is necessary (the GUID of the target device).
         Bundle extraParameters = new Bundle();
 
         // Future: Handle multiple-selection. Bug 1061297.
         extraParameters.putStringArray(SendTab.SEND_TAB_TARGET_DEVICES, new String[] { targetGUID });
--- a/mobile/android/base/java/org/mozilla/gecko/webapp/InstallListener.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapp/InstallListener.java
@@ -5,17 +5,17 @@
 
 package org.mozilla.gecko.webapp;
 
 import java.io.File;
 import java.io.IOException;
 
 import org.json.JSONException;
 import org.json.JSONObject;
-import org.mozilla.gecko.Assert;
+import org.mozilla.gecko.ReleaseAssert;
 import org.mozilla.gecko.GeckoThread;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.text.TextUtils;
 import android.util.Log;
@@ -27,18 +27,18 @@ public class InstallListener extends Bro
     private final String mManifestUrl;
     private boolean mReceived;
     private final File mApkFile;
 
     public InstallListener(String manifestUrl, JSONObject data, File apkFile) {
         mData = data;
         mApkFile = apkFile;
         mManifestUrl = manifestUrl;
-        Assert.isNotNull(mManifestUrl);
-        Assert.isTrue(mApkFile != null && mApkFile.exists());
+        ReleaseAssert.isNotNull(mManifestUrl);
+        ReleaseAssert.isTrue(mApkFile != null && mApkFile.exists());
     }
 
     public boolean isReceived() {
         return mReceived;
     }
 
     @Override
     public void onReceive(Context context, Intent intent) {
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -197,17 +197,16 @@ gbjar.sources += ['java/org/mozilla/geck
     'animation/BounceAnimatorBuilder.java',
     'animation/HeightChangeAnimation.java',
     'animation/PropertyAnimator.java',
     'animation/Rotate3DAnimation.java',
     'animation/TransitionsTracker.java',
     'animation/ViewHelper.java',
     'ANRReporter.java',
     'AppNotificationClient.java',
-    'Assert.java',
     'BaseGeckoInterface.java',
     'BrowserApp.java',
     'BrowserLocaleManager.java',
     'ContactService.java',
     'ContextGetter.java',
     'CrashHandler.java',
     'CustomEditText.java',
     'DataReportingNotification.java',
@@ -490,16 +489,17 @@ gbjar.sources += ['java/org/mozilla/geck
     'prompts/Prompt.java',
     'prompts/PromptInput.java',
     'prompts/PromptListAdapter.java',
     'prompts/PromptListItem.java',
     'prompts/PromptService.java',
     'prompts/TabInput.java',
     'ReaderModeUtils.java',
     'ReadingListHelper.java',
+    'ReleaseAssert.java',
     'RemoteClientsDialogFragment.java',
     'RemoteTabsExpandableListAdapter.java',
     'Restarter.java',
     'Restrictions.java',
     'restrictions/DefaultConfiguration.java',
     'restrictions/GuestProfileConfiguration.java',
     'restrictions/Restrictable.java',
     'restrictions/RestrictedProfileConfiguration.java',