Merge "Add activity to handle default dialer requests" into mnc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ce010da..a2295b5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -75,7 +75,7 @@
<!-- Message indicating that the user is not allowed to make non-emergency outgoing phone calls
due to a user restriction -->
- <string name="outgoing_call_not_allowed">Only emergency calls are allowed by the device owner</string>
+ <string name="outgoing_call_not_allowed">Only emergency calls are allowed by the device owner.</string>
<!-- Call failure message displayed in an error dialog used to indicate that a phone number was not provided -->
<string name="outgoing_call_error_no_phone_number_supplied">To place a call, enter a valid number.</string>
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index cd789ce..63e9e49 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -741,10 +741,12 @@
+ " is not allowed to place phone calls");
}
synchronized (mLock) {
+ final UserHandle userHandle = Binder.getCallingUserHandle();
long token = Binder.clearCallingIdentity();
final Intent intent = new Intent(Intent.ACTION_CALL, handle);
intent.putExtras(extras);
- new UserCallIntentProcessor(mContext).processIntent(intent, callingPackage);
+ new UserCallIntentProcessor(mContext, userHandle).processIntent(intent,
+ callingPackage);
Binder.restoreCallingIdentity(token);
}
}
diff --git a/src/com/android/server/telecom/components/UserCallActivity.java b/src/com/android/server/telecom/components/UserCallActivity.java
index ccff468..ae9004c 100644
--- a/src/com/android/server/telecom/components/UserCallActivity.java
+++ b/src/com/android/server/telecom/components/UserCallActivity.java
@@ -21,8 +21,11 @@
import com.android.server.telecom.TelecomSystem;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
import android.telecom.TelecomManager;
// TODO: Needed for move to system service: import com.android.internal.R;
@@ -53,7 +56,10 @@
// See OutgoingCallBroadcaster in services/Telephony for more.
Intent intent = getIntent();
verifyCallAction(intent);
- new UserCallIntentProcessor(this).processIntent(getIntent(), getCallingPackage());
+ final UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
+ final UserHandle userHandle = new UserHandle(userManager.getUserHandle());
+ new UserCallIntentProcessor(this, userHandle).processIntent(getIntent(),
+ getCallingPackage());
finish();
}
diff --git a/src/com/android/server/telecom/components/UserCallIntentProcessor.java b/src/com/android/server/telecom/components/UserCallIntentProcessor.java
index d50073d..d19a260 100644
--- a/src/com/android/server/telecom/components/UserCallIntentProcessor.java
+++ b/src/com/android/server/telecom/components/UserCallIntentProcessor.java
@@ -21,13 +21,11 @@
import com.android.server.telecom.R;
import com.android.server.telecom.TelephonyUtil;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.UserHandle;
import android.os.UserManager;
-import android.provider.Settings;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
@@ -57,9 +55,11 @@
public class UserCallIntentProcessor {
private final Context mContext;
+ private final UserHandle mUserHandle;
- public UserCallIntentProcessor(Context context) {
+ public UserCallIntentProcessor(Context context, UserHandle userHandle) {
mContext = context;
+ mUserHandle = userHandle;
}
/**
@@ -93,15 +93,12 @@
}
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS)
+ if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, mUserHandle)
&& !TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) {
// Only emergency calls are allowed for users with the DISALLOW_OUTGOING_CALLS
// restriction.
- Toast.makeText(
- mContext,
- mContext.getResources().getString(R.string.outgoing_call_not_allowed),
- Toast.LENGTH_SHORT).show();
- Log.d(this, "Rejecting non-emergency phone call due to DISALLOW_OUTGOING_CALLS "
+ showErrorDialogForRestrictedOutgoingCall(mContext);
+ Log.w(this, "Rejecting non-emergency phone call due to DISALLOW_OUTGOING_CALLS "
+ "restriction");
return;
}
@@ -173,4 +170,12 @@
mContext.sendBroadcastAsUser(intent, UserHandle.OWNER);
return true;
}
+
+ private static void showErrorDialogForRestrictedOutgoingCall(Context context) {
+ final Intent intent = new Intent(context, ErrorDialogActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(ErrorDialogActivity.ERROR_MESSAGE_ID_EXTRA,
+ R.string.outgoing_call_not_allowed);
+ context.startActivityAsUser(intent, UserHandle.CURRENT);
+ }
}
diff --git a/testapps/src/com/android/server/telecom/testapps/TestCallList.java b/testapps/src/com/android/server/telecom/testapps/TestCallList.java
index 7bb7a91..dabc21b 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestCallList.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestCallList.java
@@ -120,7 +120,7 @@
mCalls.clear();
for (Call call : mVideoCallListeners.keySet()) {
if (call.getVideoCall() != null) {
- call.getVideoCall().unregisterCallback();
+ call.getVideoCall().destroy();
}
}
mVideoCallListeners.clear();
diff --git a/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java b/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java
index 0e67627..1da8906 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java
@@ -163,6 +163,7 @@
capabilities |= CAPABILITY_MUTE;
capabilities |= CAPABILITY_SUPPORT_HOLD;
capabilities |= CAPABILITY_HOLD;
+ capabilities |= CAPABILITY_RESPOND_VIA_TEXT;
setConnectionCapabilities(capabilities);
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(