diff --git a/parts/Android.bp b/parts/Android.bp
index 56c6534..9892c9a 100644
--- a/parts/Android.bp
+++ b/parts/Android.bp
@@ -14,10 +14,7 @@ android_app {
privileged: true,
static_libs: [
- "androidx.core_core",
- "androidx.preference_preference",
"org.lineageos.settings.resources",
- "vendor.xiaomi.hardware.motor-V1.0-java",
],
optimize: {
diff --git a/parts/AndroidManifest.xml b/parts/AndroidManifest.xml
index ad5474d..49811ff 100644
--- a/parts/AndroidManifest.xml
+++ b/parts/AndroidManifest.xml
@@ -22,7 +22,6 @@
android:sharedUserId="android.uid.system">
-
@@ -46,10 +45,6 @@
android:permission="XiaomiDozeService">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/parts/proguard.flags b/parts/proguard.flags
index 0abe5d3..f6d7a5b 100644
--- a/parts/proguard.flags
+++ b/parts/proguard.flags
@@ -1,7 +1,3 @@
-keep class org.lineageos.settings.doze.* {
*;
}
-
--keep class org.lineageos.settings.popupcamera.* {
- *;
-}
diff --git a/parts/res/drawable/ic_popup_calibration.xml b/parts/res/drawable/ic_popup_calibration.xml
deleted file mode 100644
index f1c70fb..0000000
--- a/parts/res/drawable/ic_popup_calibration.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
diff --git a/parts/res/drawable/ic_popup_light.xml b/parts/res/drawable/ic_popup_light.xml
deleted file mode 100644
index 17e695f..0000000
--- a/parts/res/drawable/ic_popup_light.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
diff --git a/parts/res/drawable/ic_popup_sound.xml b/parts/res/drawable/ic_popup_sound.xml
deleted file mode 100644
index b9581bb..0000000
--- a/parts/res/drawable/ic_popup_sound.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
diff --git a/parts/res/drawable/ic_settings_popup.xml b/parts/res/drawable/ic_settings_popup.xml
deleted file mode 100644
index d593eb2..0000000
--- a/parts/res/drawable/ic_settings_popup.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
diff --git a/parts/res/values/arrays.xml b/parts/res/values/arrays.xml
deleted file mode 100644
index 7d2191e..0000000
--- a/parts/res/values/arrays.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- - @string/action_none
- - @string/popup_sound_muqin
- - @string/popup_sound_yingyan
- - @string/popup_sound_mofa
- - @string/popup_sound_jijia
- - @string/popup_sound_chilun
- - @string/popup_sound_cangmen
-
-
-
- - popup_muqin_up.ogg
- - popup_muqin_down.ogg
- - popup_yingyan_up.ogg
- - popup_yingyan_down.ogg
- - popup_mofa_up.ogg
- - popup_mofa_down.ogg
- - popup_jijia_up.ogg
- - popup_jijia_down.ogg
- - popup_chilun_up.ogg
- - popup_chilun_down.ogg
- - popup_cangmen_up.ogg
- - popup_cangmen_down.ogg
-
-
-
- - -1
- - 0
- - 2
- - 4
- - 6
- - 8
- - 10
-
-
diff --git a/parts/res/values/strings.xml b/parts/res/values/strings.xml
deleted file mode 100644
index 8a3843b..0000000
--- a/parts/res/values/strings.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- Front camera settings
- Camera LED
- Enable LED light while the front camera appears and retracts
- Sound effects
- Xylophone
- Condor
- Magic
- Mecha
- Gearwheel
- Cabin door
- Calibration
- Calibrate the popup camera motor
- Motor calibration
- Unnecessary use of calibration may cause permanent damage. It is recommended to calibrate the popup camera motor only in case of it not moving properly or it being in incorrect position!
-
-
- Warning
- Couldn\'t close front camera. Try calibrating the motor.
- Couldn\'t open front camera. Try calibrating the motor.
- Front camera cannot be used during calibration.
- Calibrate
- Couldn\'t calibrate
- Calibrated successfully. You can open the front camera now.
-
diff --git a/parts/res/xml/popup_settings.xml b/parts/res/xml/popup_settings.xml
deleted file mode 100644
index 98aa637..0000000
--- a/parts/res/xml/popup_settings.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/parts/src/org/lineageos/settings/BootCompletedReceiver.java b/parts/src/org/lineageos/settings/BootCompletedReceiver.java
index b1092e8..672621e 100644
--- a/parts/src/org/lineageos/settings/BootCompletedReceiver.java
+++ b/parts/src/org/lineageos/settings/BootCompletedReceiver.java
@@ -23,7 +23,6 @@ import android.content.Intent;
import android.util.Log;
import org.lineageos.settings.doze.DozeUtils;
-import org.lineageos.settings.popupcamera.PopupCameraUtils;
public class BootCompletedReceiver extends BroadcastReceiver {
private static final boolean DEBUG = false;
@@ -34,6 +33,5 @@ public class BootCompletedReceiver extends BroadcastReceiver {
if (DEBUG)
Log.d(TAG, "Received boot completed intent");
DozeUtils.checkDozeService(context);
- PopupCameraUtils.startService(context);
}
}
diff --git a/parts/src/org/lineageos/settings/popupcamera/Constants.java b/parts/src/org/lineageos/settings/popupcamera/Constants.java
deleted file mode 100644
index 25feacb..0000000
--- a/parts/src/org/lineageos/settings/popupcamera/Constants.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2020 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.settings.popupcamera;
-
-public class Constants {
- public static final int FREE_FALL_SENSOR_ID = 33171042;
-
- public static final int CAMERA_EVENT_DELAY_TIME = 100; // ms
- public static final int MSG_CAMERA_CLOSED = 1001;
- public static final int MSG_CAMERA_OPEN = 1002;
-
- public static final int MOTOR_STATUS_POPUP_OK = 11;
- public static final int MOTOR_STATUS_POPUP_JAMMED = 12;
- public static final int MOTOR_STATUS_TAKEBACK_OK = 13;
- public static final int MOTOR_STATUS_TAKEBACK_JAMMED = 14;
- public static final int MOTOR_STATUS_PRESSED = 15;
- public static final int MOTOR_STATUS_CALIB_OK = 17;
- public static final int MOTOR_STATUS_CALIB_ERROR = 18;
- public static final int MOTOR_STATUS_REQUEST_CALIB = 19;
-
- public static final String CLOSE_CAMERA_STATE = "0";
- public static final String OPEN_CAMERA_STATE = "1";
-
- public static final String FRONT_CAMERA_ID = "1";
- public static final String LEFT_LED_BREATH_PATH = "/sys/class/leds/left/breath";
- public static final String LEFT_LED_PATH = "/sys/class/leds/left/brightness";
- public static final String RIGHT_LED_PATH = "/sys/class/leds/right/brightness";
- public static final String POPUP_SOUND_PATH = "/system/media/audio/ui/";
-}
diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraPreferences.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraPreferences.java
deleted file mode 100644
index 070e6b2..0000000
--- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraPreferences.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2020 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.settings.popupcamera;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-
-public class PopupCameraPreferences {
- private static final String TAG = "PopupCameraUtils";
- private static final boolean DEBUG = false;
- private static final String LED_EFFECT_KEY = "popup_led_effect";
- private static final boolean LED_EFFECT_DEFAULT_VALUE = true;
- private static final String SOUND_EFFECT_KEY = "popup_sound_effect";
- private static final String SOUND_EFFECT_DEFAULT_VALUE = "0";
- private SharedPreferences mSharedPrefs;
-
- public PopupCameraPreferences(Context context) {
- mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- }
-
- public String getSoundEffect() {
- return mSharedPrefs.getString(SOUND_EFFECT_KEY, SOUND_EFFECT_DEFAULT_VALUE);
- }
-
- public boolean isLedAllowed() {
- return mSharedPrefs.getBoolean(LED_EFFECT_KEY, LED_EFFECT_DEFAULT_VALUE);
- }
-}
diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java
deleted file mode 100644
index f3a6bbe..0000000
--- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (C) 2020 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.settings.popupcamera;
-
-import android.annotation.NonNull;
-import android.app.AlertDialog;
-import android.app.Service;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.hardware.camera2.CameraManager;
-import android.media.AudioAttributes;
-import android.media.SoundPool;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.os.UserHandle;
-import android.util.Log;
-import android.view.WindowManager;
-
-import org.lineageos.settings.R;
-import org.lineageos.settings.utils.FileUtils;
-
-import vendor.xiaomi.hardware.motor.V1_0.IMotor;
-import vendor.xiaomi.hardware.motor.V1_0.IMotorCallback;
-import vendor.xiaomi.hardware.motor.V1_0.MotorEvent;
-
-public class PopupCameraService extends Service implements Handler.Callback {
- private static final String TAG = "PopupCameraService";
- private static final boolean DEBUG = false;
-
- private int[] mSounds;
- private boolean mMotorBusy = false;
- private long mClosedEvent;
- private long mOpenEvent;
-
- private Handler mHandler = new Handler(this);
- private IMotor mMotor = null;
- private IMotorCallback mMotorStatusCallback;
- private boolean mMotorCalibrating = false;
- private boolean mErrorDialogShowing;
- private final Object mLock = new Object();
- private PopupCameraPreferences mPopupCameraPreferences;
- private SensorManager mSensorManager;
- private Sensor mFreeFallSensor;
- private SoundPool mSoundPool;
-
- private CameraManager.AvailabilityCallback availabilityCallback =
- new CameraManager.AvailabilityCallback() {
- @Override
- public void onCameraAvailable(@NonNull String cameraId) {
- super.onCameraAvailable(cameraId);
- if (cameraId.equals(Constants.FRONT_CAMERA_ID)) {
- mClosedEvent = SystemClock.elapsedRealtime();
- if (SystemClock.elapsedRealtime() - mOpenEvent
- < Constants.CAMERA_EVENT_DELAY_TIME
- && mHandler.hasMessages(Constants.MSG_CAMERA_OPEN)) {
- mHandler.removeMessages(Constants.MSG_CAMERA_OPEN);
- }
- mHandler.sendEmptyMessageDelayed(
- Constants.MSG_CAMERA_CLOSED, Constants.CAMERA_EVENT_DELAY_TIME);
- }
- }
-
- @Override
- public void onCameraUnavailable(@NonNull String cameraId) {
- super.onCameraAvailable(cameraId);
- if (cameraId.equals(Constants.FRONT_CAMERA_ID)) {
- mOpenEvent = SystemClock.elapsedRealtime();
- if (SystemClock.elapsedRealtime() - mClosedEvent
- < Constants.CAMERA_EVENT_DELAY_TIME
- && mHandler.hasMessages(Constants.MSG_CAMERA_CLOSED)) {
- mHandler.removeMessages(Constants.MSG_CAMERA_CLOSED);
- }
- mHandler.sendEmptyMessageDelayed(
- Constants.MSG_CAMERA_OPEN, Constants.CAMERA_EVENT_DELAY_TIME);
- }
- }
- };
-
- private SensorEventListener mFreeFallListener = new SensorEventListener() {
- @Override
- public void onSensorChanged(SensorEvent event) {
- if (event.values[0] == 2.0f) {
- try {
- mMotor.takebackMotorShortly();
- mSensorManager.unregisterListener(mFreeFallListener, mFreeFallSensor);
- } catch (RemoteException e) {
- // Do nothing
- }
- goBackHome();
- }
- }
-
- @Override
- public void onAccuracyChanged(Sensor sensor, int accuracy) {}
- };
-
- @Override
- public void onCreate() {
- CameraManager cameraManager = getSystemService(CameraManager.class);
- cameraManager.registerAvailabilityCallback(availabilityCallback, null);
- mSensorManager = getSystemService(SensorManager.class);
- mFreeFallSensor = mSensorManager.getDefaultSensor(Constants.FREE_FALL_SENSOR_ID);
- mPopupCameraPreferences = new PopupCameraPreferences(this);
- mSoundPool =
- new SoundPool.Builder()
- .setMaxStreams(1)
- .setAudioAttributes(
- new AudioAttributes.Builder()
- .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
- .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
- .setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED)
- .build())
- .build();
- String[] soundNames = getResources().getStringArray(R.array.popupcamera_effects_names);
- mSounds = new int[soundNames.length];
- for (int i = 0; i < soundNames.length; i++) {
- mSounds[i] = mSoundPool.load(Constants.POPUP_SOUND_PATH + soundNames[i], 1);
- }
-
- try {
- mMotor = IMotor.getService();
- int status = mMotor.getMotorStatus();
- if (status == Constants.MOTOR_STATUS_POPUP_OK
- || status == Constants.MOTOR_STATUS_TAKEBACK_JAMMED) {
- mMotor.takebackMotor(1);
- Thread.sleep(1200);
- }
- mMotorStatusCallback = new MotorStatusCallback();
- mMotor.setMotorCallback(mMotorStatusCallback);
- } catch (InterruptedException | RemoteException e) {
- // Do nothing
- }
- }
-
- private final class MotorStatusCallback extends IMotorCallback.Stub {
- public MotorStatusCallback() {}
-
- @Override
- public void onNotify(MotorEvent event) {
- int status = event.vaalue;
- int cookie = event.cookie;
- if (DEBUG)
- Log.d(TAG, "onNotify: cookie=" + cookie + ", status=" + status);
- synchronized (mLock) {
- if (status == Constants.MOTOR_STATUS_CALIB_OK
- || status == Constants.MOTOR_STATUS_CALIB_ERROR) {
- showCalibrationResult(status);
- } else if (status == Constants.MOTOR_STATUS_PRESSED) {
- updateMotor(Constants.CLOSE_CAMERA_STATE);
- goBackHome();
- } else if (status == Constants.MOTOR_STATUS_POPUP_JAMMED
- || status == Constants.MOTOR_STATUS_TAKEBACK_JAMMED) {
- showErrorDialog();
- }
- }
- }
- }
-
- protected void calibrateMotor() {
- synchronized (mLock) {
- if (mMotorCalibrating)
- return;
- if (mMotor == null) {
- try {
- mMotor = IMotor.getService();
- } catch (RemoteException e) {
- // Do nothing
- }
- if (mMotor == null)
- return;
- }
- try {
- mMotorCalibrating = true;
- mMotor.calibration();
- } catch (RemoteException e) {
- // Do nothing
- }
- mHandler.postDelayed(() -> mMotorCalibrating = false, 7000);
- }
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- if (DEBUG)
- Log.d(TAG, "Starting service");
- return START_STICKY;
- }
-
- @Override
- public void onDestroy() {
- if (DEBUG)
- Log.d(TAG, "Destroying service");
- super.onDestroy();
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- private void updateMotor(String cameraState) {
- if (mMotor == null) {
- return;
- }
- final Runnable r = () -> {
- mMotorBusy = true;
- try {
- int status = mMotor.getMotorStatus();
- if (DEBUG)
- Log.d(TAG, "updateMotor: status=" + status + ", cameraState=" + cameraState);
- if (cameraState.equals(Constants.OPEN_CAMERA_STATE)
- && (status == Constants.MOTOR_STATUS_TAKEBACK_OK
- || status == Constants.MOTOR_STATUS_CALIB_OK)) {
- lightUp();
- playSoundEffect(Constants.OPEN_CAMERA_STATE);
- mMotor.popupMotor(1);
- mSensorManager.registerListener(
- mFreeFallListener, mFreeFallSensor, SensorManager.SENSOR_DELAY_NORMAL);
- } else if (cameraState.equals(Constants.CLOSE_CAMERA_STATE)
- && status == Constants.MOTOR_STATUS_POPUP_OK) {
- lightUp();
- playSoundEffect(Constants.CLOSE_CAMERA_STATE);
- mMotor.takebackMotor(1);
- mSensorManager.unregisterListener(mFreeFallListener, mFreeFallSensor);
- } else {
- mMotorBusy = false;
- if (status == Constants.MOTOR_STATUS_POPUP_JAMMED
- || status == Constants.MOTOR_STATUS_TAKEBACK_JAMMED
- || status == Constants.MOTOR_STATUS_CALIB_ERROR
- || status == Constants.MOTOR_STATUS_REQUEST_CALIB) {
- showErrorDialog();
- }
- return;
- }
- } catch (RemoteException e) {
- // Do nothing
- }
- mHandler.postDelayed(() -> mMotorBusy = false, 1200);
- };
-
- if (mMotorBusy) {
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (mMotorBusy) {
- mHandler.postDelayed(this, 100);
- } else {
- mHandler.post(r);
- }
- }
- }, 100);
- } else {
- mHandler.post(r);
- }
- }
-
- private void lightUp() {
- if (mPopupCameraPreferences.isLedAllowed()) {
- String ledBreathing = FileUtils.readOneLine(Constants.LEFT_LED_BREATH_PATH);
- String ledBrightness = FileUtils.readOneLine(Constants.LEFT_LED_PATH);
-
- FileUtils.writeLine(Constants.LEFT_LED_BREATH_PATH, "0");
- FileUtils.writeLine(Constants.LEFT_LED_PATH, "255");
- FileUtils.writeLine(Constants.RIGHT_LED_PATH, "255");
-
- mHandler.postDelayed(() -> {
- if (ledBreathing.equals("1")) {
- FileUtils.writeLine(Constants.LEFT_LED_BREATH_PATH, ledBreathing);
- } else {
- FileUtils.writeLine(Constants.LEFT_LED_PATH, ledBrightness);
- }
- FileUtils.writeLine(Constants.RIGHT_LED_PATH, "0");
- }, 1200);
- }
- }
-
- private void showCalibrationResult(int status) {
- if (mErrorDialogShowing) {
- return;
- }
- mErrorDialogShowing = true;
- mHandler.post(() -> {
- Resources res = getResources();
- int dialogMessageResId = mMotorCalibrating
- ? R.string.popup_camera_calibrate_running
- : (status == Constants.MOTOR_STATUS_CALIB_OK
- ? R.string.popup_camera_calibrate_success
- : R.string.popup_camera_calibrate_failed);
- AlertDialog.Builder alertDialogBuilder =
- new AlertDialog.Builder(this, R.style.SystemAlertDialogTheme);
- alertDialogBuilder.setMessage(res.getString(dialogMessageResId));
- alertDialogBuilder.setPositiveButton(android.R.string.ok, null);
- AlertDialog alertDialog = alertDialogBuilder.create();
- alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
- alertDialog.setCancelable(false);
- alertDialog.setCanceledOnTouchOutside(false);
- alertDialog.show();
- alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialogInterface) {
- mErrorDialogShowing = false;
- }
- });
- });
- }
-
- private void showErrorDialog() {
- if (mErrorDialogShowing) {
- return;
- }
- mErrorDialogShowing = true;
- goBackHome();
- mHandler.post(() -> {
- Resources res = getResources();
- String cameraState = "-1";
- int dialogMessageResId = cameraState.equals(Constants.CLOSE_CAMERA_STATE)
- ? R.string.popup_camera_takeback_failed_calibrate
- : R.string.popup_camera_popup_failed_calibrate;
- AlertDialog alertDialog =
- new AlertDialog.Builder(this, R.style.SystemAlertDialogTheme)
- .setTitle(res.getString(R.string.popup_camera_tip))
- .setMessage(res.getString(dialogMessageResId))
- .setPositiveButton(res.getString(R.string.popup_camera_calibrate_now),
- (dialog, which) -> calibrateMotor())
- .setNegativeButton(res.getString(android.R.string.cancel), null)
- .create();
- alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
- alertDialog.setCanceledOnTouchOutside(false);
- alertDialog.show();
- alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialogInterface) {
- mErrorDialogShowing = false;
- }
- });
- });
- }
-
- private void playSoundEffect(String state) {
- int soundEffect = Integer.parseInt(mPopupCameraPreferences.getSoundEffect());
- if (soundEffect != -1) {
- if (state.equals(Constants.CLOSE_CAMERA_STATE)) {
- soundEffect++;
- }
- mSoundPool.play(mSounds[soundEffect], 1.0f, 1.0f, 0, 0, 1.0f);
- }
- }
-
- public void goBackHome() {
- Intent homeIntent = new Intent(Intent.ACTION_MAIN);
- homeIntent.addCategory(Intent.CATEGORY_HOME);
- homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivityAsUser(homeIntent, null, UserHandle.CURRENT);
- }
-
- @Override
- public boolean handleMessage(Message msg) {
- switch (msg.what) {
- case Constants.MSG_CAMERA_CLOSED: {
- updateMotor(Constants.CLOSE_CAMERA_STATE);
- } break;
- case Constants.MSG_CAMERA_OPEN: {
- updateMotor(Constants.OPEN_CAMERA_STATE);
- } break;
- }
- return true;
- }
-}
diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsActivity.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsActivity.java
deleted file mode 100644
index a312cff..0000000
--- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsActivity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2020 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.settings.popupcamera;
-
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-
-public class PopupCameraSettingsActivity extends PreferenceActivity {
- private static final String TAG_POPUPCAMERA = "popupcamera";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- getFragmentManager()
- .beginTransaction()
- .replace(android.R.id.content, new PopupCameraSettingsFragment(), TAG_POPUPCAMERA)
- .commit();
- }
-}
diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsFragment.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsFragment.java
deleted file mode 100644
index 797ce7e..0000000
--- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsFragment.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2020 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.settings.popupcamera;
-
-import android.app.AlertDialog;
-import android.app.Activity;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.view.MenuItem;
-
-import androidx.preference.Preference;
-import androidx.preference.Preference.OnPreferenceChangeListener;
-import androidx.preference.Preference.OnPreferenceClickListener;
-import androidx.preference.PreferenceFragment;
-
-import org.lineageos.settings.R;
-
-public class PopupCameraSettingsFragment extends PreferenceFragment
- implements OnPreferenceChangeListener, OnPreferenceClickListener {
- private Preference mCalibrationPreference;
- private static final String MOTOR_CALIBRATION_KEY = "motor_calibration";
-
- private PopupCameraService mPopupCameraService = new PopupCameraService();
-
- @Override
- public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
- addPreferencesFromResource(R.xml.popup_settings);
- getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
-
- mCalibrationPreference = (Preference) findPreference(MOTOR_CALIBRATION_KEY);
- mCalibrationPreference.setOnPreferenceClickListener(this);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- return false;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- getActivity().onBackPressed();
- return true;
- }
- return false;
- }
-
- @Override
- public boolean onPreferenceClick(Preference preference) {
- if (MOTOR_CALIBRATION_KEY.equals(preference.getKey())) {
- MotorCalibrationWarningDialog fragment = new MotorCalibrationWarningDialog();
- fragment.show(getFragmentManager(), "motor_calibration_warning_dialog");
- return true;
- }
- return false;
- }
-
- private class MotorCalibrationWarningDialog extends DialogFragment {
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- return new AlertDialog.Builder(getActivity())
- .setTitle(R.string.popup_calibration_warning_title)
- .setMessage(R.string.popup_calibration_warning_text)
- .setPositiveButton(R.string.popup_camera_calibrate_now,
- (dialog, which) -> {
- mPopupCameraService.calibrateMotor();
- dialog.cancel();
- })
- .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel())
- .create();
- }
- }
-}
diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraUtils.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraUtils.java
deleted file mode 100644
index 46c29c4..0000000
--- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraUtils.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2020 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.settings.popupcamera;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.UserHandle;
-
-public class PopupCameraUtils {
- private static final String TAG = "PopupCameraUtils";
- private static final boolean DEBUG = false;
-
- public static void startService(Context context) {
- context.startServiceAsUser(
- new Intent(context, PopupCameraService.class), UserHandle.CURRENT);
- }
-}
diff --git a/parts/src/org/lineageos/settings/utils/FileUtils.java b/parts/src/org/lineageos/settings/utils/FileUtils.java
deleted file mode 100644
index 00028ff..0000000
--- a/parts/src/org/lineageos/settings/utils/FileUtils.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2016 The CyanogenMod Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.settings.utils;
-
-import android.util.Log;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-
-public final class FileUtils {
- private static final String TAG = "FileUtils";
-
- private FileUtils() {
- // This class is not supposed to be instantiated
- }
-
- /**
- * Reads the first line of text from the given file.
- * Reference {@link BufferedReader#readLine()} for clarification on what a line is
- *
- * @return the read line contents, or null on failure
- */
- public static String readOneLine(String fileName) {
- String line = null;
- BufferedReader reader = null;
-
- try {
- reader = new BufferedReader(new FileReader(fileName), 512);
- line = reader.readLine();
- } catch (FileNotFoundException e) {
- Log.w(TAG, "No such file " + fileName + " for reading", e);
- } catch (IOException e) {
- Log.e(TAG, "Could not read from file " + fileName, e);
- } finally {
- try {
- if (reader != null) {
- reader.close();
- }
- } catch (IOException e) {
- // Ignored, not much we can do anyway
- }
- }
-
- return line;
- }
-
- /**
- * Writes the given value into the given file
- *
- * @return true on success, false on failure
- */
- public static boolean writeLine(String fileName, String value) {
- BufferedWriter writer = null;
-
- try {
- writer = new BufferedWriter(new FileWriter(fileName));
- writer.write(value);
- } catch (FileNotFoundException e) {
- Log.w(TAG, "No such file " + fileName + " for writing", e);
- return false;
- } catch (IOException e) {
- Log.e(TAG, "Could not write to file " + fileName, e);
- return false;
- } finally {
- try {
- if (writer != null) {
- writer.close();
- }
- } catch (IOException e) {
- // Ignored, not much we can do anyway
- }
- }
-
- return true;
- }
-
- /**
- * Checks whether the given file exists
- *
- * @return true if exists, false if not
- */
- public static boolean fileExists(String fileName) {
- final File file = new File(fileName);
- return file.exists();
- }
-
- /**
- * Checks whether the given file is readable
- *
- * @return true if readable, false if not
- */
- public static boolean isFileReadable(String fileName) {
- final File file = new File(fileName);
- return file.exists() && file.canRead();
- }
-
- /**
- * Checks whether the given file is writable
- *
- * @return true if writable, false if not
- */
- public static boolean isFileWritable(String fileName) {
- final File file = new File(fileName);
- return file.exists() && file.canWrite();
- }
-
- /**
- * Deletes an existing file
- *
- * @return true if the delete was successful, false if not
- */
- public static boolean delete(String fileName) {
- final File file = new File(fileName);
- boolean ok = false;
- try {
- ok = file.delete();
- } catch (SecurityException e) {
- Log.w(TAG, "SecurityException trying to delete " + fileName, e);
- }
- return ok;
- }
-
- /**
- * Renames an existing file
- *
- * @return true if the rename was successful, false if not
- */
- public static boolean rename(String srcPath, String dstPath) {
- final File srcFile = new File(srcPath);
- final File dstFile = new File(dstPath);
- boolean ok = false;
- try {
- ok = srcFile.renameTo(dstFile);
- } catch (SecurityException e) {
- Log.w(TAG, "SecurityException trying to rename " + srcPath + " to " + dstPath, e);
- } catch (NullPointerException e) {
- Log.e(TAG, "NullPointerException trying to rename " + srcPath + " to " + dstPath, e);
- }
- return ok;
- }
-}