[automerger skipped] Revert "Unbind CS if connection is not created within 15 seconds." am: b6967b43f2 -s ours
am skip reason: Merged-In I30caed1481dff5af2223a8ff589846597cee8229 with SHA-1 f8659b6921 is already in history. Merged-In was found from reverted change.
Reverted change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/27629954
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/28727861
Change-Id: If8276d9459ba2092441fdaf0854b212b752abdbe
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c38fa4e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea
+*.iml
diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
index 79b9524..b9c3a67 100644
--- a/res/values-eu/strings.xml
+++ b/res/values-eu/strings.xml
@@ -81,13 +81,13 @@
<string name="blocked_numbers_number_already_blocked_message" msgid="2301270825735665458">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> blokeatuta dago dagoeneko."</string>
<string name="toast_personal_call_msg" msgid="5817631570381795610">"Telefono pertsonala erabiltzen ari zara deia egiteko"</string>
<string name="notification_incoming_call" msgid="1233481138362230894">"<xliff:g id="CALL_VIA">%1$s</xliff:g> deia (deitzailea: <xliff:g id="CALL_FROM">%2$s</xliff:g>)"</string>
- <string name="notification_incoming_video_call" msgid="5795968314037063900">"<xliff:g id="CALL_VIA">%1$s</xliff:g> bideo-deia (deitzailea: <xliff:g id="CALL_FROM">%2$s</xliff:g>)"</string>
+ <string name="notification_incoming_video_call" msgid="5795968314037063900">"<xliff:g id="CALL_VIA">%1$s</xliff:g> bideodeia (deitzailea: <xliff:g id="CALL_FROM">%2$s</xliff:g>)"</string>
<string name="answering_ends_other_call" msgid="8653544281903986641">"Erantzuten baduzu, amaitu egingo da <xliff:g id="CALL_VIA">%1$s</xliff:g> deia"</string>
<string name="answering_ends_other_calls" msgid="3702302838456922535">"Erantzuten baduzu, amaitu egingo dira <xliff:g id="CALL_VIA">%1$s</xliff:g> deiak"</string>
- <string name="answering_ends_other_video_call" msgid="8572022039304239958">"Erantzuten baduzu, amaitu egingo da <xliff:g id="CALL_VIA">%1$s</xliff:g> bideo-deia"</string>
+ <string name="answering_ends_other_video_call" msgid="8572022039304239958">"Erantzuten baduzu, amaitu egingo da <xliff:g id="CALL_VIA">%1$s</xliff:g> bideodeia"</string>
<string name="answering_ends_other_managed_call" msgid="4031778317409881805">"Erantzuten baduzu, amaitu egingo da oraingo deia"</string>
<string name="answering_ends_other_managed_calls" msgid="3974069768615307659">"Erantzuten baduzu, amaitu egingo dira oraingo deiak"</string>
- <string name="answering_ends_other_managed_video_call" msgid="1988508241432031327">"Erantzuten baduzu, amaitu egingo da oraingo bideo-deia"</string>
+ <string name="answering_ends_other_managed_video_call" msgid="1988508241432031327">"Erantzuten baduzu, amaitu egingo da oraingo bideodeia"</string>
<string name="answer_incoming_call" msgid="2045888814782215326">"Erantzun"</string>
<string name="decline_incoming_call" msgid="922147089348451310">"Baztertu"</string>
<string name="cant_call_due_to_no_supported_service" msgid="1635626384149947077">"Ezin da egin deia, ez dagoelako mota honetako deiak onartzen duen deiak egiteko konturik."</string>
diff --git a/res/values-hy/strings.xml b/res/values-hy/strings.xml
index 851e4e9..f702f66 100644
--- a/res/values-hy/strings.xml
+++ b/res/values-hy/strings.xml
@@ -79,7 +79,7 @@
<string name="blocked_numbers_number_unblocked_message" msgid="2933071624674945601">"<xliff:g id="UNBLOCKED_NUMBER">%1$s</xliff:g> արգելահանվեց"</string>
<string name="blocked_numbers_block_emergency_number_message" msgid="4198550501500893890">"Արտակարգ իրավիճակների հեռախոսահամարը հնարավոր չէ արգելափակել:"</string>
<string name="blocked_numbers_number_already_blocked_message" msgid="2301270825735665458">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> համարն արդեն արգելափակված է:"</string>
- <string name="toast_personal_call_msg" msgid="5817631570381795610">"Զանգելու նպատակով անհատական համարհավաքիչի օգտագործում"</string>
+ <string name="toast_personal_call_msg" msgid="5817631570381795610">"Զանգելու նպատակով անհատական համարահավաքիչի օգտագործում"</string>
<string name="notification_incoming_call" msgid="1233481138362230894">"<xliff:g id="CALL_VIA">%1$s</xliff:g>-ի զանգ՝ <xliff:g id="CALL_FROM">%2$s</xliff:g>-ից"</string>
<string name="notification_incoming_video_call" msgid="5795968314037063900">"<xliff:g id="CALL_VIA">%1$s</xliff:g>-ի տեսազանգ՝ <xliff:g id="CALL_FROM">%2$s</xliff:g>-ից"</string>
<string name="answering_ends_other_call" msgid="8653544281903986641">"Եթե պատասխանեք այս զանգին, <xliff:g id="CALL_VIA">%1$s</xliff:g>-ի ընթացիկ զանգը կընդհատվի"</string>
diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
index 5743e0d..c59d551 100644
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -24,7 +24,7 @@
<string name="notification_missedCallsTitle" msgid="3910479625507893809">"不在着信"</string>
<string name="notification_missedCallsMsg" msgid="5055782736170916682">"不在着信<xliff:g id="NUM_MISSED_CALLS">%s</xliff:g>件"</string>
<string name="notification_missedCallTicker" msgid="6731461957487087769">"<xliff:g id="MISSED_CALL_FROM">%s</xliff:g>さんからの不在着信"</string>
- <string name="notification_missedCall_call_back" msgid="7900333283939789732">"コールバック"</string>
+ <string name="notification_missedCall_call_back" msgid="7900333283939789732">"かけ直す"</string>
<string name="notification_missedCall_message" msgid="4054698824390076431">"メッセージ"</string>
<string name="notification_disconnectedCall_title" msgid="1790131923692416928">"通話が切断されました"</string>
<string name="notification_disconnectedCall_body" msgid="600491714584417536">"緊急通報番号宛に発信中のため、<xliff:g id="CALLER">%s</xliff:g> さんとの通話が切断されました。"</string>
diff --git a/res/values-mr/strings.xml b/res/values-mr/strings.xml
index 6fbdc03..e5ed694 100644
--- a/res/values-mr/strings.xml
+++ b/res/values-mr/strings.xml
@@ -33,7 +33,7 @@
<string name="notification_audioProcessing_body" msgid="6397005913770420388">"<xliff:g id="AUDIO_PROCESSING_APP_NAME">%s</xliff:g> यांनी कॉल बॅकग्राउंडवर ठेवला आहे हे अॅप कदाचित कॉलद्वारे ऑडिओ ॲक्सेस आणि प्ले करत आहे."</string>
<string name="notification_incallservice_not_responding_title" msgid="5347557574288598548">"<xliff:g id="IN_CALL_SERVICE_APP_NAME">%s</xliff:g> ने प्रतिसाद देणे थांबवले आहे"</string>
<string name="notification_incallservice_not_responding_body" msgid="9209308270131968623">"तुमच्या कॉलने डिव्हाइससोबत दिलेले फोन अॅप वापरले आहे"</string>
- <string name="accessibility_call_muted" msgid="2968461092554300779">"कॉल नि.शब्द केला."</string>
+ <string name="accessibility_call_muted" msgid="2968461092554300779">"कॉल म्यूट केला."</string>
<string name="accessibility_speakerphone_enabled" msgid="555386652061614267">"स्पीकरफोन सक्षम केला."</string>
<string name="respond_via_sms_canned_response_1" msgid="6332561460870382561">"आत्ता बोलू शकत नाही. कशासाठी कॉल केला होता?"</string>
<string name="respond_via_sms_canned_response_2" msgid="2052951316129952406">"मी तुम्हाला परत कॉल करेन."</string>
@@ -70,15 +70,15 @@
<string name="add_blocked_dialog_body" msgid="8599974422407139255">"यावरील कॉल आणि एसएमएस ब्लॉक करा"</string>
<string name="add_blocked_number_hint" msgid="8769422085658041097">"फोन नंबर"</string>
<string name="block_button" msgid="485080149164258770">"ब्लॉक करा"</string>
- <string name="non_primary_user" msgid="315564589279622098">"फक्त डिव्हाइस मालक अवरोधित केलेले नंबर पाहू आणि व्यवस्थापित करू शकतो."</string>
+ <string name="non_primary_user" msgid="315564589279622098">"फक्त डिव्हाइस मालक ब्लॉक केलेले नंबर पाहू आणि व्यवस्थापित करू शकतो."</string>
<string name="delete_icon_description" msgid="5335959254954774373">"ब्लॉक करा"</string>
- <string name="blocked_numbers_butter_bar_title" msgid="582982373755950791">"अवरोधित करणे तात्पुरते बंद आहे"</string>
- <string name="blocked_numbers_butter_bar_body" msgid="1261213114919301485">"तुम्ही एखादा आणीबाणी नंबर डायल केला किंवा त्यावर मजकूर पाठविल्यानंतर, आणीबाणी सेवा आपल्याशी संपर्क साधू शकतात हे सुनिश्चित करण्यासाठी अवरोधित करणे बंद करते."</string>
+ <string name="blocked_numbers_butter_bar_title" msgid="582982373755950791">"ब्लॉक करणे तात्पुरते बंद आहे"</string>
+ <string name="blocked_numbers_butter_bar_body" msgid="1261213114919301485">"तुम्ही एखादा आणीबाणी नंबर डायल केला किंवा त्यावर मेसेज पाठवल्यानंतर, आणीबाणी सेवा तुमच्याशी संपर्क साधू शकतात याची खात्री करण्यासाठी ब्लॉक करणे बंद केले जाते."</string>
<string name="blocked_numbers_butter_bar_button" msgid="2704456308072489793">"आता पुन्हा-सक्षम करा"</string>
- <string name="blocked_numbers_number_blocked_message" msgid="4314736791180919167">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> अवरोधित केला"</string>
+ <string name="blocked_numbers_number_blocked_message" msgid="4314736791180919167">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> ब्लॉक केला"</string>
<string name="blocked_numbers_number_unblocked_message" msgid="2933071624674945601">"<xliff:g id="UNBLOCKED_NUMBER">%1$s</xliff:g> अनब्लॉक केला"</string>
- <string name="blocked_numbers_block_emergency_number_message" msgid="4198550501500893890">"आणीबाणी नंबर अवरोधित करण्यात अक्षम."</string>
- <string name="blocked_numbers_number_already_blocked_message" msgid="2301270825735665458">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> आधीपासून अवरोधित केला आहे."</string>
+ <string name="blocked_numbers_block_emergency_number_message" msgid="4198550501500893890">"आणीबाणी नंबर ब्लॉक करता आला नाही."</string>
+ <string name="blocked_numbers_number_already_blocked_message" msgid="2301270825735665458">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> आधीपासून ब्लॉक केला आहे."</string>
<string name="toast_personal_call_msg" msgid="5817631570381795610">"कॉल करण्यासाठी वैयक्तिक डायलर वापरणे"</string>
<string name="notification_incoming_call" msgid="1233481138362230894">"<xliff:g id="CALL_FROM">%2$s</xliff:g> कडील <xliff:g id="CALL_VIA">%1$s</xliff:g> मधील कॉल"</string>
<string name="notification_incoming_video_call" msgid="5795968314037063900">"<xliff:g id="CALL_FROM">%2$s</xliff:g> कडील <xliff:g id="CALL_VIA">%1$s</xliff:g> मधील व्हिडिओ कॉल"</string>
diff --git a/res/values-ne/strings.xml b/res/values-ne/strings.xml
index e38ed9d..522f360 100644
--- a/res/values-ne/strings.xml
+++ b/res/values-ne/strings.xml
@@ -74,7 +74,7 @@
<string name="delete_icon_description" msgid="5335959254954774373">"अनब्लक गर्नुहोस्"</string>
<string name="blocked_numbers_butter_bar_title" msgid="582982373755950791">"रोक लगाउने काम अस्थायी रूपमा निष्क्रिय छ"</string>
<string name="blocked_numbers_butter_bar_body" msgid="1261213114919301485">"तपाईँले आपत्कालीन नम्बरमा डायल गरेपछि वा टेक्स्ट म्यासेज पठाएपछि आपत्कालीन सेवाहरूले तपाईँलाई सम्पर्क गर्न सकून् भन्ने कुरा सुनिश्चित गर्न कलमाथिको अवरोध निष्क्रिय गरिन्छ।"</string>
- <string name="blocked_numbers_butter_bar_button" msgid="2704456308072489793">"अब पुन:-सक्रिय गर्नुहोस्"</string>
+ <string name="blocked_numbers_butter_bar_button" msgid="2704456308072489793">"अब पुन:-अन गर्नुहोस्"</string>
<string name="blocked_numbers_number_blocked_message" msgid="4314736791180919167">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> माथि रोक लगाइयो"</string>
<string name="blocked_numbers_number_unblocked_message" msgid="2933071624674945601">"<xliff:g id="UNBLOCKED_NUMBER">%1$s</xliff:g> माथिको रोक हटाइयो"</string>
<string name="blocked_numbers_block_emergency_number_message" msgid="4198550501500893890">"आपत्कालीन नम्बरमाथि रोक लगाउन सकिएन।"</string>
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
index 8dc58d0..fd051e5 100644
--- a/res/values-nl/strings.xml
+++ b/res/values-nl/strings.xml
@@ -73,7 +73,7 @@
<string name="non_primary_user" msgid="315564589279622098">"Alleen de eigenaar van het apparaat kan geblokkeerd nummers bekijken en beheren."</string>
<string name="delete_icon_description" msgid="5335959254954774373">"Blokkering opheffen"</string>
<string name="blocked_numbers_butter_bar_title" msgid="582982373755950791">"Blokkering tijdelijk uitgezet"</string>
- <string name="blocked_numbers_butter_bar_body" msgid="1261213114919301485">"Als je een noodnummer belt of er een sms naartoe stuurt, wordt de blokkering uitgeschakeld om te zorgen dat hulpdiensten contact met je kunnen opnemen."</string>
+ <string name="blocked_numbers_butter_bar_body" msgid="1261213114919301485">"Als je een noodnummer belt of er een sms naartoe stuurt, wordt de blokkering uitgezet om te zorgen dat hulpdiensten contact met je kunnen opnemen."</string>
<string name="blocked_numbers_butter_bar_button" msgid="2704456308072489793">"Nu opnieuw aanzetten"</string>
<string name="blocked_numbers_number_blocked_message" msgid="4314736791180919167">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> geblokkeerd"</string>
<string name="blocked_numbers_number_unblocked_message" msgid="2933071624674945601">"Blokkering van <xliff:g id="UNBLOCKED_NUMBER">%1$s</xliff:g> opgeheven"</string>
diff --git a/src/com/android/server/telecom/AsyncRingtonePlayer.java b/src/com/android/server/telecom/AsyncRingtonePlayer.java
index bf2472f..d7786e1 100644
--- a/src/com/android/server/telecom/AsyncRingtonePlayer.java
+++ b/src/com/android/server/telecom/AsyncRingtonePlayer.java
@@ -77,8 +77,10 @@
* {@code False} indicates that a haptic track is NOT present on the ringtone;
* in this case the default vibration in {@link Ringer} should be trigger if needed.
*/
- public @NonNull CompletableFuture<Boolean> play(RingtoneFactory factory, Call incomingCall,
- @Nullable VolumeShaper.Configuration volumeShaperConfig, boolean isVibrationEnabled) {
+ public @NonNull
+ CompletableFuture<Boolean> play(RingtoneFactory factory, Call incomingCall,
+ @Nullable VolumeShaper.Configuration volumeShaperConfig, boolean isRingerAudible,
+ boolean isVibrationEnabled) {
Log.d(this, "Posting play.");
if (mHapticsFuture == null) {
mHapticsFuture = new CompletableFuture<>();
@@ -88,7 +90,8 @@
args.arg2 = incomingCall;
args.arg3 = volumeShaperConfig;
args.arg4 = isVibrationEnabled;
- args.arg5 = Log.createSubsession();
+ args.arg5 = isRingerAudible;
+ args.arg6 = Log.createSubsession();
postMessage(EVENT_PLAY, true /* shouldCreateHandler */, args);
return mHapticsFuture;
}
@@ -152,30 +155,33 @@
Call incomingCall = (Call) args.arg2;
VolumeShaper.Configuration volumeShaperConfig = (VolumeShaper.Configuration) args.arg3;
boolean isVibrationEnabled = (boolean) args.arg4;
- Session session = (Session) args.arg5;
+ boolean isRingerAudible = (boolean) args.arg5;
+ Session session = (Session) args.arg6;
args.recycle();
Log.continueSession(session, "ARP.hP");
try {
// don't bother with any of this if there is an EVENT_STOP waiting.
if (mHandler.hasMessages(EVENT_STOP)) {
- if (mHapticsFuture != null) {
- mHapticsFuture.complete(false /* ringtoneHasHaptics */);
- mHapticsFuture = null;
- }
+ completeHapticFuture(false /* ringtoneHasHaptics */);
return;
}
- // If the Ringtone Uri is EMPTY, then the "None" Ringtone has been selected. Do not play
- // anything.
- if (Uri.EMPTY.equals(incomingCall.getRingtone())) {
- mRingtone = null;
- if (mHapticsFuture != null) {
- mHapticsFuture.complete(false /* ringtoneHasHaptics */);
- mHapticsFuture = null;
+ // If the Ringtone Uri is EMPTY, then the "None" Ringtone has been selected.
+ // If ringer is not audible for this call, then the phone is in "Vibrate" mode.
+ // Use haptic-only ringtone or do not play anything.
+ if (!isRingerAudible || Uri.EMPTY.equals(incomingCall.getRingtone())) {
+ if (isVibrationEnabled) {
+ mRingtone = factory.getHapticOnlyRingtone();
+ if (mRingtone == null) {
+ completeHapticFuture(false /* ringtoneHasHaptics */);
+ return;
+ }
+ } else {
+ mRingtone = null;
+ completeHapticFuture(false /* ringtoneHasHaptics */);
+ return;
}
-
- return;
}
ThreadUtil.checkNotOnMainThread();
@@ -189,34 +195,30 @@
ringtoneUri.toSafeString();
Log.addEvent(null, LogUtils.Events.ERROR_LOG, "Failed to get ringtone from " +
"factory. Skipping ringing. Uri was: " + ringtoneUriString);
- if (mHapticsFuture != null) {
- mHapticsFuture.complete(false /* ringtoneHasHaptics */);
- mHapticsFuture = null;
- }
+ completeHapticFuture(false /* ringtoneHasHaptics */);
return;
}
+ }
- // With the ringtone to play now known, we can determine if it has haptic channels or
- // not; we will complete the haptics future so the default vibration code in Ringer
- // can know whether to trigger the vibrator.
- if (mHapticsFuture != null && !mHapticsFuture.isDone()) {
- boolean hasHaptics = factory.hasHapticChannels(mRingtone);
- Log.i(this, "handlePlay: hasHaptics=%b, isVibrationEnabled=%b", hasHaptics,
- isVibrationEnabled);
- SystemSettingsUtil systemSettingsUtil = new SystemSettingsUtil();
- if (hasHaptics && (volumeShaperConfig == null
- || systemSettingsUtil.enableAudioCoupledVibrationForRampingRinger())) {
- AudioAttributes attributes = mRingtone.getAudioAttributes();
- Log.d(this, "handlePlay: %s haptic channel",
- (isVibrationEnabled ? "unmuting" : "muting"));
- mRingtone.setAudioAttributes(
- new AudioAttributes.Builder(attributes)
- .setHapticChannelsMuted(!isVibrationEnabled)
- .build());
- }
- mHapticsFuture.complete(hasHaptics);
- mHapticsFuture = null;
+ // With the ringtone to play now known, we can determine if it has haptic channels or
+ // not; we will complete the haptics future so the default vibration code in Ringer can
+ // know whether to trigger the vibrator.
+ if (mHapticsFuture != null && !mHapticsFuture.isDone()) {
+ boolean hasHaptics = factory.hasHapticChannels(mRingtone);
+ Log.i(this, "handlePlay: hasHaptics=%b, isVibrationEnabled=%b", hasHaptics,
+ isVibrationEnabled);
+ SystemSettingsUtil systemSettingsUtil = new SystemSettingsUtil();
+ if (hasHaptics && (volumeShaperConfig == null
+ || systemSettingsUtil.enableAudioCoupledVibrationForRampingRinger())) {
+ AudioAttributes attributes = mRingtone.getAudioAttributes();
+ Log.d(this, "handlePlay: %s haptic channel",
+ (isVibrationEnabled ? "unmuting" : "muting"));
+ mRingtone.setAudioAttributes(
+ new AudioAttributes.Builder(attributes)
+ .setHapticChannelsMuted(!isVibrationEnabled)
+ .build());
}
+ completeHapticFuture(hasHaptics);
}
mRingtone.setLooping(true);
@@ -259,4 +261,11 @@
public boolean isPlaying() {
return mRingtone != null;
}
+
+ private void completeHapticFuture(boolean ringtoneHasHaptics) {
+ if (mHapticsFuture != null) {
+ mHapticsFuture.complete(ringtoneHasHaptics);
+ mHapticsFuture = null;
+ }
+ }
}
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
old mode 100644
new mode 100755
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index ca76456..211e796 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -947,6 +947,15 @@
}
};
+ private final BroadcastReceiver mUserAddedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) {
+ restrictPhoneCallOps();
+ }
+ }
+ };
+
private final SystemStateListener mSystemStateListener = new SystemStateListener() {
@Override
public void onCarModeChanged(int priority, String packageName, boolean isCarMode) {
@@ -1055,6 +1064,7 @@
mSystemStateHelper.addListener(mSystemStateListener);
mClockProxy = clockProxy;
restrictPhoneCallOps();
+ mContext.registerReceiver(mUserAddedReceiver, new IntentFilter(Intent.ACTION_USER_ADDED));
}
private void restrictPhoneCallOps() {
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index 91276de..6c9b1cc 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -280,25 +280,33 @@
}
if (mVolumeShaperConfig == null) {
float silencePoint = (float) (RAMPING_RINGER_VIBRATION_DURATION)
- / (float) (RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION);
+ / (float) (RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION);
mVolumeShaperConfig = new VolumeShaper.Configuration.Builder()
- .setDuration(RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION)
- .setCurve(new float[] {0.f, silencePoint + EPSILON /*keep monotonicity*/,
- 1.f}, new float[] {0.f, 0.f, 1.f})
- .setInterpolatorType(VolumeShaper.Configuration.INTERPOLATOR_TYPE_LINEAR)
- .build();
+ .setDuration(
+ RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION)
+ .setCurve(new float[]{0.f, silencePoint + EPSILON /*keep monotonicity*/,
+ 1.f}, new float[]{0.f, 0.f, 1.f})
+ .setInterpolatorType(
+ VolumeShaper.Configuration.INTERPOLATOR_TYPE_LINEAR)
+ .build();
}
hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall,
- mVolumeShaperConfig, isVibratorEnabled);
+ mVolumeShaperConfig, attributes.isRingerAudible(), isVibratorEnabled);
} else {
// Ramping ringtone is not enabled.
hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall, null,
- isVibratorEnabled);
+ attributes.isRingerAudible(), isVibratorEnabled);
effect = getVibrationEffectForCall(mRingtoneFactory, foregroundCall);
}
} else {
Log.addEvent(foregroundCall, LogUtils.Events.SKIP_RINGING, "Inaudible: "
+ attributes.getInaudibleReason());
+ if (isVibratorEnabled && mIsHapticPlaybackSupportedByDevice) {
+ // Attempt to run the attentional haptic ringtone first and fallback to the default
+ // vibration effect if hapticFuture is completed with false.
+ hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall, null,
+ attributes.isRingerAudible(), isVibratorEnabled);
+ }
effect = mDefaultVibrationEffect;
}
diff --git a/src/com/android/server/telecom/RingtoneFactory.java b/src/com/android/server/telecom/RingtoneFactory.java
index df89ee7..5365e20 100644
--- a/src/com/android/server/telecom/RingtoneFactory.java
+++ b/src/com/android/server/telecom/RingtoneFactory.java
@@ -103,6 +103,27 @@
Log.e(this, npe, "getRingtone: NPE while getting ringtone.");
}
}
+ return setRingtoneAudioAttributes(ringtone);
+ }
+
+ public Ringtone getRingtone(Call incomingCall) {
+ return getRingtone(incomingCall, null);
+ }
+
+ /** Returns a ringtone to be used when ringer is not audible for the incoming call. */
+ @Nullable
+ public Ringtone getHapticOnlyRingtone() {
+ Uri ringtoneUri = Uri.parse("file://" + mContext.getString(
+ com.android.internal.R.string.config_defaultRingtoneVibrationSound));
+ Ringtone ringtone = RingtoneManager.getRingtone(mContext, ringtoneUri, null);
+ if (ringtone != null) {
+ // Make sure the sound is muted.
+ ringtone.setVolume(0);
+ }
+ return setRingtoneAudioAttributes(ringtone);
+ }
+
+ private Ringtone setRingtoneAudioAttributes(Ringtone ringtone) {
if (ringtone != null) {
ringtone.setAudioAttributes(new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
@@ -112,10 +133,6 @@
return ringtone;
}
- public Ringtone getRingtone(Call incomingCall) {
- return getRingtone(incomingCall, null);
- }
-
private Context getWorkProfileContextForUser(UserHandle userHandle) {
// UserManager.getEnabledProfiles returns the enabled profiles along with the user's handle
// itself (so we must filter out the user).
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index 847e1f5..0771f58 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -291,7 +291,7 @@
String packageName) {
//TODO: Deprecate this in S
try {
- enforceCallingPackage(packageName);
+ enforceCallingPackage(packageName, "getPhoneAccountsForPackage");
} catch (SecurityException se1) {
EventLog.writeEvent(0x534e4554, "153995334", Binder.getCallingUid(),
"getPhoneAccountsForPackage: invalid calling package");
@@ -326,6 +326,13 @@
@Override
public PhoneAccount getPhoneAccount(PhoneAccountHandle accountHandle,
String callingPackage) {
+ try {
+ enforceCallingPackage(callingPackage, "getPhoneAccount");
+ } catch (SecurityException se) {
+ EventLog.writeEvent(0x534e4554, "196406138", Binder.getCallingUid(),
+ "getPhoneAccount: invalid calling package");
+ throw se;
+ }
synchronized (mLock) {
final UserHandle callingUserHandle = Binder.getCallingUserHandle();
if (CompatChanges.isChangeEnabled(
@@ -864,7 +871,7 @@
public boolean hasManageOngoingCallsPermission(String callingPackage) {
try {
Log.startSession("TSI.hMOCP");
- enforceCallingPackage(callingPackage);
+ enforceCallingPackage(callingPackage, "hasManageOngoingCallsPermission");
return PermissionChecker.checkPermissionForDataDeliveryFromDataSource(
mContext, Manifest.permission.MANAGE_ONGOING_CALLS,
Binder.getCallingPid(),
@@ -1476,7 +1483,7 @@
String callingFeatureId) {
try {
Log.startSession("TSI.pC");
- enforceCallingPackage(callingPackage);
+ enforceCallingPackage(callingPackage, "placeCall");
PhoneAccountHandle phoneAccountHandle = null;
boolean clearPhoneAccountHandleExtra = false;
@@ -2241,7 +2248,7 @@
// feature is enabled ...
enforceConnectionServiceFeature();
// ... and the PhoneAccounts they refer to are for their own package.
- enforceCallingPackage(packageName);
+ enforceCallingPackage(packageName, "enforcePhoneAccountModificationForPackage");
}
}
@@ -2257,8 +2264,22 @@
}
}
- private void enforceCallingPackage(String packageName) {
- mAppOpsManager.checkPackage(Binder.getCallingUid(), packageName);
+ private void enforceCallingPackage(String packageName, String message) {
+ int packageUid = -1;
+ int callingUid = Binder.getCallingUid();
+ PackageManager pm = mContext.createContextAsUser(
+ UserHandle.getUserHandleForUid(callingUid), 0).getPackageManager();
+ if (pm != null) {
+ try {
+ packageUid = pm.getPackageUid(packageName, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ // packageUid is -1
+ }
+ }
+ if (packageUid != callingUid && callingUid != Process.ROOT_UID) {
+ throw new SecurityException(message + ": Package " + packageName
+ + " does not belong to " + callingUid);
+ }
}
private void enforceConnectionServiceFeature() {
diff --git a/src/com/android/server/telecom/TtyManager.java b/src/com/android/server/telecom/TtyManager.java
index 457ba36..565006c 100644
--- a/src/com/android/server/telecom/TtyManager.java
+++ b/src/com/android/server/telecom/TtyManager.java
@@ -84,7 +84,8 @@
mCurrentTtyMode = newTtyMode;
Intent ttyModeChanged = new Intent(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
ttyModeChanged.putExtra(TelecomManager.EXTRA_CURRENT_TTY_MODE, mCurrentTtyMode);
- mContext.sendBroadcastAsUser(ttyModeChanged, UserHandle.ALL);
+ mContext.sendBroadcastAsUser(ttyModeChanged, UserHandle.ALL,
+ android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
updateAudioTtyMode();
}
diff --git a/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java b/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
index d4ca5ff..87fafc6 100644
--- a/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
+++ b/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
@@ -315,11 +315,15 @@
private void bindCallScreeningService(
CompletableFuture<CallFilteringResult> resultFuture) {
- mConnection = new CallScreeningServiceConnection(resultFuture);
+ CallScreeningServiceConnection connection = new CallScreeningServiceConnection(
+ resultFuture);
if (!CallScreeningServiceHelper.bindCallScreeningService(mContext,
- mCallsManager.getCurrentUserHandle(), mPackageName, mConnection)) {
+ mCallsManager.getCurrentUserHandle(), mPackageName, connection)) {
Log.i(this, "Call screening service binding failed.");
resultFuture.complete(mPriorStageResult);
+ mConnection = null;
+ } else {
+ mConnection = connection;
}
}
diff --git a/tests/src/com/android/server/telecom/tests/BasicCallTests.java b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
index 85d9627..71982d3 100644
--- a/tests/src/com/android/server/telecom/tests/BasicCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
@@ -29,6 +29,7 @@
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
@@ -38,14 +39,17 @@
import android.content.Context;
import android.content.IContentProvider;
+import android.content.pm.PackageManager;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.media.AudioManager;
import android.net.Uri;
+import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
+import android.os.UserHandle;
import android.provider.BlockedNumberContract;
import android.telecom.Call;
import android.telecom.CallAudioState;
@@ -94,10 +98,15 @@
private static final String TEST_BUNDLE_KEY = "android.telecom.extra.TEST";
private static final String TEST_EVENT = "android.telecom.event.TEST";
+ private PackageManager mPackageManager;
+
@Override
@Before
public void setUp() throws Exception {
super.setUp();
+ doReturn(mContext).when(mContext).createContextAsUser(any(UserHandle.class), anyInt());
+ mPackageManager = mContext.getPackageManager();
+ when(mPackageManager.getPackageUid(anyString(), eq(0))).thenReturn(Binder.getCallingUid());
}
@Override
diff --git a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
index 68caf67..9ff9986 100644
--- a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
@@ -62,6 +62,7 @@
import org.mockito.Mock;
import java.util.Collections;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
@@ -229,12 +230,30 @@
CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, PKG_NAME,
CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
mAppLabelProxy, mParcelableCallUtilsConverter);
- filter.startFilterLookup(inputResult);
+ CompletableFuture<CallFilteringResult> result = filter.startFilterLookup(inputResult)
+ .toCompletableFuture();
+
+ assertEquals(result.isDone(), false);
+
filter.unbindCallScreeningService();
}
@SmallTest
@Test
+ public void testBindingFailed() {
+ // Use an empty package name here, which fails in the bindCallScreeningService.
+ CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, "",
+ CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
+ mAppLabelProxy, mParcelableCallUtilsConverter);
+
+ CompletableFuture<CallFilteringResult> result = filter.startFilterLookup(inputResult)
+ .toCompletableFuture();
+
+ assertEquals(result.isDone(), true);
+ }
+
+ @SmallTest
+ @Test
public void testAllowCall() throws Exception {
CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, PKG_NAME,
CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
diff --git a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
index 69ceac3..0d68015 100644
--- a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
@@ -37,7 +37,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -57,9 +56,6 @@
import android.telecom.CallerInfo;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
-import android.telecom.Log;
-import android.telecom.Log;
-import android.telecom.DisconnectCause;
import android.telecom.GatewayInfo;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -80,7 +76,6 @@
import com.android.server.telecom.CallState;
import com.android.server.telecom.CallerInfoLookupHelper;
import com.android.server.telecom.CallsManager;
-import com.android.server.telecom.CallsManagerListenerBase;
import com.android.server.telecom.ClockProxy;
import com.android.server.telecom.ConnectionServiceFocusManager;
import com.android.server.telecom.ConnectionServiceFocusManager.ConnectionServiceFocusManagerFactory;
@@ -1632,6 +1627,7 @@
verify(callSpy, never()).setDisconnectCause(any(DisconnectCause.class));
}
+
@SmallTest
@Test
public void testCrossUserCallRedirectionEndEarlyForIncapablePhoneAccount() {
diff --git a/tests/src/com/android/server/telecom/tests/MissedInformationTest.java b/tests/src/com/android/server/telecom/tests/MissedInformationTest.java
index a8e1c5f..e6cd986 100644
--- a/tests/src/com/android/server/telecom/tests/MissedInformationTest.java
+++ b/tests/src/com/android/server/telecom/tests/MissedInformationTest.java
@@ -26,6 +26,9 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
@@ -36,8 +39,11 @@
import android.content.ContentValues;
import android.content.IContentProvider;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.net.Uri;
+import android.os.Binder;
import android.os.Bundle;
+import android.os.UserHandle;
import android.provider.CallLog;
import android.telecom.DisconnectCause;
import android.telecom.TelecomManager;
@@ -73,6 +79,7 @@
@Mock Call mIncomingCall;
private CallsManager mCallsManager;
private CallIntentProcessor.AdapterImpl mAdapter;
+ private PackageManager mPackageManager;
@Override
@Before
@@ -85,6 +92,9 @@
when(mContentProvider.call(any(String.class), any(String.class),
any(String.class), any(Bundle.class))).thenReturn(new Bundle());
doReturn(mContentResolver).when(mSpyContext).getContentResolver();
+ doReturn(mContext).when(mContext).createContextAsUser(any(UserHandle.class), anyInt());
+ mPackageManager = mContext.getPackageManager();
+ when(mPackageManager.getPackageUid(anyString(), eq(0))).thenReturn(Binder.getCallingUid());
}
@Override
diff --git a/tests/src/com/android/server/telecom/tests/RingerTest.java b/tests/src/com/android/server/telecom/tests/RingerTest.java
index 0e93481..00456e2 100644
--- a/tests/src/com/android/server/telecom/tests/RingerTest.java
+++ b/tests/src/com/android/server/telecom/tests/RingerTest.java
@@ -149,7 +149,8 @@
when(notificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true);
when(mockRingtoneFactory.hasHapticChannels(any(Ringtone.class))).thenReturn(false);
when(mockRingtonePlayer.play(any(RingtoneFactory.class), any(Call.class),
- nullable(VolumeShaper.Configuration.class), anyBoolean())).thenReturn(mFuture);
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean()))
+ .thenReturn(mFuture);
mRingerUnderTest = new Ringer(mockPlayerFactory, mContext, mockSystemSettingsUtil,
mockRingtonePlayer, mockRingtoneFactory, mockVibrator, spyVibrationEffectProxy,
mockInCallController);
@@ -174,7 +175,7 @@
assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
verify(mockTonePlayer, never()).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- eq(null), eq(false));
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -192,7 +193,7 @@
assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
verify(mockTonePlayer, never()).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -208,7 +209,7 @@
mRingCompletionFuture.get();
verify(mockTonePlayer, never()).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -225,7 +226,7 @@
mRingCompletionFuture.get();
verify(mockTonePlayer, never()).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -241,7 +242,7 @@
assertTrue(mRingerUnderTest.startRinging(mockCall2, true));
verify(mockTonePlayer, never()).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -260,7 +261,7 @@
assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
verify(mockTonePlayer).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -276,8 +277,8 @@
assertTrue(mRingerUnderTest.startRinging(mockCall2, false));
mRingCompletionFuture.get();
verify(mockTonePlayer).stopTone();
- verify(mockRingtonePlayer).play(
- any(RingtoneFactory.class), any(Call.class), isNull(), eq(true));
+ verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+ eq(true) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
verify(mockVibrator, never()).vibrate(any(VibrationEffect.class),
any(AudioAttributes.class));
}
@@ -293,8 +294,10 @@
assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
mRingCompletionFuture.get();
verify(mockTonePlayer).stopTone();
- verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ // Try to play a silent haptics ringtone
+ verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+ eq(false) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
+ // Play default vibration when future completes with no audio coupled haptics
verify(mockVibrator).vibrate(eq(mRingerUnderTest.mDefaultVibrationEffect),
any(AudioAttributes.class));
}
@@ -305,21 +308,44 @@
mRingerUnderTest.startCallWaiting(mockCall1);
Ringtone mockRingtone = mock(Ringtone.class);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
mFuture.complete(false); // not using audio coupled haptics
enableVibrationWhenRinging();
assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
mRingCompletionFuture.get();
verify(mockTonePlayer).stopTone();
- verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ // Try to play a silent haptics ringtone
+ verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+ eq(false) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
+ // Play default vibration when future completes with no audio coupled haptics
verify(mockVibrator).vibrate(eq(mRingerUnderTest.mDefaultVibrationEffect),
any(AudioAttributes.class));
}
@SmallTest
@Test
+ public void testAudioCoupledHapticsForSilentRingtone() throws Exception {
+ mRingerUnderTest.startCallWaiting(mockCall1);
+ Ringtone mockRingtone = mock(Ringtone.class);
+ when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
+ when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+ when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
+ mFuture.complete(true); // using audio coupled haptics
+ enableVibrationWhenRinging();
+ assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
+ mRingCompletionFuture.get();
+ verify(mockTonePlayer).stopTone();
+ // Try to play a silent haptics ringtone
+ verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+ eq(false) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
+ // Skip vibration for audio coupled haptics
+ verify(mockVibrator, never()).vibrate(any(VibrationEffect.class),
+ any(AudioAttributes.class));
+ }
+
+ @SmallTest
+ @Test
public void testStopRingingBeforeHapticsLookupComplete() throws Exception {
enableVibrationWhenRinging();
Ringtone mockRingtone = mock(Ringtone.class);
@@ -329,7 +355,7 @@
mRingerUnderTest.startRinging(mockCall1, false);
// Make sure we haven't started the vibrator yet, but have started ringing.
verify(mockRingtonePlayer).play(nullable(RingtoneFactory.class), nullable(Call.class),
- nullable(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never()).vibrate(nullable(VibrationEffect.class),
nullable(AudioAttributes.class));
// Simulate something stopping the ringer
@@ -357,7 +383,7 @@
mRingCompletionFuture.get();
verify(mockTonePlayer).stopTone();
verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), eq(null),
- eq(true));
+ eq(true) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
verify(mockVibrator).vibrate(eq(spyVibrationEffectProxy.get(FAKE_RINGTONE_URI, mContext)),
any(AudioAttributes.class));
}
@@ -373,7 +399,7 @@
mRingCompletionFuture.get();
verify(mockTonePlayer).stopTone();
verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), eq(null),
- eq(false));
+ eq(true) /* isRingerAudible */, eq(false) /* isVibrationEnabled */);
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -391,7 +417,7 @@
verify(mockTonePlayer).stopTone();
verify(mockRingtonePlayer).play(
any(RingtoneFactory.class), any(Call.class), any(VolumeShaper.Configuration.class),
- eq(true));
+ eq(true) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
}
@SmallTest
@@ -408,7 +434,7 @@
mRingCompletionFuture.get();
verify(mockTonePlayer).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
@@ -426,7 +452,7 @@
mRingCompletionFuture.get();
verify(mockTonePlayer).stopTone();
verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
- any(VolumeShaper.Configuration.class), anyBoolean());
+ nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
verify(mockVibrator, never())
.vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
}
diff --git a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
index e0e38a7..eb348f2 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
@@ -103,6 +103,7 @@
public class TelecomServiceImplTest extends TelecomTestCase {
public static final String TEST_PACKAGE = "com.test";
+ public static final String PACKAGE_NAME = "test";
public static class CallIntentProcessAdapterFake implements CallIntentProcessor.Adapter {
@Override
@@ -181,15 +182,17 @@
private static final UserHandle USER_HANDLE_16 = new UserHandle(16);
private static final UserHandle USER_HANDLE_17 = new UserHandle(17);
private static final PhoneAccountHandle TEL_PA_HANDLE_16 = new PhoneAccountHandle(
- new ComponentName("test", "telComponentName"), "0", USER_HANDLE_16);
+ new ComponentName(PACKAGE_NAME, "telComponentName"), "0", USER_HANDLE_16);
private static final PhoneAccountHandle SIP_PA_HANDLE_17 = new PhoneAccountHandle(
- new ComponentName("test", "sipComponentName"), "1", USER_HANDLE_17);
+ new ComponentName(PACKAGE_NAME, "sipComponentName"), "1", USER_HANDLE_17);
private static final PhoneAccountHandle TEL_PA_HANDLE_CURRENT = new PhoneAccountHandle(
- new ComponentName("test", "telComponentName"), "2", Binder.getCallingUserHandle());
+ new ComponentName(PACKAGE_NAME, "telComponentName"), "2",
+ Binder.getCallingUserHandle());
private static final PhoneAccountHandle SIP_PA_HANDLE_CURRENT = new PhoneAccountHandle(
- new ComponentName("test", "sipComponentName"), "3", Binder.getCallingUserHandle());
- private static final ComponentName THIRD_PARTY_CALL_SCREENING = new ComponentName("com.android" +
- ".thirdparty", "com.android.thirdparty.callscreeningserviceimpl");
+ new ComponentName(PACKAGE_NAME, "sipComponentName"), "3",
+ Binder.getCallingUserHandle());
+ private static final ComponentName THIRD_PARTY_CALL_SCREENING = new ComponentName(
+ "com.android.thirdparty", "com.android.thirdparty.callscreeningserviceimpl");
@Override
@Before
@@ -202,6 +205,7 @@
when(mockTelephonyManager.isVoiceCapable()).thenReturn(true);
doReturn(mContext).when(mContext).getApplicationContext();
+ doReturn(mContext).when(mContext).createContextAsUser(any(UserHandle.class), anyInt());
doNothing().when(mContext).sendBroadcastAsUser(any(Intent.class), any(UserHandle.class),
anyString());
doAnswer(invocation -> {
@@ -238,6 +242,7 @@
.thenReturn(true);
mPackageManager = mContext.getPackageManager();
+ when(mPackageManager.getPackageUid(anyString(), eq(0))).thenReturn(Binder.getCallingUid());
}
@Override
@@ -463,12 +468,18 @@
@SmallTest
@Test
- public void testGetPhoneAccount() throws RemoteException {
+ public void testGetPhoneAccount() throws Exception {
makeAccountsVisibleToAllUsers(TEL_PA_HANDLE_16, SIP_PA_HANDLE_17);
assertEquals(TEL_PA_HANDLE_16, mTSIBinder.getPhoneAccount(TEL_PA_HANDLE_16,
mContext.getPackageName()).getAccountHandle());
assertEquals(SIP_PA_HANDLE_17, mTSIBinder.getPhoneAccount(SIP_PA_HANDLE_17,
mContext.getPackageName()).getAccountHandle());
+ try {
+ // Try to call the method without using the caller's package name
+ mTSIBinder.getPhoneAccount(TEL_PA_HANDLE_16, null);
+ fail("Should have thrown a SecurityException");
+ } catch (SecurityException expected) {
+ }
}
@SmallTest