Merge "Implement getVisualVoicemailSettings()" into oc-dev
am: 644751a0bd
Change-Id: I171e37e45aae9aff45a7ea5c384cbc91d211f475
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 1fd9004..99621d0 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -19,7 +19,6 @@
import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
import android.Manifest.permission;
-import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.PendingIntent;
@@ -95,7 +94,10 @@
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.util.HexDump;
import com.android.phone.settings.VoicemailNotificationSettingsUtil;
+import com.android.phone.vvm.PhoneAccountHandleConverter;
import com.android.phone.vvm.RemoteVvmTaskManager;
+import com.android.phone.vvm.VisualVoicemailPreferences;
+import com.android.phone.vvm.VisualVoicemailSettingsUtil;
import com.android.phone.vvm.VisualVoicemailSmsFilterConfig;
import java.io.FileDescriptor;
@@ -2016,6 +2018,20 @@
}
@Override
+ public Bundle getVisualVoicemailSettings(String callingPackage, int subId) {
+ mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
+ String systemDialer = TelecomManager.from(mPhone.getContext()).getSystemDialerPackage();
+ if (!TextUtils.equals(callingPackage, systemDialer)) {
+ throw new SecurityException("caller must be system dialer");
+ }
+ PhoneAccountHandle phoneAccountHandle = PhoneAccountHandleConverter.fromSubId(subId);
+ if (phoneAccountHandle == null){
+ return null;
+ }
+ return VisualVoicemailSettingsUtil.dump(mPhone.getContext(), phoneAccountHandle);
+ }
+
+ @Override
public String getVisualVoicemailPackageName(String callingPackage, int subId) {
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
if (!canReadPhoneState(callingPackage, "getVisualVoicemailPackageName")) {
diff --git a/src/com/android/phone/vvm/VisualVoicemailSettingsUtil.java b/src/com/android/phone/vvm/VisualVoicemailSettingsUtil.java
index 6829daf..8215261 100644
--- a/src/com/android/phone/vvm/VisualVoicemailSettingsUtil.java
+++ b/src/com/android/phone/vvm/VisualVoicemailSettingsUtil.java
@@ -16,8 +16,9 @@
package com.android.phone.vvm;
import android.content.Context;
+import android.os.Bundle;
import android.telecom.PhoneAccountHandle;
-import com.android.phone.R;
+import android.telephony.TelephonyManager;
/**
* Save whether or not a particular account is enabled in shared to be retrieved later.
@@ -26,39 +27,18 @@
private static final String IS_ENABLED_KEY = "is_enabled";
+ private static final String DEFAULT_OLD_PIN_KEY = "default_old_pin";
- public static void setEnabled(Context context, PhoneAccountHandle phoneAccount,
- boolean isEnabled) {
- new VisualVoicemailPreferences(context, phoneAccount).edit()
- .putBoolean(IS_ENABLED_KEY, isEnabled)
- .apply();
- }
-
- public static boolean isEnabled(Context context,
- PhoneAccountHandle phoneAccount) {
- if (phoneAccount == null) {
- return false;
+ public static Bundle dump(Context context, PhoneAccountHandle phoneAccountHandle){
+ Bundle result = new Bundle();
+ VisualVoicemailPreferences prefs = new VisualVoicemailPreferences(context,
+ phoneAccountHandle);
+ if (prefs.contains(IS_ENABLED_KEY)) {
+ result.putBoolean(TelephonyManager.EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL,
+ prefs.getBoolean(IS_ENABLED_KEY, false));
}
- if (!context.getResources().getBoolean(R.bool.allow_visual_voicemail)) {
- return false;
- }
-
- VisualVoicemailPreferences prefs = new VisualVoicemailPreferences(context, phoneAccount);
- return prefs.getBoolean(IS_ENABLED_KEY, false);
- }
-
- /**
- * Whether the client enabled status is explicitly set by user or by default(Whether carrier VVM
- * app is installed). This is used to determine whether to disable the client when the carrier
- * VVM app is installed. If the carrier VVM app is installed the client should give priority to
- * it if the settings are not touched.
- */
- public static boolean isEnabledUserSet(Context context,
- PhoneAccountHandle phoneAccount) {
- if (phoneAccount == null) {
- return false;
- }
- VisualVoicemailPreferences prefs = new VisualVoicemailPreferences(context, phoneAccount);
- return prefs.contains(IS_ENABLED_KEY);
+ result.putString(TelephonyManager.EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING,
+ prefs.getString(DEFAULT_OLD_PIN_KEY));
+ return result;
}
}