diff options
Diffstat (limited to 'src/com')
14 files changed, 226 insertions, 460 deletions
diff --git a/src/com/android/settings/AdvancedSecuritySettings.java b/src/com/android/settings/AdvancedSecuritySettings.java deleted file mode 100644 index 3ddbf96..0000000 --- a/src/com/android/settings/AdvancedSecuritySettings.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.settings; - -import com.android.internal.widget.LockPatternUtils; - -import android.app.ListFragment; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.os.Bundle; -import android.service.trust.TrustAgentService; -import android.util.ArrayMap; -import android.util.ArraySet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.CheckBox; -import android.widget.TextView; - -import java.util.List; - -public class AdvancedSecuritySettings extends ListFragment implements View.OnClickListener { - static final String TAG = "AdvancedSecuritySettings"; - - private static final String SERVICE_INTERFACE = TrustAgentService.SERVICE_INTERFACE; - - private final ArraySet<ComponentName> mActiveAgents = new ArraySet<ComponentName>(); - private final ArrayMap<ComponentName, AgentInfo> mAvailableAgents - = new ArrayMap<ComponentName, AgentInfo>(); - - private LockPatternUtils mLockPatternUtils; - - public static final class AgentInfo { - CharSequence label; - ComponentName component; // service that implements ITrustAgent - - @Override - public boolean equals(Object other) { - if (other instanceof AgentInfo) { - return component.equals(((AgentInfo)other).component); - } - return true; - } - - public int compareTo(AgentInfo other) { - return component.compareTo(other.component); - } - } - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - if (mLockPatternUtils == null) { - mLockPatternUtils = new LockPatternUtils( - container.getContext().getApplicationContext()); - } - setListAdapter(new AgentListAdapter()); - return inflater.inflate(R.layout.advanced_security_settings, container, false); - } - - @Override - public void onResume() { - super.onResume(); - updateList(); - } - - void updateList() { - Context context = getActivity(); - if (context == null) { - return; - } - - loadActiveAgents(); - - PackageManager pm = getActivity().getPackageManager(); - Intent trustAgentIntent = new Intent(SERVICE_INTERFACE); - List<ResolveInfo> resolveInfos = pm.queryIntentServices(trustAgentIntent, - PackageManager.GET_META_DATA); - - mAvailableAgents.clear(); - mAvailableAgents.ensureCapacity(resolveInfos.size()); - - for (ResolveInfo resolveInfo : resolveInfos) { - if (resolveInfo.serviceInfo == null) continue; - if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue; - ComponentName name = TrustAgentUtils.getComponentName(resolveInfo); - if (!mAvailableAgents.containsKey(name)) { - AgentInfo agentInfo = new AgentInfo(); - agentInfo.label = resolveInfo.loadLabel(pm); - agentInfo.component = name; - mAvailableAgents.put(name, agentInfo); - } - } - ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); - } - - @Override - public void onClick(View view) { - ViewHolder h = (ViewHolder) view.getTag(); - - if (view.getId() == R.id.clickable) { - boolean wasActive = mActiveAgents.contains(h.agentInfo.component); - loadActiveAgents(); - if (!wasActive) { - mActiveAgents.add(h.agentInfo.component); - } else { - mActiveAgents.remove(h.agentInfo.component); - } - saveActiveAgents(); - ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); - } - } - - private void loadActiveAgents() { - mActiveAgents.clear(); - List<ComponentName> activeTrustAgents = mLockPatternUtils.getEnabledTrustAgents(); - if (activeTrustAgents != null) { - mActiveAgents.addAll(activeTrustAgents); - } - } - - private void saveActiveAgents() { - mLockPatternUtils.setEnabledTrustAgents(mActiveAgents); - } - - static class ViewHolder { - TextView name; - CheckBox checkbox; - TextView description; - AgentInfo agentInfo; - View clickable; - } - - class AgentListAdapter extends BaseAdapter { - final LayoutInflater mInflater; - - AgentListAdapter() { - mInflater = (LayoutInflater) - getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - - public boolean hasStableIds() { - return false; - } - - public int getCount() { - return mAvailableAgents.size(); - } - - public Object getItem(int position) { - return mAvailableAgents.valueAt(position); - } - - public long getItemId(int position) { - return position; - } - - public boolean areAllItemsEnabled() { - return false; - } - - public boolean isEnabled(int position) { - return true; - } - - public View getView(int position, View convertView, ViewGroup parent) { - View v; - if (convertView == null) { - v = newView(parent); - } else { - v = convertView; - } - bindView(v, position); - return v; - } - - public View newView(ViewGroup parent) { - View v = mInflater.inflate(R.layout.trust_agent_item, parent, false); - ViewHolder h = new ViewHolder(); - 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); - v.setTag(h); - h.clickable.setTag(h); - return v; - } - - public void bindView(View view, int position) { - ViewHolder vh = (ViewHolder) view.getTag(); - AgentInfo item = mAvailableAgents.valueAt(position); - vh.name.setText(item.label); - vh.checkbox.setChecked(mActiveAgents.contains(item.component)); - vh.agentInfo = item; - } - } -} diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java index 129b201..c2295e6 100644 --- a/src/com/android/settings/CryptKeeper.java +++ b/src/com/android/settings/CryptKeeper.java @@ -170,6 +170,11 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList } else if (failedAttempts == MAX_FAILED_ATTEMPTS) { // Factory reset the device. sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); + } else if (failedAttempts == -1) { + // Right password, but decryption failed. Tell user bad news ... + setContentView(R.layout.crypt_keeper_progress); + showFactoryReset(true); + return; } else { // Wrong entry. Handle pattern case. if (mLockPatternView != null) { @@ -392,7 +397,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList private void setupUi() { if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) { setContentView(R.layout.crypt_keeper_progress); - showFactoryReset(); + showFactoryReset(false); return; } @@ -508,7 +513,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList updateProgress(); } - private void showFactoryReset() { + /** + * Show factory reset screen allowing the user to reset their phone when + * there is nothing else we can do + * @param corrupt true if userdata is corrupt, false if encryption failed + * partway through + */ + private void showFactoryReset(boolean corrupt) { // Hide the encryption-bot to make room for the "factory reset" button findViewById(R.id.encroid).setVisibility(View.GONE); @@ -524,8 +535,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList }); // Alert the user of the failure. - ((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_failed_title); - ((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_failed_summary); + if (corrupt) { + ((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_data_corrupt_title); + ((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_data_corrupt_summary); + } else { + ((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_failed_title); + ((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_failed_summary); + } final View view = findViewById(R.id.bottom_divider); // TODO(viki): Why would the bottom divider be missing in certain layouts? Investigate. @@ -538,7 +554,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList final String state = SystemProperties.get("vold.encrypt_progress"); if ("error_partially_encrypted".equals(state)) { - showFactoryReset(); + showFactoryReset(false); return; } diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index ba8e2f1..7b12e6f 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -117,6 +117,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private static final String DISABLE_OVERLAYS_KEY = "disable_overlays"; private static final String SIMULATE_COLOR_SPACE = "simulate_color_space"; private static final String USE_NUPLAYER_KEY = "use_nuplayer"; + private static final String USB_AUDIO_KEY = "usb_audio"; private static final String USE_AWESOMEPLAYER_PROPERTY = "persist.sys.media.use-awesome"; private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage"; private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui"; @@ -222,6 +223,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private ListPreference mSimulateColorSpace; private CheckBoxPreference mUseNuplayer; + private CheckBoxPreference mUSBAudio; private CheckBoxPreference mImmediatelyDestroyActivities; private ListPreference mAppProcessLimit; @@ -343,6 +345,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment mOpenGLTraces = addListPreference(OPENGL_TRACES_KEY); mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE); mUseNuplayer = findAndInitCheckboxPref(USE_NUPLAYER_KEY); + mUSBAudio = findAndInitCheckboxPref(USB_AUDIO_KEY); mImmediatelyDestroyActivities = (CheckBoxPreference) findPreference( IMMEDIATELY_DESTROY_ACTIVITIES_KEY); @@ -549,6 +552,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment updateWifiAllowScansWithTrafficOptions(); updateSimulateColorSpace(); updateUseNuplayerOptions(); + updateUSBAudioOptions(); } private void resetDangerousOptions() { @@ -1013,6 +1017,17 @@ public class DevelopmentSettings extends SettingsPreferenceFragment pokeSystemProperties(); } + private void updateUSBAudioOptions() { + updateCheckBox(mUSBAudio, Settings.Secure.getInt(getContentResolver(), + Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0); + } + + private void writeUSBAudioOptions() { + Settings.Secure.putInt(getContentResolver(), + Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, + mUSBAudio.isChecked() ? 1 : 0); + } + private void updateForceRtlOptions() { updateCheckBox(mForceRtlLayout, Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.DEVELOPMENT_FORCE_RTL, 0) != 0); @@ -1417,6 +1432,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment writeWifiAllowScansWithTrafficOptions(); } else if (preference == mUseNuplayer) { writeUseNuplayerOptions(); + } else if (preference == mUSBAudio) { + writeUSBAudioOptions(); } else { return super.onPreferenceTreeClick(preferenceScreen, preference); } diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java index 0bd548f..ed95500 100644 --- a/src/com/android/settings/DeviceAdminAdd.java +++ b/src/com/android/settings/DeviceAdminAdd.java @@ -32,7 +32,10 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.os.Bundle; @@ -103,6 +106,7 @@ public class DeviceAdminAdd extends Activity { mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); mAppOps = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE); + PackageManager packageManager = getPackageManager(); if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { Log.w(TAG, "Cannot start ADD_DEVICE_ADMIN as a new task"); @@ -120,6 +124,8 @@ public class DeviceAdminAdd extends Activity { } if (action != null && action.equals(DevicePolicyManager.ACTION_SET_PROFILE_OWNER)) { + setResult(RESULT_CANCELED); + setFinishOnTouchOutside(true); mAddingProfileOwner = true; mProfileOwnerName = getIntent().getStringExtra(DevicePolicyManager.EXTRA_PROFILE_OWNER_NAME); @@ -129,11 +135,23 @@ public class DeviceAdminAdd extends Activity { finish(); return; } + try { + PackageInfo packageInfo = packageManager.getPackageInfo(callingPackage, 0); + if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { + Log.e(TAG, "Cannot set a non-system app as a profile owner"); + finish(); + return; + } + } catch (NameNotFoundException nnfe) { + Log.e(TAG, "Cannot find the package " + callingPackage); + finish(); + return; + } } ActivityInfo ai; try { - ai = getPackageManager().getReceiverInfo(who, PackageManager.GET_META_DATA); + ai = packageManager.getReceiverInfo(who, PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Unable to retrieve device policy " + who, e); finish(); @@ -144,7 +162,7 @@ public class DeviceAdminAdd extends Activity { // No need to check this when deactivating, because it is safe to deactivate an active // invalid device admin. if (!mDPM.isAdminActive(who)) { - List<ResolveInfo> avail = getPackageManager().queryBroadcastReceivers( + List<ResolveInfo> avail = packageManager.queryBroadcastReceivers( new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED), PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS); int count = avail == null ? 0 : avail.size(); diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 7f51599..1b9f44c 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -296,14 +296,10 @@ public class SecuritySettings extends SettingsPreferenceFragment root.findPreference(KEY_SIM_LOCK).setEnabled(false); } } - try { - if (Settings.System.getInt(getContentResolver(), Settings.System.LOCK_TO_APP_ENABLED) - != 0) { - root.findPreference(KEY_SCREEN_PINNING).setSummary( - getResources().getString(R.string.switch_on_text)); - } - } catch (SettingNotFoundException e) { - Log.w(TAG, "No Lock-to-app enabled setting", e); + if (Settings.System.getInt(getContentResolver(), + Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) { + root.findPreference(KEY_SCREEN_PINNING).setSummary( + getResources().getString(R.string.switch_on_text)); } // Show password diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index a8e28df..e0ab5bc 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -72,7 +72,6 @@ import com.android.settings.applications.InstalledAppDetails; import com.android.settings.applications.ManageApplications; import com.android.settings.applications.ProcessStatsUi; import com.android.settings.bluetooth.BluetoothSettings; -import com.android.settings.bluetooth.MessageAccessSettings; import com.android.settings.dashboard.DashboardCategory; import com.android.settings.dashboard.DashboardSummary; import com.android.settings.dashboard.DashboardTile; @@ -238,7 +237,6 @@ public class SettingsActivity extends Activity AdvancedWifiSettings.class.getName(), SavedAccessPointsWifiSettings.class.getName(), BluetoothSettings.class.getName(), - MessageAccessSettings.class.getName(), SimSettings.class.getName(), TetherSettings.class.getName(), WifiP2pSettings.class.getName(), diff --git a/src/com/android/settings/TrustAgentSettings.java b/src/com/android/settings/TrustAgentSettings.java new file mode 100644 index 0000000..54fef36 --- /dev/null +++ b/src/com/android/settings/TrustAgentSettings.java @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings; + +import java.util.List; + +import android.content.ComponentName; +import android.content.Context; +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.preference.Preference; +import android.preference.PreferenceGroup; +import android.preference.SwitchPreference; +import android.service.trust.TrustAgentService; +import android.util.ArrayMap; +import android.util.ArraySet; + +import com.android.internal.widget.LockPatternUtils; + +public class TrustAgentSettings extends SettingsPreferenceFragment implements + Preference.OnPreferenceChangeListener { + private static final String SERVICE_INTERFACE = TrustAgentService.SERVICE_INTERFACE; + private ArrayMap<ComponentName, AgentInfo> mAvailableAgents; + private final ArraySet<ComponentName> mActiveAgents = new ArraySet<ComponentName>(); + private LockPatternUtils mLockPatternUtils; + + public static final class AgentInfo { + CharSequence label; + ComponentName component; // service that implements ITrustAgent + SwitchPreference preference; + public Drawable icon; + + @Override + public boolean equals(Object other) { + if (other instanceof AgentInfo) { + return component.equals(((AgentInfo)other).component); + } + return true; + } + + public int compareTo(AgentInfo other) { + return component.compareTo(other.component); + } + } + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + addPreferencesFromResource(R.xml.trust_agent_settings); + } + + public void onResume() { + super.onResume(); + updateAgents(); + }; + + private void updateAgents() { + final Context context = getActivity(); + if (mAvailableAgents == null) { + mAvailableAgents = findAvailableTrustAgents(); + } + if (mLockPatternUtils == null) { + mLockPatternUtils = new LockPatternUtils(getActivity()); + } + loadActiveAgents(); + PreferenceGroup category = + (PreferenceGroup) getPreferenceScreen().findPreference("trust_agents"); + category.removeAll(); + final int count = mAvailableAgents.size(); + for (int i = 0; i < count; i++) { + AgentInfo agent = mAvailableAgents.valueAt(i); + final SwitchPreference preference = new SwitchPreference(context); + agent.preference = preference; + preference.setPersistent(false); + preference.setTitle(agent.label); + preference.setIcon(agent.icon); + preference.setPersistent(false); + preference.setOnPreferenceChangeListener(this); + preference.setChecked(mActiveAgents.contains(agent.component)); + category.addPreference(agent.preference); + } + } + + private void loadActiveAgents() { + List<ComponentName> activeTrustAgents = mLockPatternUtils.getEnabledTrustAgents(); + if (activeTrustAgents != null) { + mActiveAgents.addAll(activeTrustAgents); + } + } + + private void saveActiveAgents() { + mLockPatternUtils.setEnabledTrustAgents(mActiveAgents); + } + + ArrayMap<ComponentName, AgentInfo> findAvailableTrustAgents() { + PackageManager pm = getActivity().getPackageManager(); + Intent trustAgentIntent = new Intent(SERVICE_INTERFACE); + List<ResolveInfo> resolveInfos = pm.queryIntentServices(trustAgentIntent, + PackageManager.GET_META_DATA); + + ArrayMap<ComponentName, AgentInfo> agents = new ArrayMap<ComponentName, AgentInfo>(); + final int count = resolveInfos.size(); + agents.ensureCapacity(count); + for (int i = 0; i < count; i++ ) { + ResolveInfo resolveInfo = resolveInfos.get(i); + if (resolveInfo.serviceInfo == null) continue; + if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue; + ComponentName name = TrustAgentUtils.getComponentName(resolveInfo); + AgentInfo agentInfo = new AgentInfo(); + agentInfo.label = resolveInfo.loadLabel(pm); + agentInfo.icon = resolveInfo.loadIcon(pm); + agentInfo.component = name; + agents.put(name, agentInfo); + } + return agents; + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if (preference instanceof SwitchPreference) { + final int count = mAvailableAgents.size(); + for (int i = 0; i < count; i++) { + AgentInfo agent = mAvailableAgents.valueAt(i); + if (agent.preference == preference) { + if ((Boolean) newValue) { + if (!mActiveAgents.contains(agent.component)) { + mActiveAgents.add(agent.component); + } + } else { + mActiveAgents.remove(agent.component); + } + saveActiveAgents(); + return true; + } + } + } + return false; + } + +} diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index bbd86a1..3c62ba9 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -69,7 +69,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem private static final int MENU_ID_SCAN = Menu.FIRST; private static final int MENU_ID_RENAME_DEVICE = Menu.FIRST + 1; private static final int MENU_ID_SHOW_RECEIVED = Menu.FIRST + 2; - private static final int MENU_ID_MESSAGE_ACCESS = Menu.FIRST + 3; /* Private intent to show the list of received files */ private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES = @@ -205,12 +204,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(Menu.NONE, MENU_ID_SHOW_RECEIVED, 0, R.string.bluetooth_show_received_files) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); - // Message Access API is still not finished, once completed we undo this check. - // Bug 16232864 - if (android.os.SystemProperties.get("show_bluetooth_message_access").equals("true")){ - menu.add(Menu.NONE, MENU_ID_MESSAGE_ACCESS, 0, R.string.bluetooth_show_message_access) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); - } super.onCreateOptionsMenu(menu, inflater); } @@ -232,14 +225,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES); getActivity().sendBroadcast(intent); return true; - - case MENU_ID_MESSAGE_ACCESS: - if (getActivity() instanceof SettingsActivity) { - ((SettingsActivity) getActivity()).startPreferencePanel( - MessageAccessSettings.class.getCanonicalName(), null, - R.string.bluetooth_show_message_access, null, this, 0); - } - return true; } return super.onOptionsItemSelected(item); } @@ -377,7 +362,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem } } - @Override public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) { setDeviceListGroup(getPreferenceScreen()); removeAllDevices(); diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index a7104df..3b64ade 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -539,7 +539,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { if (bondState == BluetoothDevice.BOND_NONE) { mProfiles.clear(); mConnectAfterPairing = false; // cancel auto-connect - setPhonebookPermissionChoice(ACCESS_ALLOWED); + setPhonebookPermissionChoice(ACCESS_UNKNOWN); setMessagePermissionChoice(ACCESS_UNKNOWN); mPhonebookRejectedTimes = 0; savePhonebookRejectTimes(); diff --git a/src/com/android/settings/bluetooth/MessageAccessSettings.java b/src/com/android/settings/bluetooth/MessageAccessSettings.java deleted file mode 100644 index 913357c..0000000 --- a/src/com/android/settings/bluetooth/MessageAccessSettings.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.bluetooth; - -import android.accounts.Account; -import android.accounts.AccountManager; -import android.app.ActivityManagerNative; -import android.content.Context; -import android.content.pm.PackageManager.NameNotFoundException; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.os.UserHandle; -import android.preference.SwitchPreference; -import android.preference.Preference; -import android.preference.PreferenceGroup; -import android.preference.PreferenceScreen; -import android.provider.SearchIndexableResource; -import android.util.Log; - -import com.android.settings.accounts.AuthenticatorHelper; -import com.android.settings.R; -import com.android.settings.SettingsPreferenceFragment; -import com.android.settings.Utils; -import com.android.settings.search.BaseSearchIndexProvider; -import com.android.settings.search.Indexable; - -import java.util.ArrayList; -import java.util.List; - -public class MessageAccessSettings extends SettingsPreferenceFragment - implements AuthenticatorHelper.OnAccountsUpdateListener, Indexable { - private static final String TAG = "MessageAccessSettings"; - private static final String GMAIL_PACKAGE_NAME = "com.google.android.gm"; - private static final String EMAIL_PACKAGE_NAME = "com.google.android.email"; - - private Account[] mAccounts; - private UserHandle mUserHandle; - private PreferenceGroup mAvailableAccounts; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // TODO: Define behavior for managed profile. See: http://b/16287773 - mUserHandle = new UserHandle(UserHandle.myUserId()); - - addPreferencesFromResource(R.xml.bluetooth_message_access); - } - - @Override - public void onResume() { - super.onResume(); - initPreferences(); - } - - @Override - public void onAccountsUpdate(final UserHandle userHandle) { - mAccounts = AccountManager.get(getActivity()).getAccountsAsUser( - mUserHandle.getIdentifier()); - - final int mAccountsSize = mAccounts.length; - for (int i = 0; i < mAccountsSize; ++i){ - Log.d(TAG, String.format("account.type = %s\n", mAccounts[i].type)); - } - } - - /** - * Retrieves the email icon for a given account's email preference - * - * @param accountPref The user's account to retrieve the icon from. - * - * @return The drawable representing the icon of the user's email preference - **/ - private Drawable getIcon(AccountPreference accountPref){ - Drawable icon = null; - - // Currently only two types of icons are allowed. - final String packageName = accountPref.account.type.equals("com.google") - ? GMAIL_PACKAGE_NAME : EMAIL_PACKAGE_NAME; - - try{ - icon = getPackageManager().getApplicationIcon(packageName); - }catch(NameNotFoundException nnfe){ - icon = null; - } - - return icon; - } - - private void initPreferences() { - final PreferenceScreen preferenceScreen = getPreferenceScreen(); - mAvailableAccounts = (PreferenceGroup)preferenceScreen.findPreference("accounts"); - mAccounts = AccountManager.get(getActivity()).getAccountsAsUser( - mUserHandle.getIdentifier()); - - final int mAccountsSize = mAccounts.length; - for (int i = 0; i < mAccountsSize; ++i){ - AccountPreference accountPref = new AccountPreference(getActivity(), mAccounts[i]); - Drawable icon = getIcon(accountPref); - if (icon != null){ - accountPref.setIcon(icon); - } - mAvailableAccounts.addPreference(accountPref); - } - } - - private class AccountPreference extends SwitchPreference - implements Preference.OnPreferenceChangeListener{ - private Account account; - - AccountPreference(Context context, Account account){ - super(context); - this.account = account; - setTitle(account.type); - setSummary(account.name); - - setOnPreferenceChangeListener(this); - } - - @Override - public boolean onPreferenceChange(Preference preference, Object val) { - if (preference instanceof AccountPreference){ - final AccountPreference accountPref = (AccountPreference) preference; - - if (((Boolean)val).booleanValue()){ - // Enable paired deviced to connect, fill in once API is available - Log.w(TAG, String.format( - "User has turned on '%s' for Bluetooth message access.", - accountPref.account.name)); - } else { - // Disable paired deviced to connect, fill in once API is available - Log.w(TAG, String.format( - "User has turned off '%s' for Bluetooth message access.", - accountPref.account.name)); - } - } - return true; - } - } - - public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = - new BaseSearchIndexProvider() { - @Override - public List<SearchIndexableResource> getXmlResourcesToIndex( - Context context, boolean enabled) { - List<SearchIndexableResource> indexables = new ArrayList<SearchIndexableResource>(); - SearchIndexableResource indexable = new SearchIndexableResource(context); - indexable.xmlResId = R.xml.bluetooth_message_access; - indexables.add(indexable); - return indexables; - } - }; -} diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java index c8b86ae..3528c56 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java +++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java @@ -807,33 +807,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment R.string.builtin_keyboard_settings_title); indexable.screenTitle = screenTitle; indexables.add(indexable); - - // Auto replace. - indexable = new SearchIndexableRaw(context); - indexable.key = "auto_replace"; - indexable.title = context.getString(R.string.auto_replace); - indexable.summaryOn = context.getString(R.string.auto_replace_summary); - indexable.summaryOff = context.getString(R.string.auto_replace_summary); - indexable.screenTitle = screenTitle; - indexables.add(indexable); - - // Auto caps. - indexable = new SearchIndexableRaw(context); - indexable.key = "auto_caps"; - indexable.title = context.getString(R.string.auto_caps); - indexable.summaryOn = context.getString(R.string.auto_caps_summary); - indexable.summaryOff = context.getString(R.string.auto_caps_summary); - indexable.screenTitle = screenTitle; - indexables.add(indexable); - - // Auto punctuate. - indexable = new SearchIndexableRaw(context); - indexable.key = "auto_punctuate"; - indexable.title = context.getString(R.string.auto_punctuate); - indexable.summaryOn = context.getString(R.string.auto_punctuate_summary); - indexable.summaryOff = context.getString(R.string.auto_punctuate_summary); - indexable.screenTitle = screenTitle; - indexables.add(indexable); } // Voice input diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java index 1a08aa2..2c76002 100644 --- a/src/com/android/settings/search/Ranking.java +++ b/src/com/android/settings/search/Ranking.java @@ -30,7 +30,6 @@ import com.android.settings.WallpaperTypeSettings; import com.android.settings.WirelessSettings; import com.android.settings.accessibility.AccessibilitySettings; import com.android.settings.bluetooth.BluetoothSettings; -import com.android.settings.bluetooth.MessageAccessSettings; import com.android.settings.deviceinfo.Memory; import com.android.settings.fuelgauge.BatterySaverSettings; import com.android.settings.fuelgauge.PowerUsageSummary; @@ -94,7 +93,6 @@ public final class Ranking { // BT sRankMap.put(BluetoothSettings.class.getName(), RANK_BT); - sRankMap.put(MessageAccessSettings.class.getName(), RANK_BT); // SIM Cards sRankMap.put(SimSettings.class.getName(), RANK_SIM); diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 31dac7b..5108da3 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -33,7 +33,6 @@ import com.android.settings.WallpaperTypeSettings; import com.android.settings.WirelessSettings; import com.android.settings.accessibility.AccessibilitySettings; import com.android.settings.bluetooth.BluetoothSettings; -import com.android.settings.bluetooth.MessageAccessSettings; import com.android.settings.deviceinfo.Memory; import com.android.settings.fuelgauge.BatterySaverSettings; import com.android.settings.fuelgauge.PowerUsageSummary; @@ -97,13 +96,6 @@ public final class SearchIndexableResources { SimSettings.class.getName(), R.drawable.ic_sim_sd)); - sResMap.put(MessageAccessSettings.class.getName(), - new SearchIndexableResource( - Ranking.getRankForClassName(MessageAccessSettings.class.getName()), - NO_DATA_RES_ID, - MessageAccessSettings.class.getName(), - R.drawable.ic_settings_bluetooth2)); - sResMap.put(DataUsageSummary.class.getName(), new SearchIndexableResource( Ranking.getRankForClassName(DataUsageSummary.class.getName()), diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java index 93f9b0f..9ad34a9 100644 --- a/src/com/android/settings/users/UserSettings.java +++ b/src/com/android/settings/users/UserSettings.java @@ -790,6 +790,8 @@ public class UserSettings extends SettingsPreferenceFragment } else { setPhotoId(pref, user); } + } else { + pref.setIcon(getEncircledDefaultAvatar()); } } @@ -833,7 +835,7 @@ public class UserSettings extends SettingsPreferenceFragment if (missingIcons.size() > 0) { loadIconsAsync(missingIcons); } - boolean moreUsers = mUserManager.getMaxSupportedUsers() > users.size(); + boolean moreUsers = mUserManager.canAddMoreUsers(); mAddUser.setEnabled(moreUsers); } @@ -849,6 +851,9 @@ public class UserSettings extends SettingsPreferenceFragment protected Void doInBackground(List<Integer>... values) { for (int userId : values[0]) { Bitmap bitmap = mUserManager.getUserIcon(userId); + if (bitmap == null) { + bitmap = createBitmapFromDrawable(R.drawable.ic_avatar_default_1); + } mUserIcons.append(userId, bitmap); } return null; |