Merge "Multiuser settings revamp - followup to address comments"
diff --git a/res/layout/trust_agent_item.xml b/res/layout/trust_agent_item.xml
index e2ef953..e7b3bc8 100644
--- a/res/layout/trust_agent_item.xml
+++ b/res/layout/trust_agent_item.xml
@@ -67,21 +67,4 @@
                     android:maxLines="4"/>
         </RelativeLayout>
     </LinearLayout>
-    <View
-            android:layout_width="2dip"
-            android:layout_height="match_parent"
-            android:layout_marginTop="5dip"
-            android:layout_marginBottom="5dip"
-            android:background="@android:drawable/divider_horizontal_dark"/>
-    <ImageView
-            android:id="@+id/settings"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:paddingStart="15dip"
-            android:src="@drawable/ic_sysbar_quicksettings"
-            android:contentDescription="@string/input_method_settings_button"
-            android:layout_gravity="center"
-            android:clickable="true"
-            android:focusable="true"
-            android:background="?android:attr/selectableItemBackground"/>
 </LinearLayout>
diff --git a/src/com/android/settings/AdvancedSecuritySettings.java b/src/com/android/settings/AdvancedSecuritySettings.java
index 2a8c623..3ddbf96 100644
--- a/src/com/android/settings/AdvancedSecuritySettings.java
+++ b/src/com/android/settings/AdvancedSecuritySettings.java
@@ -24,7 +24,6 @@
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
-import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.service.trust.TrustAgentService;
 import android.util.ArrayMap;
@@ -34,7 +33,6 @@
 import android.view.ViewGroup;
 import android.widget.BaseAdapter;
 import android.widget.CheckBox;
-import android.widget.ImageView;
 import android.widget.TextView;
 
 import java.util.List;
@@ -52,9 +50,7 @@
 
     public static final class AgentInfo {
         CharSequence label;
-        Drawable icon;
         ComponentName component; // service that implements ITrustAgent
-        ComponentName settings; // setting to launch to modify agent.
 
         @Override
         public boolean equals(Object other) {
@@ -114,11 +110,7 @@
             if (!mAvailableAgents.containsKey(name)) {
                 AgentInfo agentInfo = new AgentInfo();
                 agentInfo.label = resolveInfo.loadLabel(pm);
-                agentInfo.icon = resolveInfo.loadIcon(pm);
                 agentInfo.component = name;
-                TrustAgentUtils.TrustAgentComponentInfo trustAgentComponentInfo =
-                        TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
-                agentInfo.settings = trustAgentComponentInfo.componentName;
                 mAvailableAgents.put(name, agentInfo);
             }
         }
@@ -128,16 +120,8 @@
     @Override
     public void onClick(View view) {
         ViewHolder h = (ViewHolder) view.getTag();
-        AgentInfo agentInfo = h.agentInfo;
 
-        if (view.getId() == R.id.settings) {
-            if (agentInfo.settings != null) {
-                Intent intent = new Intent();
-                intent.setComponent(agentInfo.settings);
-                intent.setAction("TODO");
-                startActivity(intent);
-            }
-        } else if (view.getId() == R.id.clickable) {
+        if (view.getId() == R.id.clickable) {
             boolean wasActive = mActiveAgents.contains(h.agentInfo.component);
             loadActiveAgents();
             if (!wasActive) {
@@ -163,13 +147,11 @@
     }
 
     static class ViewHolder {
-        ImageView icon;
         TextView name;
         CheckBox checkbox;
         TextView description;
         AgentInfo agentInfo;
         View clickable;
-        View settings;
     }
 
     class AgentListAdapter extends BaseAdapter {
@@ -218,16 +200,12 @@
         public View newView(ViewGroup parent) {
             View v = mInflater.inflate(R.layout.trust_agent_item, parent, false);
             ViewHolder h = new ViewHolder();
-            h.icon = (ImageView)v.findViewById(R.id.icon);
             h.name = (TextView)v.findViewById(R.id.name);
             h.checkbox = (CheckBox)v.findViewById(R.id.checkbox);
             h.clickable = v.findViewById(R.id.clickable);
             h.clickable.setOnClickListener(AdvancedSecuritySettings.this);
             h.description = (TextView)v.findViewById(R.id.description);
-            h.settings = v.findViewById(R.id.settings);
-            h.settings.setOnClickListener(AdvancedSecuritySettings.this);
             v.setTag(h);
-            h.settings.setTag(h);
             h.clickable.setTag(h);
             return v;
         }
@@ -238,7 +216,6 @@
             vh.name.setText(item.label);
             vh.checkbox.setChecked(mActiveAgents.contains(item.component));
             vh.agentInfo = item;
-            vh.settings.setVisibility(item.settings != null ? View.VISIBLE : View.INVISIBLE);
         }
     }
 }
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 151927d..7f159ab 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -35,6 +35,8 @@
 import android.os.UserHandle;
 import android.os.storage.IMountService;
 import android.os.storage.StorageManager;
+
+import android.phone.PhoneManager;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.text.Editable;
@@ -858,9 +860,8 @@
             return;
         }
 
-        final int newState = getTelephonyManager().getCallState();
         int textId;
-        if (newState == TelephonyManager.CALL_STATE_OFFHOOK) {
+        if (getPhoneManager().isInAPhoneCall()) {
             // Show "return to call" text and show phone icon
             textId = R.string.cryptkeeper_return_to_call;
             final int phoneCallIcon = R.drawable.stat_sys_phone_call;
@@ -878,9 +879,9 @@
     }
 
     private void takeEmergencyCallAction() {
-        TelephonyManager telephonyManager = getTelephonyManager();
-        if (telephonyManager.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK) {
-            telephonyManager.showCallScreen();
+        PhoneManager phoneManager = getPhoneManager();
+        if (phoneManager.isInAPhoneCall()) {
+            phoneManager.showCallScreen(false /* showDialpad */);
         } else {
             launchEmergencyDialer();
         }
@@ -899,6 +900,10 @@
         return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
     }
 
+    private PhoneManager getPhoneManager() {
+        return (PhoneManager) getSystemService(Context.PHONE_SERVICE);
+    }
+
     /**
      * Listen to key events so we can disable sounds when we get a keyinput in EditText.
      */