Bug 1363885 - 1. Remove GeckoAppShell.AppStateListener; r=droeh
authorJim Chen <nchen@mozilla.com>
Thu, 25 May 2017 18:33:30 -0400
changeset 360702 de4a54a0212ca8e57a770aa1794c8383902c02b9
parent 360701 b4c5cb5344327aef49d733d4c9c2cf86ee331fc6
child 360703 6b91b33444eb0b779bc18da64bb1abc17b5314a6
push id90718
push usernchen@mozilla.com
push dateThu, 25 May 2017 22:34:28 +0000
treeherdermozilla-inbound@35d857a41a7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdroeh
bugs1363885
milestone55.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 1363885 - 1. Remove GeckoAppShell.AppStateListener; r=droeh Remove GeckoAppShell.AppStateListener and its associated methods in GeckoInterface (orientation listener and app state listener methods). MozReview-Commit-ID: 4BCrTysSEHZ
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/BaseGeckoInterface.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -182,17 +182,16 @@ public abstract class GeckoApp extends G
     protected boolean mIgnoreLastSelectedTab;
     protected static WeakReference<GeckoApp> mLastActiveGeckoApp;
 
     protected RelativeLayout mRootLayout;
     protected RelativeLayout mMainLayout;
 
     protected RelativeLayout mGeckoLayout;
     private OrientationEventListener mCameraOrientationEventListener;
-    public List<GeckoAppShell.AppStateListener> mAppStateListeners = new LinkedList<GeckoAppShell.AppStateListener>();
     protected MenuPanel mMenuPanel;
     protected Menu mMenu;
     protected boolean mIsRestoringActivity;
 
     /** Tells if we're aborting app launch, e.g. if this is an unsupported device configuration. */
     protected boolean mIsAbortingAppLaunch;
 
     private PromptService mPromptService;
@@ -402,26 +401,16 @@ public abstract class GeckoApp extends G
         return GeckoSharedPrefs.forApp(this);
     }
 
     public SharedPreferences getSharedPreferencesForProfile() {
         return GeckoSharedPrefs.forProfile(this);
     }
 
     @Override
-    public void addAppStateListener(GeckoAppShell.AppStateListener listener) {
-        mAppStateListeners.add(listener);
-    }
-
-    @Override
-    public void removeAppStateListener(GeckoAppShell.AppStateListener listener) {
-        mAppStateListeners.remove(listener);
-    }
-
-    @Override
     public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
         // When a tab is closed, it is always unselected first.
         // When a tab is unselected, another tab is always selected first.
         switch (msg) {
             case UNSELECTED:
                 break;
 
             case LOCATION_CHANGE:
@@ -1837,19 +1826,16 @@ public abstract class GeckoApp extends G
         // Check if launched from data reporting notification.
         if (ACTION_LAUNCH_SETTINGS.equals(action)) {
             Intent settingsIntent = new Intent(GeckoApp.this, GeckoPreferences.class);
             // Copy extras.
             settingsIntent.putExtras(intent.getUnsafe());
             startActivity(settingsIntent);
         }
 
-        //app state callbacks
-        mAppStateListeners = new LinkedList<GeckoAppShell.AppStateListener>();
-
         mPromptService = new PromptService(this);
 
         // Trigger the completion of the telemetry timer that wraps activity startup,
         // then grab the duration to give to FHR.
         mJavaUiStartupTimer.stop();
         final long javaDuration = mJavaUiStartupTimer.getElapsed();
 
         ThreadUtils.getBackgroundHandler().postDelayed(new Runnable() {
@@ -2122,40 +2108,16 @@ public abstract class GeckoApp extends G
 
         StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                                .detectAll()
                                .penaltyLog()
                                .build());
     }
 
     @Override
-    public void enableOrientationListener() {
-        // Start listening for orientation events
-        mCameraOrientationEventListener = new OrientationEventListener(this) {
-            @Override
-            public void onOrientationChanged(int orientation) {
-                if (mAppStateListeners != null) {
-                    for (GeckoAppShell.AppStateListener listener: mAppStateListeners) {
-                        listener.onOrientationChanged();
-                    }
-                }
-            }
-        };
-        mCameraOrientationEventListener.enable();
-    }
-
-    @Override
-    public void disableOrientationListener() {
-        if (mCameraOrientationEventListener != null) {
-            mCameraOrientationEventListener.disable();
-            mCameraOrientationEventListener = null;
-        }
-    }
-
-    @Override
     protected void onNewIntent(Intent externalIntent) {
         final SafeIntent intent = new SafeIntent(externalIntent);
         final String action = intent.getAction();
 
         final boolean isFirstTab = !mWasFirstTabShownAfterActivityUnhidden;
         mWasFirstTabShownAfterActivityUnhidden = true; // Reset since we'll be loading a tab.
         if (!Intent.ACTION_MAIN.equals(action)) {
             mIgnoreLastSelectedTab = true;
@@ -2314,22 +2276,16 @@ public abstract class GeckoApp extends G
         mSuppressActivitySwitch = false;
         mIgnoreLastSelectedTab = false;
 
         int newOrientation = getResources().getConfiguration().orientation;
         if (GeckoScreenOrientation.getInstance().update(newOrientation)) {
             refreshChrome();
         }
 
-        if (mAppStateListeners != null) {
-            for (GeckoAppShell.AppStateListener listener : mAppStateListeners) {
-                listener.onResume();
-            }
-        }
-
         // We use two times: a pseudo-unique wall-clock time to identify the
         // current session across power cycles, and the elapsed realtime to
         // track the duration of the session.
         final long now = System.currentTimeMillis();
         final long realTime = android.os.SystemClock.elapsedRealtime();
 
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
@@ -2427,22 +2383,16 @@ public abstract class GeckoApp extends G
 
                     editor.putBoolean(GeckoApp.PREFS_CLEANUP_TEMP_FILES, false);
                 }
 
                 editor.apply();
             }
         });
 
-        if (mAppStateListeners != null) {
-            for (GeckoAppShell.AppStateListener listener : mAppStateListeners) {
-                listener.onPause();
-            }
-        }
-
         super.onPause();
     }
 
     @Override
     public void onRestart() {
         if (mIsAbortingAppLaunch) {
             super.onRestart();
             return;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/BaseGeckoInterface.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/BaseGeckoInterface.java
@@ -16,30 +16,16 @@ import android.widget.AbsoluteLayout;
 public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
     private final Context mContext;
 
     public BaseGeckoInterface(Context context) {
         mContext = context;
     }
 
     @Override
-    public void enableOrientationListener() {}
-
-    @Override
-    public void disableOrientationListener() {}
-
-    // Bug 908786: Implement this
-    @Override
-    public void addAppStateListener(GeckoAppShell.AppStateListener listener) {}
-
-    // Bug 908787: Implement this
-    @Override
-    public void removeAppStateListener(GeckoAppShell.AppStateListener listener) {}
-
-    @Override
     public boolean openUriExternal(String targetURI, String mimeType, String packageName, String className, String action, String title) {
         // By default, never open external URIs.
         return false;
     }
 
     @Override
     public String[] getHandlersForMimeType(String mimeType, String action) {
         // By default, offer no handlers for any MIME type.
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1649,28 +1649,17 @@ public class GeckoAppShell
 
     public static SharedPreferences getSharedPreferences() {
         if (sContextGetter == null) {
             throw new IllegalStateException("No ContextGetter; cannot fetch prefs.");
         }
         return sContextGetter.getSharedPreferences();
     }
 
-    public interface AppStateListener {
-        public void onPause();
-        public void onResume();
-        public void onOrientationChanged();
-    }
-
     public interface GeckoInterface {
-        public void enableOrientationListener();
-        public void disableOrientationListener();
-        public void addAppStateListener(AppStateListener listener);
-        public void removeAppStateListener(AppStateListener listener);
-
         public boolean openUriExternal(String targetURI, String mimeType, String packageName, String className, String action, String title);
 
         public String[] getHandlersForMimeType(String mimeType, String action);
         public String[] getHandlersForURL(String url, String action);
     };
 
     private static GeckoInterface sGeckoInterface;
 
@@ -1704,26 +1693,16 @@ public class GeckoAppShell
             if (sCamera != null) {
                 sCamera.addCallbackBuffer(sCameraBuffer);
             }
         }
     }
 
     @WrapForJNI(calledFrom = "gecko")
     private static int[] initCamera(String aContentType, int aCamera, int aWidth, int aHeight) {
-        ThreadUtils.postToUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        if (getGeckoInterface() != null)
-                            getGeckoInterface().enableOrientationListener();
-                    } catch (Exception e) { }
-                }
-            });
-
         // [0] = 0|1 (failure/success)
         // [1] = width
         // [2] = height
         // [3] = fps
         int[] result = new int[4];
         result[0] = 0;
 
         if (Camera.getNumberOfCameras() == 0) {
@@ -1778,25 +1757,16 @@ public class GeckoAppShell
             Log.w(LOGTAG, "initCamera RuntimeException.", e);
             result[0] = result[1] = result[2] = result[3] = 0;
         }
         return result;
     }
 
     @WrapForJNI(calledFrom = "gecko")
     private static synchronized void closeCamera() {
-        ThreadUtils.postToUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        if (getGeckoInterface() != null)
-                            getGeckoInterface().disableOrientationListener();
-                    } catch (Exception e) { }
-                }
-            });
         if (sCamera != null) {
             sCamera.stopPreview();
             sCamera.release();
             sCamera = null;
             sCameraBuffer = null;
         }
     }