diff options
| author | Semavi Ulusoy <doc.divxm@gmail.com> | 2022-07-12 23:55:12 +0300 |
|---|---|---|
| committer | Semavi Ulusoy <doc.divxm@gmail.com> | 2022-07-28 16:14:24 +0300 |
| commit | 766bb585087810f4af4fef297f4347a897796db7 (patch) | |
| tree | 2666617e27c3ace2209080536a5cec509f5bf5be | |
| parent | 9120f8cb7dc05ffed657773cef96db4a3747ae86 (diff) | |
** untill we find a way to add back OpCamera to OOS12 based trees
This reverts commit 79baa8ab7df5984394bbaac62ae71f1c2f940b06.
Change-Id: Ia4cd95f0c5575b03a646f3214de19ee79d870844
| -rw-r--r-- | Android.mk | 2 | ||||
| -rw-r--r-- | src_8kh/com/aicp/device/KeyHandler.java | 96 |
2 files changed, 26 insertions, 72 deletions
@@ -21,8 +21,6 @@ ifeq ($(TARGET_DEVICE),$(filter $(TARGET_DEVICE),guacamole guacamoleb hotdog hot endif ifeq ($(TARGET_DEVICE),$(filter $(TARGET_DEVICE),instantnoodle instantnoodlep kebab)) LOCAL_SRC_FILES += $(call all-java-files-under, src_8kh) -LOCAL_STATIC_JAVA_LIBRARIES := \ - vendor.oneplus.hardware.camera-V1.0-java endif LOCAL_PACKAGE_NAME := PartsBin LOCAL_CERTIFICATE := platform diff --git a/src_8kh/com/aicp/device/KeyHandler.java b/src_8kh/com/aicp/device/KeyHandler.java index 95c3939..dfbaa49 100644 --- a/src_8kh/com/aicp/device/KeyHandler.java +++ b/src_8kh/com/aicp/device/KeyHandler.java @@ -30,7 +30,6 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.pm.PackageManager.NameNotFoundException; import android.media.IAudioService; import android.media.AudioManager; import android.media.session.MediaSessionLegacyHelper; @@ -40,7 +39,6 @@ import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; -import android.os.FileObserver; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; @@ -54,11 +52,8 @@ import android.view.HapticFeedbackConstants; import com.android.internal.util.ArrayUtils; import com.android.internal.util.aicp.AicpVibe; import com.android.internal.util.aicp.CustomKeyHandler; -import com.android.internal.util.aicp.PackageUtils; import com.android.internal.statusbar.IStatusBarService; -import vendor.oneplus.hardware.camera.V1_0.IOnePlusCameraProvider; - public class KeyHandler implements CustomKeyHandler { private static final String TAG = "KeyHandler"; @@ -69,9 +64,6 @@ public class KeyHandler implements CustomKeyHandler { public static final String DYNAMIC_FPS_PATH = "/sys/class/drm/card0-DSI-1/dynamic_fps"; - public static final String CLIENT_PACKAGE_NAME = "com.oneplus.camera"; - public static final String CLIENT_PACKAGE_PATH = "/data/misc/aicp/client_package_name"; - protected final Context mContext; private final PowerManager mPowerManager; private EventHandler mEventHandler; @@ -80,24 +72,21 @@ public class KeyHandler implements CustomKeyHandler { private static boolean mButtonDisabled; private final NotificationManager mNotificationManager; private final AudioManager mAudioManager; + private boolean mDispOn; private boolean mTorchState = false; private boolean mUseSliderTorch = false; - private boolean mDispOn; - private ClientPackageNameObserver mClientObserver; - private IOnePlusCameraProvider mProvider; - private boolean isOPCameraAvail; - private BroadcastReceiver mSystemStateReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { - mDispOn = true; - onDisplayOn(); - } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { - mDispOn = false; - onDisplayOff(); - } - } + private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { + mDispOn = true; + onDisplayOn(); + } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { + mDispOn = false; + onDisplayOff(); + } + } }; public KeyHandler(Context context) { @@ -109,16 +98,9 @@ public class KeyHandler implements CustomKeyHandler { "GestureWakeLock"); mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); - - IntentFilter systemStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); - systemStateFilter.addAction(Intent.ACTION_SCREEN_OFF); - mContext.registerReceiver(mSystemStateReceiver, systemStateFilter); - - isOPCameraAvail = PackageUtils.isPackageAvailable(context, "com.oneplus.camera"); - if (isOPCameraAvail) { - mClientObserver = new ClientPackageNameObserver(CLIENT_PACKAGE_PATH); - mClientObserver.startWatching(); - } + IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); + screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF); + mContext.registerReceiver(mScreenStateReceiver, screenStateFilter); } private class EventHandler extends Handler { @@ -392,6 +374,17 @@ public class KeyHandler implements CustomKeyHandler { return false; } + private void onDisplayOn() { + if (DEBUG) Log.i(TAG, "Display on"); + + Utils.writeValue(DYNAMIC_FPS_PATH, "90"); + } + + private void onDisplayOff() { + if (DEBUG) Log.i(TAG, "Display off"); + Settings.System.putInt(mContext.getContentResolver(), HBMModeSwitch.SETTINGS_KEY, 0); + } + private void launchDozePulse() { // Note: Only works with ambient display enabled. mContext.sendBroadcastAsUser(new Intent(Constants.DOZE_INTENT), @@ -434,41 +427,4 @@ public class KeyHandler implements CustomKeyHandler { } return audioService; } - - private void onDisplayOn() { - if (DEBUG) Log.i(TAG, "Display on"); - if ((mClientObserver == null) && (isOPCameraAvail)) { - mClientObserver = new ClientPackageNameObserver(CLIENT_PACKAGE_PATH); - mClientObserver.startWatching(); - } - } - - private void onDisplayOff() { - if (DEBUG) Log.i(TAG, "Display off"); - if (mClientObserver != null) { - mClientObserver.stopWatching(); - mClientObserver = null; - } - } - - private class ClientPackageNameObserver extends FileObserver { - - public ClientPackageNameObserver(String file) { - super(CLIENT_PACKAGE_PATH, MODIFY); - } - - @Override - public void onEvent(int event, String file) { - String pkgName = Utils.getFileValue(CLIENT_PACKAGE_PATH, "0"); - if (event == FileObserver.MODIFY) { - try { - Log.d(TAG, "client_package" + file + " and " + pkgName); - mProvider = IOnePlusCameraProvider.getService(); - mProvider.setPackageName(pkgName); - } catch (RemoteException e) { - Log.e(TAG, "setPackageName error", e); - } - } - } - } } |
