aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2014-11-07 00:25:20 (GMT)
committerJorge Ruesga <jorge@ruesga.com>2014-11-07 00:29:23 (GMT)
commit9500dc3a19466dae5269bf337364396b0a48309c (patch)
treef8355948986c47661fda2995ddd7e5366e9cc898
parent943a2376c07c86ec571ce664186268103e8531ef (diff)
downloadandroid_packages_wallpapers_PhotoPhase-9500dc3a19466dae5269bf337364396b0a48309c.zip
android_packages_wallpapers_PhotoPhase-9500dc3a19466dae5269bf337364396b0a48309c.tar.gz
android_packages_wallpapers_PhotoPhase-9500dc3a19466dae5269bf337364396b0a48309c.tar.bz2
photophase: restart lwp service on bad egl context
This patch contains some fixes for bad egl context detection and other NPE and lint fixes Change-Id: I47c4348770dc72f768df4bea27c7817d1ec10c42 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--res/layout/color_picker_pref_item.xml2
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/AndroidHelper.java18
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java18
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/preferences/ChoosePicturesFragment.java2
4 files changed, 38 insertions, 2 deletions
diff --git a/res/layout/color_picker_pref_item.xml b/res/layout/color_picker_pref_item.xml
index f299d0e..65f51b7 100644
--- a/res/layout/color_picker_pref_item.xml
+++ b/res/layout/color_picker_pref_item.xml
@@ -19,7 +19,7 @@
android:layout_height="32dp"
android:background="@android:color/darker_gray">
<afzkl.development.mColorPicker.views.ColorPanelView
- android:id="@+android:id/color_picker"
+ android:id="@+id/color_picker"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp"
diff --git a/src/org/cyanogenmod/wallpapers/photophase/AndroidHelper.java b/src/org/cyanogenmod/wallpapers/photophase/AndroidHelper.java
index bf69cde..56e0563 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/AndroidHelper.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/AndroidHelper.java
@@ -17,10 +17,14 @@
package org.cyanogenmod.wallpapers.photophase;
import android.app.Activity;
+import android.app.WallpaperManager;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.provider.Settings;
+import android.os.Process;
import android.util.DisplayMetrics;
import android.view.ViewConfiguration;
@@ -109,4 +113,18 @@ public final class AndroidHelper {
}
return result;
}
+
+ /**
+ * Method that restart the wallpaper
+ *
+ * @param ctx The current context
+ */
+ public static void restartWallpaper(Context ctx) {
+ // Restart the service
+ Process.killProcess(Process.myPid());
+ Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
+ intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
+ new ComponentName(ctx, PhotoPhaseWallpaper.class));
+ ctx.startActivity(intent);
+ }
}
diff --git a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java
index bb9ed29..9358877 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java
@@ -181,6 +181,14 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer {
}
};
+ private final Runnable mEGLContextWatchDog = new Runnable() {
+ @Override
+ public void run() {
+ // Restart the wallpaper
+ AndroidHelper.restartWallpaper(mContext);
+ }
+ };
+
/**
* Constructor of <code>PhotoPhaseRenderer<code>
*
@@ -314,6 +322,11 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer {
} else {
mDispatcher.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
+
+ // Set a watchdog to detect EGL bad context and restart the wallpaper
+ if (!mIsPreview) {
+ mHandler.postDelayed(mEGLContextWatchDog, 1000L);
+ }
}
/**
@@ -709,6 +722,11 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer {
*/
@Override
public void onDrawFrame(GL10 glUnused) {
+ // Remove the EGL context watchdog
+ if (!mIsPreview) {
+ mHandler.removeCallbacks(mEGLContextWatchDog);
+ }
+
// Set the projection, view and model
GLES20.glViewport(0, -mStatusBarHeight, mWidth, mHeight);
Matrix.setLookAtM(mVMatrix, 0, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/ChoosePicturesFragment.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/ChoosePicturesFragment.java
index f83c392..fa9c637 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/preferences/ChoosePicturesFragment.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/ChoosePicturesFragment.java
@@ -478,7 +478,7 @@ public class ChoosePicturesFragment extends PreferenceFragment
private void restoreData() {
// Restore and the albums the selection
mSelectedAlbums = new HashSet<String>(mOriginalSelectedAlbums);
- int count = mAlbums.size();
+ int count = Math.min(mAlbums.size(), mOriginalAlbums.size());
for (int i = 0; i < count ; i++) {
Album album = mAlbums.get(i);
Album originalAlbum = mOriginalAlbums.get(i);