[PATCH 01/10]
Bug 1363885 - 1. Remove GeckoAppShell.AppStateListener;
From f6eed7d8fdc24c0caedb20206852b05cb4a9f0ca Mon Sep 17 00:00:00 2001
r?droeh
Remove GeckoAppShell.AppStateListener and its associated methods in
GeckoInterface (orientation listener and app state listener methods).
---
.../base/java/org/mozilla/gecko/GeckoApp.java | 51 ----------------------
.../java/org/mozilla/gecko/BaseGeckoInterface.java | 14 ------
.../main/java/org/mozilla/gecko/GeckoAppShell.java | 29 ------------
3 files changed, 94 deletions(-)
MozReview-Commit-ID: Jn6DdGXcgJw
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -191,17 +191,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;
@@ -419,27 +418,16 @@ public abstract class GeckoApp extends G
return GeckoSharedPrefs.forProfile(this);
}
@Override
public Activity getActivity() {
return 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.
// When we're switching activities because of differing tab types,
// the first statement is not true.
switch (msg) {
case UNSELECTED:
break;
@@ -1834,19 +1822,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() {
@@ -2126,40 +2111,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
public String getDefaultUAString() {
return HardwareUtils.isTablet() ? AppConstants.USER_AGENT_FENNEC_TABLET :
AppConstants.USER_AGENT_FENNEC_MOBILE;
}
@Override
public void createShortcut(final String title, final String url) {
@@ -2432,22 +2393,16 @@ public abstract class GeckoApp extends G
}
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
@@ -2545,22 +2500,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
@@ -52,30 +52,16 @@ public class BaseGeckoInterface implemen
// Bug 908779: Implement this
@Override
public void addPluginView(final View view) {}
// Bug 908781: Implement this
@Override
public void removePluginView(final View view) {}
- @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) {}
-
// Bug 908789: Implement this
@Override
public void notifyWakeLockChanged(String topic, String state) {}
@Override
public boolean areTabsShown() {
return false;
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1648,34 +1648,24 @@ 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 @NonNull EventDispatcher getAppEventDispatcher();
public GeckoProfile getProfile();
public Activity getActivity();
public String getDefaultUAString();
public void addPluginView(View view);
public void removePluginView(final View view);
- public void enableOrientationListener();
- public void disableOrientationListener();
- public void addAppStateListener(AppStateListener listener);
- public void removeAppStateListener(AppStateListener listener);
public void notifyWakeLockChanged(String topic, String state);
public boolean areTabsShown();
public AbsoluteLayout getPluginContainer();
public void invalidateOptionsMenu();
public boolean isForegrounded();
/**
* Create a shortcut -- generally a home-screen icon -- linking the given title to the given URI.
@@ -1777,26 +1767,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) {
@@ -1851,25 +1831,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;
}
}