Bug 1263390 - Post: Fix new "Registered" lint errors. r=mcomella
authorSebastian Kaspari <s.kaspari@gmail.com>
Wed, 20 Apr 2016 10:18:33 +0200
changeset 295512 58da59309c4615f784c827c4227d1b471d3688bb
parent 295511 1ac17eedc75ce78ec2060c0773809e55984e860b
child 295513 ba848d207bff32315e33e682b61b2a4d82cf2cf2
push id75951
push userkwierso@gmail.com
push dateFri, 29 Apr 2016 23:01:24 +0000
treeherdermozilla-inbound@f8896b71e9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1263390, 204846
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1263390 - Post: Fix new "Registered" lint errors. r=mcomella * GeckoActivity, LocaleAwareAppCompatActivity, LocaleAwareFragmentActivity, LocaleAwareActivity: Those activities are never instantiated directly. Make them abstract. * CrashReporter: This activity is only registered if MOZ_CRASHREPORTER is set. Supress warning. Unfortunately I had to downgrade this lint check from "error" to "warning" because the current gradle plugin doesn't recognize the SupressLint annotation for the "Registered" check: https://code.google.com/p/android/issues/detail?id=204846 MozReview-Commit-ID: Hy56pZB8ZdB
mobile/android/app/lint.xml
mobile/android/base/java/org/mozilla/gecko/CrashReporter.java
mobile/android/base/java/org/mozilla/gecko/GeckoActivity.java
mobile/android/base/java/org/mozilla/gecko/Locales.java
mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountWebFlowActivity.java
--- a/mobile/android/app/lint.xml
+++ b/mobile/android/app/lint.xml
@@ -30,16 +30,21 @@
     <issue id="NewApi" severity="warning" />
     <issue id="OnClick" severity="warning" />
     <issue id="ReferenceType" severity="warning" />
     <issue id="ResourceAsColor" severity="warning" />
     <issue id="ResourceType" severity="warning" />
     <issue id="ValidFragment" severity="warning" />
     <issue id="WrongConstant" severity="warning" />
 
+    <!-- We fixed all "Registered" lint errors. However the current gradle plugin has a bug where
+         it ignores @SuppressLint annotations for this check. See CrashReporter class and
+         https://code.google.com/p/android/issues/detail?id=204846 -->
+    <issue id="Registered" severity="warning" />
+
     <!-- WHEN YOU FIX A LINT WARNING, ADD IT TO THIS LIST.
 
          We want all lint warnings to be fatal errors.
          This is the list of checks that we've explicitly
          set as errors. Ideally, once we have no more warnings,
          we switch to the `warningsAsErrors` lint option
          (bug 1253737) rather than listing everything explicitly. -->
     <issue id="AaptCrash" severity="error" />
@@ -139,17 +144,16 @@
     <issue id="ParcelCreator" severity="error" />
     <issue id="Performance" severity="error" />
     <issue id="Proguard" severity="error" />
     <issue id="ProguardSplit" severity="error" />
     <issue id="PropertyEscape" severity="error" />
     <issue id="ProtectedPermissions" severity="error" />
     <issue id="PxUsage" severity="error" />
     <issue id="Range" severity="error" />
-    <issue id="Registered" severity="error" />
     <issue id="RelativeOverlap" severity="error" />
     <issue id="RequiredSize" severity="error" />
     <issue id="ResAuto" severity="error" />
     <issue id="ResourceCycle" severity="error" />
     <issue id="ResourceName" severity="error" />
     <issue id="ResourceType" severity="error" />
     <issue id="RtlCompat" severity="error" />
     <issue id="RtlEnabled" severity="error" />
--- a/mobile/android/base/java/org/mozilla/gecko/CrashReporter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/CrashReporter.java
@@ -18,32 +18,34 @@ import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.nio.channels.Channels;
 import java.nio.channels.FileChannel;
 import java.util.zip.GZIPOutputStream;
 
 import org.mozilla.gecko.AppConstants.Versions;
 
+import android.annotation.SuppressLint;
 import android.app.AlertDialog;
 import android.app.ProgressDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.support.v7.app.AppCompatActivity;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
 import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.EditText;
 
+@SuppressLint("Registered") // This activity is only registered in the manifest if MOZ_CRASHREPORTER is set
 public class CrashReporter extends AppCompatActivity
 {
     private static final String LOGTAG = "GeckoCrashReporter";
 
     private static final String PASSED_MINI_DUMP_KEY = "minidumpPath";
     private static final String MINI_DUMP_PATH_KEY = "upload_file_minidump";
     private static final String PAGE_URL_KEY = "URL";
     private static final String NOTES_KEY = "Notes";
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoActivity.java
@@ -3,17 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import android.content.ComponentName;
 import android.content.Intent;
 import android.support.v7.app.AppCompatActivity;
 
-public class GeckoActivity extends AppCompatActivity implements GeckoActivityStatus {
+public abstract class GeckoActivity extends AppCompatActivity implements GeckoActivityStatus {
     // has this activity recently started another Gecko activity?
     private boolean mGeckoActivityOpened;
 
     /**
      * Display any resources that show strings or encompass locale-specific
      * representations.
      *
      * onLocaleReady must always be called on the UI thread.
--- a/mobile/android/base/java/org/mozilla/gecko/Locales.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Locales.java
@@ -43,33 +43,33 @@ public class Locales {
         StrictMode.allowThreadDiskWrites();
         try {
             localeManager.getAndApplyPersistedLocale(context);
         } finally {
             StrictMode.setThreadPolicy(savedPolicy);
         }
     }
 
-    public static class LocaleAwareAppCompatActivity extends AppCompatActivity {
+    public static abstract class LocaleAwareAppCompatActivity extends AppCompatActivity {
         @Override
         protected void onCreate(Bundle savedInstanceState) {
             Locales.initializeLocale(getApplicationContext());
             super.onCreate(savedInstanceState);
         }
 
     }
-    public static class LocaleAwareFragmentActivity extends FragmentActivity {
+    public static abstract class LocaleAwareFragmentActivity extends FragmentActivity {
         @Override
         protected void onCreate(Bundle savedInstanceState) {
             Locales.initializeLocale(getApplicationContext());
             super.onCreate(savedInstanceState);
         }
     }
 
-    public static class LocaleAwareActivity extends Activity {
+    public static abstract class LocaleAwareActivity extends Activity {
         @Override
         protected void onCreate(Bundle savedInstanceState) {
             Locales.initializeLocale(getApplicationContext());
             super.onCreate(savedInstanceState);
         }
     }
 
     /**
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountWebFlowActivity.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountWebFlowActivity.java
@@ -9,17 +9,17 @@ import android.os.Bundle;
 import org.mozilla.gecko.Locales;
 import org.mozilla.gecko.background.common.log.Logger;
 import org.mozilla.gecko.fxa.FxAccountConstants;
 import org.mozilla.gecko.sync.setup.activities.ActivityUtils;
 
 /**
  * Activity which shows the status activity or passes through to web flow.
  */
-public class FxAccountWebFlowActivity extends FxAccountAbstractActivity {
+public abstract class FxAccountWebFlowActivity extends FxAccountAbstractActivity {
     protected static final String LOG_TAG = FxAccountWebFlowActivity.class.getSimpleName();
 
     protected static final String ABOUT_ACCOUNTS = "about:accounts";
 
     public static final String EXTRA_ENDPOINT = "entrypoint";
 
     protected static final String[] EXTRAS_TO_PASSTHROUGH = new String[] {
             EXTRA_ENDPOINT,