Skip to content

Instantly share code, notes, and snippets.

@Quarx2k
Last active October 21, 2021 10:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Quarx2k/a96dd95f2d71b9d478280690cb6098c8 to your computer and use it in GitHub Desktop.
Save Quarx2k/a96dd95f2d71b9d478280690cb6098c8 to your computer and use it in GitHub Desktop.
Oneplus 7Pro 48M Mode Enabler
private int[] getSensorsModeTable(CameraCharacteristics characteristics) {
//OP7 Pro return. Used by video recording.
//Sensor modes: [9, 3, 4000, 3000, 30, 4000, 3000, 30, 4000, 3000, 60, 2000, 1128, 240, 1296, 736, 480, 2000, 1500, 120, 4000, 3000, 23, 4000, 3000, 30, 8000, 6000, 21]
Constructor<CameraCharacteristics.Key> cameraCharacteristicsConstructor;
try {
cameraCharacteristicsConstructor = CameraCharacteristics.Key.class.getDeclaredConstructor(String.class, Class.class);
cameraCharacteristicsConstructor.setAccessible(true);
CameraCharacteristics.Key KEY_SENSOR_MODE_TABLE =
cameraCharacteristicsConstructor.newInstance("org.quic.camera2.sensormode.info.SensorModeTable", int[].class);
int[] modes = (int[]) characteristics.get(KEY_SENSOR_MODE_TABLE);
Log.e(TAG, "Sensor modes: " + Arrays.toString(modes));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private void setVendorStreamConfigMode() {
try {
//Used by video recording.
Method setVendorStreamConfigModeMethod = CameraDevice.class.getMethod("setVendorStreamConfigMode", Integer.TYPE);
setVendorStreamConfigModeMethod.invoke(cameraDevice, Integer.valueOf(1));
} catch (Exception e) {
e.printStackTrace();
}
}
private void createCustomCaptureSession(List<Surface> surfaces, CameraCaptureSession.StateCallback stateCallback) {
try {
//32794 is 48M Pro Mode.
//32770 is RAW and JPEG Pro modes.
List<OutputConfiguration> outputConfigurations = surfaces.stream().map(OutputConfiguration::new).collect(Collectors.toList());
Method createCustomCaptureSessionMethod = CameraDevice.class.getMethod("createCustomCaptureSession",
InputConfiguration.class, List.class, Integer.TYPE, CameraCaptureSession.StateCallback.class, Handler.class);
createCustomCaptureSessionMethod.invoke(cameraDevice, null, outputConfigurations, 32794, stateCallback, null);
} catch (Exception e) {
e.printStackTrace();
}
}
private Size getProResolution(CameraCharacteristics characteristics) {
//OP7 Pro return [1, 8000, 6000]. Stock camera use [1] [2] values.
try {
Constructor<CameraCharacteristics.Key> cameraCharacteristicsConstructor = CameraCharacteristics.Key.class.getDeclaredConstructor(String.class, Class.class);
cameraCharacteristicsConstructor.setAccessible(true);
CameraCharacteristics.Key KEY_ALTERNATIVE_PICTURE_SIZE = cameraCharacteristicsConstructor.newInstance("org.oneplus.camera2.parameters.ProFullInfo", int[].class);
int[] res = (int[]) characteristics.get(KEY_ALTERNATIVE_PICTURE_SIZE);
Log.e(TAG, Arrays.toString(res));
return new Size(res[1], res[2]);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment