Merge "Telecomm: Incall vibration options" into android-15
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index f3c84ba..04eb68e 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -48,9 +48,12 @@
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
+import android.os.Vibrator;
+import android.provider.Settings;
import android.telecom.CallAudioState;
import android.telecom.CallEndpoint;
import android.telecom.ConnectionService;
+import android.telecom.DisconnectCause;
import android.telecom.InCallService;
import android.telecom.Log;
import android.telecom.Logging.Runnable;
@@ -70,6 +73,8 @@
import com.android.server.telecom.flags.FeatureFlags;
import com.android.server.telecom.ui.NotificationChannelManager;
+import org.omnirom.omnilib.utils.OmniSettings;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -1665,9 +1670,27 @@
Log.i(this, "onCallStateChanged: Call state changed for TC@%s: %s -> %s", call.getId(),
CallState.toString(oldState), CallState.toString(newState));
maybeTrackMicrophoneUse(isMuted());
+ boolean vibrateOnConnect = Settings.System.getIntForUser(mContext.getContentResolver(),
+ OmniSettings.OMNI_VIBRATE_ON_CONNECT, 0, UserHandle.USER_CURRENT) == 1;
+ boolean vibrateOnDisconnect = Settings.System.getIntForUser(mContext.getContentResolver(),
+ OmniSettings.OMNI_VIBRATE_ON_DISCONNECT, 0, UserHandle.USER_CURRENT) == 1;
+
+ if (oldState == CallState.DIALING && newState == CallState.ACTIVE && vibrateOnConnect) {
+ vibrate(100, 200, 0);
+ } else if (oldState == CallState.ACTIVE && newState == CallState.DISCONNECTED
+ && vibrateOnDisconnect) {
+ vibrate(100, 200, 0);
+ }
updateCall(call);
}
+ public void vibrate(int v1, int p1, int v2) {
+ long[] pattern = new long[] {
+ 0, v1, p1, v2
+ };
+ ((Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(pattern, -1);
+ }
+
@Override
public void onConnectionServiceChanged(
Call call,
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index e148ef5..c28d70b 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -42,6 +42,7 @@
import android.os.Vibrator;
import android.os.vibrator.persistence.ParsedVibration;
import android.os.vibrator.persistence.VibrationXmlParser;
+import android.provider.Settings;
import android.telecom.Log;
import android.telecom.TelecomManager;
import android.util.Pair;
@@ -51,6 +52,8 @@
import com.android.server.telecom.LogUtils.EventTimer;
import com.android.server.telecom.flags.FeatureFlags;
+import org.omnirom.omnilib.utils.OmniSettings;
+
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
@@ -597,6 +600,11 @@
stopRinging();
+ if (Settings.System.getIntForUser(mContext.getContentResolver(),
+ OmniSettings.OMNI_VIBRATE_ON_CALLWAITING, 0, UserHandle.USER_CURRENT) == 1) {
+ vibrate(200, 300, 500);
+ }
+
if (mCallWaitingPlayer == null) {
Log.addEvent(call, LogUtils.Events.START_CALL_WAITING_TONE, reason);
mCallWaitingCall = call;
@@ -796,6 +804,13 @@
}
}
+ public void vibrate(int v1, int p1, int v2) {
+ long[] pattern = new long[] {
+ 0, v1, p1, v2
+ };
+ ((Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(pattern, -1);
+ }
+
@Nullable
private static VibrationEffect loadSerializedDefaultRingVibration(
Resources resources, Vibrator vibrator) {