This Xposed module I made is a workaraound for the "Cannot connect to camera" problem on i9300 CM11 (Don't know if other devices has the same problem. However, the module may work on every device with Google Camera, because of the way it is implemented). I used the "Restart Camera" apk by temasek for some time, but I shortly got tired of making two or three taps every time I had to take a picture, so I kind of "reverse engineered" the temasek's apk and found out that it just kills the MediaServer process. Then, I build an Xposed module to do this automatically every time the user closes Google Camera app. I wrote that in few minutes so I haven't done a lot of testing, but it seem to work fine on my device and I think it can be shared with other users so everybody can get rid of this bug.
INSTRUCTIONS:
SOURCE CODE:
CREDITS:
@Moderators: I wrote here because I haven't got permissions to write in the Dev section. Sorry.
INSTRUCTIONS:
Code:
1. Install Xposed Framework (if you don't have it already)
2. Install the APK
3. Enable the module and reboot the device
4. Start Google Camera, wait until it loads the preview, then press the "Back" key to exit. When prompted, grant Google Camera root access for every future requests
5. Enjoy
Code:
package jager.cmcamerafix;
import java.io.DataOutputStream;
import java.io.IOException;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class CameraFix implements IXposedHookLoadPackage {
XC_MethodHook mMethodHook = new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("killall mediaserver\n");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.waitFor();
} catch (IOException e) {
throw new Exception(e);
}
}
};
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.google.android.GoogleCamera"))
return;
findAndHookMethod("com.android.camera.CameraActivity", lpparam.classLoader, "onStopTasks", mMethodHook);
}
}
Code:
- temasek for "Restart Camera" apk
- robv89 for Xposed Framework
Aucun commentaire:
Enregistrer un commentaire