Merge "Fix managed profile bugs in manage apps list"
diff --git a/res/layout/user_preference.xml b/res/layout/user_preference.xml
index 91db846..8e81fec 100644
--- a/res/layout/user_preference.xml
+++ b/res/layout/user_preference.xml
@@ -18,6 +18,8 @@
android:id="@android:id/widget_frame"
android:layout_width="match_parent"
android:layout_height="@dimen/user_spinner_item_height"
+ android:paddingStart="@dimen/user_spinner_padding_sides"
+ android:paddingEnd="@dimen/user_spinner_padding_sides"
android:orientation="horizontal" >
<ImageView
@@ -42,4 +44,4 @@
android:paddingEnd="@dimen/user_spinner_padding"
style="@style/TextAppearance.Medium" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5ed69c4..580ae22 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -213,6 +213,7 @@
<!-- User spinner -->
<dimen name="user_spinner_height">72dp</dimen>
<dimen name="user_spinner_padding">4dp</dimen>
+ <dimen name="user_spinner_padding_sides">20dp</dimen>
<dimen name="user_spinner_item_height">56dp</dimen>
<!-- CheckBoxPreference -->
diff --git a/res/values/donottranslate.xml b/res/values/donottranslate.xml
index e6bd9a6..611e2b4 100644
--- a/res/values/donottranslate.xml
+++ b/res/values/donottranslate.xml
@@ -33,4 +33,8 @@
<item>@string/input_method_selector_always_show_value</item>
<item>@string/input_method_selector_always_hide_value</item>
</string-array>
+ <string name="category_key_wireless">com.android.settings.category.wireless</string>
+ <string name="category_key_device">com.android.settings.category.device</string>
+ <string name="category_key_personal">com.android.settings.category.personal</string>
+ <string name="category_key_system">com.android.settings.category.system</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4c13e4a..d87d98f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -764,7 +764,8 @@
</plurals>
<!-- Introduction title shown in fingerprint enrollment dialog [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_enroll_onboard_title">Fingerprint setup</string>
- <!-- Introduction detail message shown in fingerprint enrollment dialog -->
+ <!-- Introduction message shown in fingerprint enrollment dialog when the user needs to choose an
+ alternate screen unlock (pin, pattern or password) as a backup to fingerprint. -->
<string name="security_settings_fingerprint_enroll_onboard_message">
To use your fingerprint to unlock your screen or confirm purchases, we\'ll need to:
\n\n\u2713 Set up your backup screen lock method
@@ -796,22 +797,6 @@
<string name="fingerprint_enroll_button_add">Add</string>
<!-- Button text shown at the end of enrollment that allows the user to move to the next step -->
<string name="fingerprint_enroll_button_next">Next</string>
- <!-- Error message shown when the fingerprint cannot be recognized -->
- <string name="fingerprint_acquired_try_again">Partial fingerprint detected. Please try again.</string>
- <!-- Error message shown when the fingerprint sensor needs cleaning -->
- <string name="fingerprint_acquired_imager_dirty">Fingerprint sensor is dirty. Please clean and try again.</string>
- <!-- Error message shown when the user removes their finger from the sensor too quickly -->
- <string name="fingerprint_acquired_too_fast">Finger moved to fast. Please try again.</string>
- <!-- Error message shown when the user moves their finger too slowly -->
- <string name="fingerprint_acquired_too_slow">Finger moved to slow. Please try again.</string>
- <!-- Generic error message shown when the fingerprint hardware can't recognize the fingerprint -->
- <string name="fingerprint_error_unable_to_process">Unable to process. Try again.</string>
- <!-- Error message shown when the fingerprint hardware can't be accessed -->
- <string name="fingerprint_error_hw_not_available">Hardware not available.</string>
- <!-- Error message shown when the fingerprint hardware has run out of room for storing fingerprints -->
- <string name="fingerprint_error_no_space">Fingerprint can\'t be stored. Please remove an existing fingerprint.</string>
- <!-- Error message shown when the fingerprint hardware timer has expired and the user needs to restart the operation. -->
- <string name="fingerprint_error_timeout">Fingerprint time out reached. Try again.</string>
<!-- Title of the preferences category for preference items to control encryption -->
<string name="crypt_keeper_settings_title">Encryption</string>
@@ -1835,10 +1820,6 @@
<string name="wfc_mode_cellular_preferred_summary">Cellular preferred (Uses Wi-Fi only if cell network isn\'t available)</string>
<!-- WFC, summary for Wi-Fi Only [CHAR LIMIT=100] -->
<string name="wfc_mode_wifi_only_summary">Wi-Fi only (Never uses cell network. Can\'t make or receive calls if Wi-Fi isn\'t available)</string>
- <!-- WFC roam enable/disable [CHAR LIMIT=30] -->
- <string name="wifi_calling_roam_title">WFC handoff while roaming</string>
- <!-- WFC roam summary [CHAR LIMIT=80] -->
- <string name="wifi_calling_roam_summary">Allow Wi-Fi voice calls handoff to cell network when roaming</string>
<!-- Sound and alerts settings -->
<skip/>
@@ -3391,6 +3372,21 @@
<string name="confirm_enable_oem_unlock_text">WARNING: Device protection features will not work on this device while this setting is turned on.</string>
+ <!-- UI debug setting: limit size of Android logger buffers -->
+ <string name="select_logd_size_title">Logger buffer sizes</string>
+ <!-- UI debug setting: limit size of Android logger buffers [CHAR LIMIT=59] -->
+ <string name="select_logd_size_dialog_title">Select Logger sizes per log buffer</string>
+ <!-- Setting Checkbox title whether to allow mock locations -->
+ <string name="allow_mock_location">Allow mock locations</string>
+ <!-- setting Checkbox summary whether to allow mock locations -->
+ <string name="allow_mock_location_summary">Allow mock locations</string>
+ <!-- Setting Checkbox title whether to enable view attribute inspection -->
+ <string name="debug_view_attributes">Enable view attribute inspection</string>
+ <!-- Title of warning dialog about the implications of enabling USB debugging -->
+
+ <!-- Preference category for networking debugging development settings. [CHAR LIMIT=50] -->
+ <string name="debug_networking_category">Networking</string>
+
<!-- Setting Checkbox title whether to show options for wireless display certification -->
<string name="wifi_display_certification">Wireless display certification</string>
<!-- Setting Checkbox title whether to enable WiFi Verbose Logging. [CHAR LIMIT=40] -->
@@ -3399,6 +3395,9 @@
<string name="wifi_aggressive_handover">Aggressive Wi\u2011Fi to Cellular handover</string>
<!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
<string name="wifi_allow_scan_with_traffic">Always allow Wi\u2011Fi Roam Scans</string>
+ <!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
+ <string name="legacy_dhcp_client">Use legacy DHCP client</string>
+
<!-- setting Checkbox summary whether to show options for wireless display certification -->
<string name="wifi_display_certification_summary">Show options for wireless display certification</string>
<!-- Setting Checkbox summary whether to enable Wifi verbose Logging [CHAR LIMIT=80] -->
@@ -3422,6 +3421,8 @@
<!-- Setting Checkbox title whether to enable view attribute inspection -->
<string name="debug_view_attributes">Enable view attribute inspection</string>
<!-- Title of warning dialog about the implications of enabling USB debugging -->
+ <!-- Setting Checkbox summary whether to use DHCP client from Lollipop (Android 5.0) [CHAR LIMIT=130] -->
+ <string name="legacy_dhcp_client_summary">Use the DHCP client from Lollipop instead of the new Android DHCP client.</string>
<string name="adb_warning_title">Allow USB debugging?</string>
<!-- Warning text to user about the implications of enabling USB debugging -->
<string name="adb_warning_message">USB debugging is intended for development purposes only. Use it to copy data between your computer and your device, install apps on your device without notification, and read log data.</string>
@@ -5609,7 +5610,7 @@
<string name="keywords_wifi">wifi wi-fi network connection</string>
<string name="keywords_more_default_sms_app">text message texting messages messaging</string>
<string name="keywords_more_mobile_networks">cellular cell carrier wireless data 4g 3g 2g lte</string>
- <string name="keywords_wifi_calling">wifi wi-fi call calling roaming handoff</string>
+ <string name="keywords_wifi_calling">wifi wi-fi call calling</string>
<string name="keywords_home">launcher</string>
<string name="keywords_display">screen touchscreen</string>
<string name="keywords_display_brightness_level">dim screen touchscreen battery</string>
@@ -6132,4 +6133,7 @@
<!-- Warning toast shown when data usage screen can't find specified app -->
<string name="unknown_app">Unknown app</string>
+ <!-- Title for profile selection dialog [CHAR LIMIT=30] -->
+ <string name="choose_profile">Choose Profile</string>
+
</resources>
diff --git a/res/xml/dashboard_categories.xml b/res/xml/dashboard_categories.xml
index 01a4f83..0d8c1ac 100644
--- a/res/xml/dashboard_categories.xml
+++ b/res/xml/dashboard_categories.xml
@@ -20,6 +20,7 @@
<!-- WIRELESS and NETWORKS -->
<dashboard-category
android:id="@+id/wireless_section"
+ android:key="@string/category_key_wireless"
android:title="@string/header_category_wireless_networks" >
<!-- Wifi -->
@@ -74,6 +75,7 @@
<!-- DEVICE -->
<dashboard-category
android:id="@+id/device_section"
+ android:key="@string/category_key_device"
android:title="@string/header_category_device" >
<!-- Home -->
@@ -152,6 +154,7 @@
<!-- PERSONAL -->
<dashboard-category
android:id="@+id/personal_section"
+ android:key="@string/category_key_personal"
android:title="@string/header_category_personal" >
<!-- Location -->
@@ -178,6 +181,9 @@
android:icon="@drawable/ic_settings_accounts"
/>
+ <!-- Marker for where to place external tiles in this category -->
+ <external-tiles />
+
<!-- Language -->
<dashboard-tile
android:id="@+id/language_settings"
@@ -199,6 +205,7 @@
<!-- SYSTEM -->
<dashboard-category
android:id="@+id/system_section"
+ android:key="@string/category_key_system"
android:title="@string/header_category_system" >
<!-- Date & Time -->
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 71351c4e..4e8ca0e 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -60,6 +60,12 @@
android:fragment="com.android.settings.applications.ProcessStatsUi">
</PreferenceScreen>
+ <PreferenceScreen
+ android:key="running_apps"
+ android:title="@string/runningservices_settings_title"
+ android:summary="@string/runningservices_settings_summary"
+ android:fragment="com.android.settings.applications.RunningServices" />
+
<PreferenceCategory android:key="debug_debugging_category"
android:title="@string/debug_debugging_category">
@@ -103,6 +109,18 @@
android:title="@string/verify_apps_over_usb_title"
android:summary="@string/verify_apps_over_usb_summary"/>
+ <ListPreference
+ android:key="select_logd_size"
+ android:title="@string/select_logd_size_title"
+ android:dialogTitle="@string/select_logd_size_dialog_title"
+ android:entries="@array/select_logd_size_titles"
+ android:entryValues="@array/select_logd_size_values" />
+
+ </PreferenceCategory>
+
+ <PreferenceCategory android:key="debug_networking_category"
+ android:title="@string/debug_networking_category">
+
<SwitchPreference
android:key="wifi_display_certification"
android:title="@string/wifi_display_certification"
@@ -123,12 +141,10 @@
android:title="@string/wifi_allow_scan_with_traffic" />
android:summary="@string/wifi_allow_scan_with_traffic_summary"/>
- <ListPreference
- android:key="select_logd_size"
- android:title="@string/select_logd_size_title"
- android:dialogTitle="@string/select_logd_size_dialog_title"
- android:entries="@array/select_logd_size_titles"
- android:entryValues="@array/select_logd_size_values" />
+ <SwitchPreference
+ android:key="legacy_dhcp_client"
+ android:title="@string/legacy_dhcp_client" />
+ android:summary="@string/legacy_dhcp_client_summary"/>
<ListPreference
android:key="select_usb_configuration"
diff --git a/res/xml/wifi_calling_settings.xml b/res/xml/wifi_calling_settings.xml
index 37a2d28..ca4e560 100644
--- a/res/xml/wifi_calling_settings.xml
+++ b/res/xml/wifi_calling_settings.xml
@@ -26,9 +26,4 @@
android:entryValues="@array/wifi_calling_mode_values"
android:dialogTitle="@string/wifi_calling_mode_dialog_title" />
- <SwitchPreference
- android:key="wifi_calling_roam"
- android:title="@string/wifi_calling_roam_title"
- android:persistent="false"/>
-
</PreferenceScreen>
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index 6cec420..b6f907e 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -34,11 +34,14 @@
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.security.KeyStore;
+import android.service.fingerprint.Fingerprint;
import android.service.fingerprint.FingerprintManager;
-import android.service.fingerprint.FingerprintManagerReceiver;
+import android.service.fingerprint.FingerprintManager.RemovalCallback;
import android.util.EventLog;
import android.util.Log;
import android.view.accessibility.AccessibilityManager;
+import android.widget.Toast;
+
import com.android.internal.widget.LockPatternUtils;
import java.util.List;
@@ -96,6 +99,18 @@
private boolean mRequirePassword;
private LockPatternUtils mLockPatternUtils;
private FingerprintManager mFingerprintManager;
+ private RemovalCallback mRemovalCallback = new RemovalCallback() {
+
+ @Override
+ public void onRemovalSucceeded(Fingerprint fingerprint) {
+ Log.v(TAG, "Fingerprint removed: " + fingerprint.getFingerId());
+ }
+
+ @Override
+ public void onRemovalError(Fingerprint fp, int errMsgId, CharSequence errString) {
+ Toast.makeText(getActivity(), errString, Toast.LENGTH_SHORT);
+ }
+ };
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -400,25 +415,15 @@
}
}
- // TODO: This is only required because we used to enforce clients have a listener,
- // which is no longer required in the new API. Remove when that happens.
- FingerprintManagerReceiver mReceiver = new FingerprintManagerReceiver() {
- public void onRemoved(int fingerprintId) {
- Log.v(TAG, "onRemoved(id=" + fingerprintId + ")");
- }
- };
-
private void removeAllFingerprintTemplates() {
if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()) {
- mFingerprintManager.startListening(mReceiver);
- mFingerprintManager.remove(0 /* all fingerprint templates */);
+ mFingerprintManager.remove(new Fingerprint(null, 0, 0, 0), mRemovalCallback);
}
}
@Override
public void onDestroy() {
super.onDestroy();
- mFingerprintManager.stopListening();
}
@Override
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index b5b33f4..192bd5c 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -140,15 +140,19 @@
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
private static final String ENABLE_MULTI_WINDOW_KEY = "enable_multi_window";
private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
+ private static final String DEBUG_APPLICATIONS_CATEGORY_KEY = "debug_applications_category";
+ private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";
+ private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";
+ private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size";
+
+ private static final String DEBUG_NETWORKING_CATEGORY_KEY = "debug_networking_category";
private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification";
private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging";
private static final String WIFI_AGGRESSIVE_HANDOVER_KEY = "wifi_aggressive_handover";
private static final String WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY = "wifi_allow_scan_with_traffic";
- private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";
- private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";
- private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size";
private static final String USB_CONFIGURATION_KEY = "select_usb_configuration";
private static final String SELECT_USB_CONFIGURATION_PROPERTY = "sys.usb.config";
+ private static final String WIFI_LEGACY_DHCP_CLIENT_KEY = "legacy_dhcp_client";
private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
@@ -203,6 +207,7 @@
private SwitchPreference mWifiDisplayCertification;
private SwitchPreference mWifiVerboseLogging;
private SwitchPreference mWifiAggressiveHandover;
+ private SwitchPreference mLegacyDhcpClient;
private SwitchPreference mWifiAllowScansWithTraffic;
private SwitchPreference mStrictMode;
@@ -343,6 +348,7 @@
mWifiVerboseLogging = findAndInitSwitchPref(WIFI_VERBOSE_LOGGING_KEY);
mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
+ mLegacyDhcpClient = findAndInitSwitchPref(WIFI_LEGACY_DHCP_CLIENT_KEY);
mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
@@ -578,6 +584,7 @@
updateWifiVerboseLoggingOptions();
updateWifiAggressiveHandoverOptions();
updateWifiAllowScansWithTrafficOptions();
+ updateLegacyDhcpClientOptions();
updateSimulateColorSpace();
updateUseNuplayerOptions();
updateUSBAudioOptions();
@@ -1120,6 +1127,18 @@
mWifiManager.setAllowScansWithTraffic(mWifiAllowScansWithTraffic.isChecked() ? 1 : 0);
}
+ private void updateLegacyDhcpClientOptions() {
+ updateSwitchPreference(mLegacyDhcpClient, Settings.Global.getInt(
+ getActivity().getContentResolver(),
+ Settings.Global.LEGACY_DHCP_CLIENT, 0) != 0);
+ }
+
+ private void writeLegacyDhcpClientOptions() {
+ Settings.Global.putInt(getActivity().getContentResolver(),
+ Settings.Global.LEGACY_DHCP_CLIENT,
+ mLegacyDhcpClient.isChecked() ? 1 : 0);
+ }
+
private void updateLogdSizeValues() {
if (mLogdSize != null) {
String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
@@ -1558,6 +1577,8 @@
writeWifiAggressiveHandoverOptions();
} else if (preference == mWifiAllowScansWithTraffic) {
writeWifiAllowScansWithTrafficOptions();
+ } else if (preference == mLegacyDhcpClient) {
+ writeLegacyDhcpClientOptions();
} else if (preference == mUseAwesomePlayer) {
writeUseAwesomePlayerOptions();
} else if (preference == mUSBAudio) {
diff --git a/src/com/android/settings/FingerprintEnroll.java b/src/com/android/settings/FingerprintEnroll.java
index 376444e..931fb9c 100644
--- a/src/com/android/settings/FingerprintEnroll.java
+++ b/src/com/android/settings/FingerprintEnroll.java
@@ -24,16 +24,16 @@
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioAttributes;
import android.os.Bundle;
+import android.os.CancellationSignal;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.Vibrator;
import android.service.fingerprint.FingerprintManager;
-import android.service.fingerprint.FingerprintManagerReceiver;
+import android.service.fingerprint.FingerprintManager.EnrollmentCallback;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -82,12 +82,13 @@
}
public static class FingerprintEnrollFragment extends Fragment implements View.OnClickListener {
+ private static final String EXTRA_PROGRESS = "progress";
+ private static final String EXTRA_STAGE = "stage";
private static final int PROGRESS_BAR_MAX = 10000;
private static final String TAG = "FingerprintEnroll";
private static final boolean DEBUG = true;
private static final int CONFIRM_REQUEST = 101;
private static final int CHOOSE_LOCK_GENERIC_REQUEST = 102;
- private static final long ENROLL_TIMEOUT = 300*1000;
private static final int FINISH_DELAY = 250;
private PowerManager mPowerManager;
@@ -128,6 +129,7 @@
@Override
public void onAnimationCancel(Animator animation) { }
};
+ private CancellationSignal mEnrollmentCancel = new CancellationSignal();
// This contains a list of all views managed by the UI. Used to determine which views
// need to be shown/hidden at each stage. It should be the union of the lists that follow
@@ -240,13 +242,12 @@
case EnrollingFindSensor:
mEnrollmentSteps = -1;
mEnrolling = false;
- mFingerprintManager.stopListening();
break;
case EnrollingStart:
mEnrollmentSteps = -1;
- mFingerprintManager.startListening(mReceiver);
- mFingerprintManager.enroll(ENROLL_TIMEOUT);
+ long challenge = 0x12345; // TODO: get from keyguard confirmation
+ mFingerprintManager.enroll(challenge, mEnrollmentCallback, mEnrollmentCancel,0);
mProgressBar.setProgress(0);
mEnrolling = true;
startFingerprintAnimator(); // XXX hack - this should follow fingerprint detection
@@ -257,12 +258,10 @@
case EnrollingFinish:
stopFingerprintAnimator(); // XXX hack - this should follow fingerprint detection
- mFingerprintManager.stopListening();
mEnrolling = false;
break;
default:
- mFingerprintManager.stopListening();
break;
}
}
@@ -270,7 +269,7 @@
private void cancelEnrollment() {
if (mEnrolling) {
if (DEBUG) Log.v(TAG, "Cancel enrollment\n");
- mFingerprintManager.enrollCancel();
+ mEnrollmentCancel.cancel();
mEnrolling = false;
}
}
@@ -278,9 +277,7 @@
@Override
public void onDetach() {
super.onDetach();
- // Do a little cleanup
- cancelEnrollment();
- mFingerprintManager.stopListening();
+ cancelEnrollment(); // Do a little cleanup
}
private void updateProgress(int progress) {
@@ -300,6 +297,10 @@
mProgressAnim = anim;
}
+ protected void setMessage(CharSequence msg) {
+ if (msg != null) mMessageText.setText(msg);
+ }
+
private void setMessage(int id) {
if (id != 0) mMessageText.setText(id);
}
@@ -308,9 +309,11 @@
if (title != 0) mTitleText.setText(title);
}
- private FingerprintManagerReceiver mReceiver = new FingerprintManagerReceiver() {
- public void onEnrollResult(int fingerprintId, int remaining) {
- if (DEBUG) Log.v(TAG, "onEnrollResult(id=" + fingerprintId + ", rem=" + remaining);
+ private EnrollmentCallback mEnrollmentCallback = new EnrollmentCallback() {
+
+ @Override
+ public void onEnrollmentProgress(int remaining) {
+ if (DEBUG) Log.v(TAG, "onEnrollResult(id=" + ", rem=" + remaining);
if (mEnrollmentSteps == -1) {
mEnrollmentSteps = remaining;
updateStage(Stage.EnrollingRepeat);
@@ -325,62 +328,14 @@
}
}
- public void onError(int error) {
- switch(error) {
- case FingerprintManager.FINGERPRINT_ERROR_UNABLE_TO_PROCESS:
- setMessage(R.string.fingerprint_error_unable_to_process);
- break;
- case FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE:
- setMessage(R.string.fingerprint_error_hw_not_available);
- break;
- case FingerprintManager.FINGERPRINT_ERROR_NO_SPACE:
- setMessage(R.string.fingerprint_error_no_space);
- break;
- case FingerprintManager.FINGERPRINT_ERROR_TIMEOUT:
- setMessage(R.string.fingerprint_error_timeout);
- break;
- case FingerprintManager.FINGERPRINT_ERROR_NO_RECEIVER:
- Log.w(TAG, "Receiver not registered");
- break;
- }
- }
-
- public void onRemoved(int fingerprintId) {
- if (DEBUG) Log.v(TAG, "onRemoved(id=" + fingerprintId + ")");
+ @Override
+ public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
+ setMessage(helpString);
}
@Override
- public void onProcessed(int fingerprintId) {
- if (DEBUG) Log.v(TAG, "onProcessed(id=" + fingerprintId + ")");
- }
-
- public void onAcquired(int scanInfo) {
- int msgId = 0;
- startFingerprintAnimator();
- switch(scanInfo) {
- case FingerprintManager.FINGERPRINT_ACQUIRED_GOOD:
- break;
- case FingerprintManager.FINGERPRINT_ACQUIRED_IMAGER_DIRTY:
- msgId = R.string.fingerprint_acquired_imager_dirty;
- break;
- case FingerprintManager.FINGERPRINT_ACQUIRED_TOO_SLOW:
- msgId = R.string.fingerprint_acquired_too_fast;
- break;
- case FingerprintManager.FINGERPRINT_ACQUIRED_TOO_FAST:
- msgId = R.string.fingerprint_acquired_too_slow;
- break;
- case FingerprintManager.FINGERPRINT_ACQUIRED_PARTIAL:
- case FingerprintManager.FINGERPRINT_ACQUIRED_INSUFFICIENT:
- msgId = R.string.fingerprint_acquired_try_again;
- break;
- default:
- // Try not to be too verbose in the UI. The user just needs to try again.
- // Log the message so we can dig into the issue if necessary.
- Log.w(TAG, "Try again because scanInfo was " + scanInfo);
- msgId = R.string.fingerprint_acquired_try_again;
- break;
- }
- setMessage(msgId);
+ public void onEnrollmentError(int errMsgId, CharSequence errString) {
+ setMessage(errString);
}
};
@@ -432,6 +387,31 @@
}
@Override
+ public void onSaveInstanceState(final Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString(EXTRA_STAGE, mStage.toString());
+ if (mStage == Stage.EnrollingRepeat) {
+ outState.putInt(EXTRA_PROGRESS, mProgressBar.getProgress());
+ }
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ if (savedInstanceState != null) {
+ //probably orientation change
+ String stageSaved = savedInstanceState.getString(EXTRA_STAGE, null);
+ if (stageSaved != null) {
+ Stage stage = Stage.valueOf(stageSaved);
+ updateStage(stage);
+ if (stage == Stage.EnrollingRepeat) {
+ mProgressBar.setProgress(savedInstanceState.getInt(EXTRA_PROGRESS));
+ }
+ }
+ }
+ }
+
+ @Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.fingerprint_enroll_button_add:
diff --git a/src/com/android/settings/FingerprintSettings.java b/src/com/android/settings/FingerprintSettings.java
index dbc4db7..857ef1f 100644
--- a/src/com/android/settings/FingerprintSettings.java
+++ b/src/com/android/settings/FingerprintSettings.java
@@ -29,13 +29,16 @@
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
+import android.service.fingerprint.Fingerprint;
import android.service.fingerprint.FingerprintManager;
-import android.service.fingerprint.FingerprintManagerReceiver;
-import android.service.fingerprint.FingerprintManager.FingerprintItem;
+import android.service.fingerprint.FingerprintManager.AuthenticationCallback;
+import android.service.fingerprint.FingerprintManager.RemovalCallback;
+import android.service.fingerprint.FingerprintManager.AuthenticationResult;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
+import android.widget.Toast;
import com.android.settings.search.Indexable;
@@ -68,6 +71,7 @@
public static class FingerprintSettingsFragment extends SettingsPreferenceFragment
implements OnPreferenceChangeListener, Indexable {
+ private static final int MAX_RETRY_ATTEMPTS = 5;
private static final String TAG = "FingerprintSettings";
private static final String KEY_FINGERPRINT_ITEM_PREFIX = "key_fingerprint_item";
private static final String KEY_USAGE_CATEGORY = "fingerprint_usage_category";
@@ -82,10 +86,54 @@
private static final int ADD_FINGERPRINT_REQUEST = 10;
private static final boolean ENABLE_USAGE_CATEGORY = false;
+ protected static final boolean DEBUG = true;
private FingerprintManager mFingerprintManager;
private EditText mDialogTextField;
private PreferenceGroup mManageCategory;
+ private AuthenticationCallback mAuthCallback = new AuthenticationCallback() {
+ int mAttempts;
+ @Override
+ public void onAuthenticationSucceeded(AuthenticationResult result) {
+ mHandler.obtainMessage(MSG_HIGHLIGHT_FINGERPRINT_ITEM,
+ result.getFingerprint().getFingerId(), 0).sendToTarget();
+ retryFingerprint(true);
+ }
+
+ @Override
+ public void onAuthenticationError(int errMsgId, CharSequence errString) {
+ Toast.makeText(getActivity(), errString, Toast.LENGTH_SHORT);
+ retryFingerprint(false);
+ }
+
+ private void retryFingerprint(boolean resetAttempts) {
+ if (resetAttempts) {
+ mAttempts = 0;
+ }
+ if (mAttempts < MAX_RETRY_ATTEMPTS) {
+ mFingerprintManager.authenticate(null, mAuthCallback, null, 0);
+ }
+ mAttempts++;
+ }
+
+ @Override
+ public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
+ Toast.makeText(getActivity(), helpString, Toast.LENGTH_SHORT);
+ }
+ };
+ private RemovalCallback mRemoveCallback = new RemovalCallback() {
+
+ @Override
+ public void onRemovalSucceeded(Fingerprint fingerprint) {
+ mHandler.obtainMessage(MSG_REFRESH_FINGERPRINT_TEMPLATES,
+ fingerprint.getFingerId(), 0).sendToTarget();
+ }
+
+ @Override
+ public void onRemovalError(Fingerprint fp, int errMsgId, CharSequence errString) {
+ Toast.makeText(getActivity(), errString, Toast.LENGTH_SHORT);
+ }
+ };
private final Handler mHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
@@ -104,20 +152,7 @@
super.onCreate(savedInstanceState);
mFingerprintManager = (FingerprintManager) getActivity().getSystemService(
Context.FINGERPRINT_SERVICE);
- mFingerprintManager.startListening(new FingerprintManagerReceiver() {
- @Override
- public void onRemoved(int fingerprintId) {
- mHandler.obtainMessage(MSG_REFRESH_FINGERPRINT_TEMPLATES, fingerprintId, 0)
- .sendToTarget();
- }
- @Override
- public void onProcessed(int fingerprintId) {
- if (fingerprintId != 0) {
- mHandler.obtainMessage(MSG_HIGHLIGHT_FINGERPRINT_ITEM, fingerprintId, 0)
- .sendToTarget();
- }
- }
- });
+ mFingerprintManager.authenticate(null, mAuthCallback, null, 0);
}
protected void removeFingerprintPreference(int fingerprintId) {
@@ -181,15 +216,15 @@
private void addFingerprintItemPreferences(PreferenceGroup manageFingerprintCategory) {
manageFingerprintCategory.removeAll();
- List<FingerprintItem> items = mFingerprintManager.getEnrolledFingerprints();
+ final List<Fingerprint> items = mFingerprintManager.getEnrolledFingerprints();
final int fingerprintCount = items.size();
for (int i = 0; i < fingerprintCount; i++) {
- final FingerprintItem item = items.get(i);
+ final Fingerprint item = items.get(i);
FingerprintPreference pref = new FingerprintPreference(
manageFingerprintCategory.getContext());
- pref.setKey(genKey(item.id));
- pref.setTitle(item.name);
- pref.setFingerprintItem(item);
+ pref.setKey(genKey(item.getFingerId()));
+ pref.setTitle(item.getName());
+ pref.setFingerprint(item);
pref.setPersistent(false);
manageFingerprintCategory.addPreference(pref);
pref.setOnPreferenceChangeListener(this);
@@ -222,15 +257,14 @@
startActivityForResult(intent, ADD_FINGERPRINT_REQUEST);
} else if (pref instanceof FingerprintPreference) {
FingerprintPreference fpref = (FingerprintPreference) pref;
- final FingerprintItem item =fpref.getFingerprintItem();
- showRenameDeleteDialog(item.name, pref, item.id);
+ final Fingerprint fp =fpref.getFingerprint();
+ showRenameDeleteDialog(pref, fp);
return super.onPreferenceTreeClick(preferenceScreen, pref);
}
return true;
}
- private void showRenameDeleteDialog(final CharSequence name, Preference pref,
- final int fpId) {
+ private void showRenameDeleteDialog(Preference pref, final Fingerprint fp) {
final Activity activity = getActivity();
AlertDialog dialog = new AlertDialog.Builder(activity)
.setView(R.layout.fingerprint_rename_dialog)
@@ -238,10 +272,11 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- String newName = mDialogTextField.getText().toString();
+ final String newName = mDialogTextField.getText().toString();
+ final CharSequence name = fp.getName();
if (!newName.equals(name)) {
- Log.v(TAG, "Would rename " + name + " to " + newName);
- mFingerprintManager.rename(fpId, newName);
+ if (DEBUG) Log.v(TAG, "rename " + name + " to " + newName);
+ mFingerprintManager.rename(fp.getFingerId(), newName);
}
dialog.dismiss();
}
@@ -250,15 +285,15 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- Log.v(TAG, "Removing fpId " + fpId);
- mFingerprintManager.remove(fpId);
+ if (DEBUG) Log.v(TAG, "Removing fpId=" + fp.getFingerId());
+ mFingerprintManager.remove(fp, mRemoveCallback);
dialog.dismiss();
}
})
.create();
dialog.show();
mDialogTextField = (EditText) dialog.findViewById(R.id.fingerprint_rename_field);
- mDialogTextField.setText(name);
+ mDialogTextField.setText(fp.getName());
mDialogTextField.selectAll();
}
@@ -282,7 +317,7 @@
public static class FingerprintPreference extends Preference {
private static final int RESET_HIGHLIGHT_DELAY_MS = 500;
- private FingerprintItem mFingerprintItem;
+ private Fingerprint mFingerprint;
private View mView;
private Drawable mHighlightDrawable;
private Context mContext;
@@ -304,12 +339,12 @@
this(context, null);
}
- public void setFingerprintItem(FingerprintItem item) {
- mFingerprintItem = item;
+ public void setFingerprint(Fingerprint item) {
+ mFingerprint = item;
}
- public FingerprintItem getFingerprintItem() {
- return mFingerprintItem;
+ public Fingerprint getFingerprint() {
+ return mFingerprint;
}
private Drawable getHighlightDrawable() {
diff --git a/src/com/android/settings/ProfileSelectDialog.java b/src/com/android/settings/ProfileSelectDialog.java
new file mode 100644
index 0000000..99f962f
--- /dev/null
+++ b/src/com/android/settings/ProfileSelectDialog.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015 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 android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.app.FragmentManager;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
+
+import com.android.settings.dashboard.DashboardTile;
+
+public class ProfileSelectDialog extends DialogFragment implements OnClickListener {
+
+ private static final String ARG_SELECTED_TILE = "selectedTile";
+
+ private DashboardTile mSelectedTile;
+
+ public static void show(FragmentManager manager, DashboardTile tile) {
+ ProfileSelectDialog dialog = new ProfileSelectDialog();
+ Bundle args = new Bundle();
+ args.putParcelable(ARG_SELECTED_TILE, tile);
+ dialog.setArguments(args);
+ dialog.show(manager, "select_profile");
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mSelectedTile = getArguments().getParcelable(ARG_SELECTED_TILE);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ Context context = getActivity();
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ UserAdapter adapter = Utils.createUserAdapter(UserManager.get(context), context,
+ mSelectedTile.userHandle);
+ builder.setTitle(R.string.choose_profile)
+ .setAdapter(adapter, this);
+
+ return builder.create();
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ UserHandle user = mSelectedTile.userHandle.get(which);
+ getActivity().startActivityAsUser(mSelectedTile.intent, user);
+ }
+}
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index 28fd92d..a67d2e6 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -134,22 +134,20 @@
}
if (SubscriptionManager.isUsableSubIdValue(mSubId)) {
- int phoneId = SubscriptionManager.getPhoneId(mSubId);
- Phone phone = PhoneFactory.getPhone(phoneId);
-
// Turn mobile data on
- phone.setDataEnabled(true);
+ telephonyManager.setDataEnabled(mSubId, true);
// Set mobile network selection mode to automatic
- phone.setNetworkSelectionModeAutomatic(null);
+ // TODO set network selection mode to automatic
+ // phone.setNetworkSelectionModeAutomatic(null);
// Set preferred mobile network type to manufacturer's recommended
// int networkType = ; // TODO get manufacturer's default
- // phone.setPreferredNetworkType(networkType, null);
+ // telephonyManager.setPreferredNetworkType(networkType);
// Turn roaming to manufacturer's default
// boolean enabled = ; // TODO get manufacturer's default
- // phone.setDataRoamingEnabled(enabled);
+ // SubscriptionManager.from(getContext()).setDataRoaming(enabled, mSubId);
String subscriberId = telephonyManager.getSubscriberId(mSubId);
NetworkTemplate template = NetworkTemplate.buildTemplateMobileAll(subscriberId);
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 1f6d50a..4ca2140 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -40,8 +40,8 @@
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.security.KeyStore;
+import android.service.fingerprint.Fingerprint;
import android.service.fingerprint.FingerprintManager;
-import android.service.fingerprint.FingerprintManager.FingerprintItem;
import android.service.trust.TrustAgentService;
import android.telephony.TelephonyManager;
import android.telephony.SubscriptionManager;
@@ -341,8 +341,8 @@
fingerprintPreference.setKey(KEY_FINGERPRINT_SETTINGS);
fingerprintPreference.setTitle(R.string.security_settings_fingerprint_preference_title);
Intent intent = new Intent();
- List<FingerprintItem> items = fpm.getEnrolledFingerprints();
- int fingerprintCount = items.size();
+ final List<Fingerprint> items = fpm.getEnrolledFingerprints();
+ final int fingerprintCount = items != null ? items.size() : 0;
final String clazz;
if (fingerprintCount > 0) {
fingerprintPreference.setSummary(getResources().getQuantityString(
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 0f0c897..eecf7a2 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -16,6 +16,8 @@
package com.android.settings;
+import static com.android.settings.dashboard.DashboardTile.TILE_ID_UNDEFINED;
+
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
@@ -49,8 +51,10 @@
import android.preference.PreferenceScreen;
import android.text.TextUtils;
import android.transition.TransitionManager;
+import android.util.ArrayMap;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.Pair;
import android.util.TypedValue;
import android.util.Xml;
import android.view.Menu;
@@ -81,9 +85,6 @@
import com.android.settings.deviceinfo.UsbSettings;
import com.android.settings.fuelgauge.BatterySaverSettings;
import com.android.settings.fuelgauge.PowerUsageSummary;
-import com.android.settings.notification.OtherSoundSettings;
-import com.android.settings.search.DynamicIndexableContentMonitor;
-import com.android.settings.search.Index;
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
import com.android.settings.inputmethod.SpellCheckersSettings;
@@ -96,9 +97,12 @@
import com.android.settings.notification.NotificationAccessSettings;
import com.android.settings.notification.NotificationSettings;
import com.android.settings.notification.NotificationStation;
+import com.android.settings.notification.OtherSoundSettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.print.PrintJobSettingsFragment;
import com.android.settings.print.PrintSettingsFragment;
+import com.android.settings.search.DynamicIndexableContentMonitor;
+import com.android.settings.search.Index;
import com.android.settings.sim.SimSettings;
import com.android.settings.tts.TextToSpeechSettings;
import com.android.settings.users.UserSettings;
@@ -110,16 +114,16 @@
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiSettings;
import com.android.settings.wifi.p2p.WifiP2pSettings;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
-import static com.android.settings.dashboard.DashboardTile.TILE_ID_UNDEFINED;
-
public class SettingsActivity extends Activity
implements PreferenceManager.OnPreferenceTreeClickListener,
PreferenceFragment.OnPreferenceStartFragmentCallback,
@@ -201,6 +205,35 @@
private static final String EMPTY_QUERY = "";
+ /**
+ * Settings will search for system activities of this action and add them as a top level
+ * settings tile using the following parameters.
+ *
+ * <p>A category must be specified in the meta-data for the activity named
+ * {@link #EXTRA_CATEGORY_KEY}
+ *
+ * <p>The title may be defined by meta-data named {@link Utils#META_DATA_PREFERENCE_TITLE}
+ * otherwise the label for the activity will be used.
+ *
+ * <p>The icon may be defined by meta-data named {@link Utils#META_DATA_PREFERENCE_ICON}
+ * otherwise the icon for the activity will be used.
+ *
+ * <p>A summary my be defined by meta-data named {@link Utils#META_DATA_PREFERENCE_SUMMARY}
+ */
+ private static final String EXTRA_SETTINGS_ACTION =
+ "com.android.settings.action.EXTRA_SETTINGS";
+
+ /**
+ * The key used to get the category from metadata of activities of action
+ * {@link #EXTRA_SETTINGS_ACTION}
+ * The value must be one of:
+ * <li>com.android.settings.category.wireless</li>
+ * <li>com.android.settings.category.device</li>
+ * <li>com.android.settings.category.personal</li>
+ * <li>com.android.settings.category.system</li>
+ */
+ private static final String EXTRA_CATEGORY_KEY = "com.android.settings.category";
+
private static boolean sShowNoHomeNotice = false;
private String mFragmentClass;
@@ -1035,6 +1068,17 @@
}
}
sa.recycle();
+ sa = obtainStyledAttributes(attrs, com.android.internal.R.styleable.Preference);
+ tv = sa.peekValue(
+ com.android.internal.R.styleable.Preference_key);
+ if (tv != null && tv.type == TypedValue.TYPE_STRING) {
+ if (tv.resourceId != 0) {
+ category.key = getString(tv.resourceId);
+ } else {
+ category.key = tv.string.toString();
+ }
+ }
+ sa.recycle();
final int innerDepth = parser.getDepth();
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
@@ -1110,6 +1154,8 @@
category.addTile(tile);
}
+ } else if (innerNodeName.equals("external-tiles")) {
+ category.externalIndex = category.getTilesCount();
} else {
XmlUtils.skipCurrentTag(parser);
}
@@ -1231,6 +1277,73 @@
n--;
}
}
+ addExternalTiles(target);
+ }
+
+ private void addExternalTiles(List<DashboardCategory> target) {
+ Map<Pair<String, String>, DashboardTile> addedCache =
+ new ArrayMap<Pair<String, String>, DashboardTile>();
+ UserManager userManager = UserManager.get(this);
+ for (UserHandle user : userManager.getUserProfiles()) {
+ addExternalTiles(target, user, addedCache);
+ }
+ }
+
+ private void addExternalTiles(List<DashboardCategory> target, UserHandle user,
+ Map<Pair<String, String>, DashboardTile> addedCache) {
+ PackageManager pm = getPackageManager();
+ Intent intent = new Intent(EXTRA_SETTINGS_ACTION);
+ List<ResolveInfo> results = pm.queryIntentActivitiesAsUser(intent,
+ PackageManager.GET_META_DATA, user.getIdentifier());
+ for (ResolveInfo resolved : results) {
+ if (!resolved.system) {
+ // Do not allow any app to add to settings, only system ones.
+ continue;
+ }
+ ActivityInfo activityInfo = resolved.activityInfo;
+ Bundle metaData = activityInfo.metaData;
+ if ((metaData == null) || !metaData.containsKey(EXTRA_CATEGORY_KEY)) {
+ Log.w(LOG_TAG, "Found " + resolved.activityInfo.name + " for action "
+ + EXTRA_SETTINGS_ACTION + " missing metadata " +
+ (metaData == null ? "" : EXTRA_CATEGORY_KEY));
+ continue;
+ }
+ String categoryKey = metaData.getString(EXTRA_CATEGORY_KEY);
+ DashboardCategory category = getCategory(target, categoryKey);
+ if (category == null) {
+ Log.w(LOG_TAG, "Activity " + resolved.activityInfo.name + " has unknown "
+ + "category key " + categoryKey);
+ continue;
+ }
+ Pair<String, String> key = new Pair<String, String>(activityInfo.packageName,
+ activityInfo.name);
+ DashboardTile tile = addedCache.get(key);
+ if (tile == null) {
+ tile = new DashboardTile();
+ tile.intent = new Intent().setClassName(
+ activityInfo.packageName, activityInfo.name);
+ Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, tile);
+
+ if (category.externalIndex == -1) {
+ // If no location for external tiles has been specified for this category,
+ // then just put them at the end.
+ category.addTile(tile);
+ } else {
+ category.addTile(category.externalIndex, tile);
+ }
+ addedCache.put(key, tile);
+ }
+ tile.userHandle.add(user);
+ }
+ }
+
+ private DashboardCategory getCategory(List<DashboardCategory> target, String categoryKey) {
+ for (DashboardCategory category : target) {
+ if (categoryKey.equals(category.key)) {
+ return category;
+ }
+ }
+ return null;
}
private boolean updateHomeSettingTiles(DashboardTile tile) {
diff --git a/src/com/android/settings/UserSpinnerAdapter.java b/src/com/android/settings/UserAdapter.java
similarity index 86%
rename from src/com/android/settings/UserSpinnerAdapter.java
rename to src/com/android/settings/UserAdapter.java
index e40a374..dcdc7eb 100644
--- a/src/com/android/settings/UserSpinnerAdapter.java
+++ b/src/com/android/settings/UserAdapter.java
@@ -16,6 +16,7 @@
package com.android.settings;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.UserInfo;
import android.database.DataSetObserver;
@@ -27,6 +28,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.ListAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
@@ -38,7 +40,7 @@
/**
* Adapter for a spinner that shows a list of users.
*/
-public class UserSpinnerAdapter implements SpinnerAdapter {
+public class UserAdapter implements SpinnerAdapter, ListAdapter {
// TODO: Update UI. See: http://b/16518801
/** Holder for user details */
public static class UserDetails {
@@ -73,7 +75,7 @@
private ArrayList<UserDetails> data;
private final LayoutInflater mInflater;
- public UserSpinnerAdapter(Context context, ArrayList<UserDetails> users) {
+ public UserAdapter(Context context, ArrayList<UserDetails> users) {
if (users == null) {
throw new IllegalArgumentException("A list of user details must be provided");
}
@@ -94,10 +96,20 @@
UserDetails user = data.get(position);
((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(user.mIcon);
- ((TextView) row.findViewById(android.R.id.title)).setText(user.mName);
+ ((TextView) row.findViewById(android.R.id.title)).setText(getTitle(user));
return row;
}
+ private int getTitle(UserDetails user) {
+ int userHandle = user.mUserHandle.getIdentifier();
+ if (userHandle == UserHandle.USER_CURRENT
+ || userHandle == ActivityManager.getCurrentUser()) {
+ return R.string.category_personal;
+ } else {
+ return R.string.category_work;
+ }
+ }
+
private View createUser(ViewGroup parent) {
return mInflater.inflate(R.layout.user_preference, parent, false);
}
@@ -151,4 +163,14 @@
public boolean isEmpty() {
return data.isEmpty();
}
+
+ @Override
+ public boolean areAllItemsEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 16037c5..bc6cbed 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -75,7 +75,7 @@
import android.widget.TabWidget;
import com.android.internal.util.UserIcons;
-import com.android.settings.UserSpinnerAdapter.UserDetails;
+import com.android.settings.UserAdapter.UserDetails;
import com.android.settings.dashboard.DashboardTile;
import com.android.settings.drawable.CircleFramedDrawable;
@@ -114,19 +114,19 @@
* Name of the meta-data item that should be set in the AndroidManifest.xml
* to specify the icon that should be displayed for the preference.
*/
- private static final String META_DATA_PREFERENCE_ICON = "com.android.settings.icon";
+ public static final String META_DATA_PREFERENCE_ICON = "com.android.settings.icon";
/**
* Name of the meta-data item that should be set in the AndroidManifest.xml
* to specify the title that should be displayed for the preference.
*/
- private static final String META_DATA_PREFERENCE_TITLE = "com.android.settings.title";
+ public static final String META_DATA_PREFERENCE_TITLE = "com.android.settings.title";
/**
* Name of the meta-data item that should be set in the AndroidManifest.xml
* to specify the summary text that should be displayed for the preference.
*/
- private static final String META_DATA_PREFERENCE_SUMMARY = "com.android.settings.summary";
+ public static final String META_DATA_PREFERENCE_SUMMARY = "com.android.settings.summary";
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
@@ -198,14 +198,17 @@
if (intent != null) {
// Find the activity that is in the system image
PackageManager pm = context.getPackageManager();
- List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
+ List<ResolveInfo> list = tile.userHandle.size() != 0
+ ? pm.queryIntentActivitiesAsUser(intent, PackageManager.GET_META_DATA,
+ tile.userHandle.get(0).getIdentifier())
+ : pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
int listSize = list.size();
for (int i = 0; i < listSize; i++) {
ResolveInfo resolveInfo = list.get(i);
if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
!= 0) {
- Drawable icon = null;
- String title = null;
+ int icon = 0;
+ CharSequence title = null;
String summary = null;
// Get the activity's meta-data
@@ -215,14 +218,18 @@
Bundle metaData = resolveInfo.activityInfo.metaData;
if (res != null && metaData != null) {
- icon = res.getDrawable(
- metaData.getInt(META_DATA_PREFERENCE_ICON), null);
- title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
- summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
+ if (metaData.containsKey(META_DATA_PREFERENCE_ICON)) {
+ icon = metaData.getInt(META_DATA_PREFERENCE_ICON);
+ }
+ if (metaData.containsKey(META_DATA_PREFERENCE_TITLE)) {
+ title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
+ }
+ if (metaData.containsKey(META_DATA_PREFERENCE_SUMMARY)) {
+ summary = res.getString(
+ metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
+ }
}
- } catch (NameNotFoundException e) {
- // Ignore
- } catch (NotFoundException e) {
+ } catch (NameNotFoundException | NotFoundException e) {
// Ignore
}
@@ -231,10 +238,13 @@
if (TextUtils.isEmpty(title)) {
title = resolveInfo.loadLabel(pm).toString();
}
+ if (icon == 0) {
+ icon = resolveInfo.activityInfo.icon;
+ }
// Set icon, title and summary for the preference
- // TODO:
- //tile.icon = icon;
+ tile.iconRes = icon;
+ tile.iconPkg = resolveInfo.activityInfo.packageName;
tile.title = title;
tile.summary = summary;
// Replace the intent with this specific activity
@@ -728,14 +738,14 @@
}
/**
- * Creates a {@link UserSpinnerAdapter} if there is more than one profile on the device.
+ * Creates a {@link UserAdapter} if there is more than one profile on the device.
*
* <p> The adapter can be used to populate a spinner that switches between the Settings
* app on the different profiles.
*
- * @return a {@link UserSpinnerAdapter} or null if there is only one profile.
+ * @return a {@link UserAdapter} or null if there is only one profile.
*/
- public static UserSpinnerAdapter createUserSpinnerAdapter(UserManager userManager,
+ public static UserAdapter createUserSpinnerAdapter(UserManager userManager,
Context context) {
List<UserHandle> userProfiles = userManager.getUserProfiles();
if (userProfiles.size() < 2) {
@@ -747,12 +757,17 @@
userProfiles.remove(myUserHandle);
userProfiles.add(0, myUserHandle);
+ return createUserAdapter(userManager, context, userProfiles);
+ }
+
+ public static UserAdapter createUserAdapter(UserManager userManager,
+ Context context, List<UserHandle> userProfiles) {
ArrayList<UserDetails> userDetails = new ArrayList<UserDetails>(userProfiles.size());
final int count = userProfiles.size();
for (int i = 0; i < count; i++) {
userDetails.add(new UserDetails(userProfiles.get(i), userManager, context));
}
- return new UserSpinnerAdapter(context, userDetails);
+ return new UserAdapter(context, userDetails);
}
/**
diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/WifiCallingSettings.java
index dacdc7b..8e2c7ed 100644
--- a/src/com/android/settings/WifiCallingSettings.java
+++ b/src/com/android/settings/WifiCallingSettings.java
@@ -25,7 +25,6 @@
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
-import android.preference.SwitchPreference;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -38,8 +37,7 @@
/**
* "Wi-Fi Calling settings" screen. This preference screen lets you
- * enable/disable Wi-Fi Calling, change mode, enable/disable
- * handover while on roaming.
+ * enable/disable Wi-Fi Calling and change Wi-Fi Calling mode.
*/
public class WifiCallingSettings extends SettingsPreferenceFragment
implements SwitchBar.OnSwitchChangeListener,
@@ -49,13 +47,11 @@
//String keys for preference lookup
private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
- private static final String BUTTON_WFC_ROAM = "wifi_calling_roam";
//UI objects
private SwitchBar mSwitchBar;
private Switch mSwitch;
private ListPreference mButtonWfcMode;
- private SwitchPreference mButtonWfcRoam;
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
/*
@@ -77,18 +73,9 @@
&& isNonTtyOrTtyOnVolteEnabled);
Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE);
- int wfcMode = ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY;
if (pref != null) {
pref.setEnabled(isWfcEnabled
&& (state == TelephonyManager.CALL_STATE_IDLE));
- ListPreference prefWfcMode = (ListPreference) pref;
- wfcMode = Integer.valueOf(prefWfcMode.getValue()).intValue();
- }
- pref = getPreferenceScreen().findPreference(BUTTON_WFC_ROAM);
- if (pref != null) {
- pref.setEnabled(isWfcEnabled
- && (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY)
- && (state == TelephonyManager.CALL_STATE_IDLE));
}
}
};
@@ -131,7 +118,7 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action.equals(ImsPhone.REGISTRATION_ERROR)) {
+ if (action.equals(ImsManager.ACTION_IMS_REGISTRATION_ERROR)) {
// If this fragment is active then we are immediately
// showing alert on screen. There is no need to add
// notification in this case.
@@ -140,6 +127,9 @@
// not show notification, we are changing result code here.
setResultCode(Activity.RESULT_CANCELED);
+ // UX requirement is to disable WFC in case of "permanent" registration failures.
+ mSwitch.setChecked(false);
+
showAlert(intent);
}
}
@@ -154,11 +144,8 @@
mButtonWfcMode = (ListPreference) findPreference(BUTTON_WFC_MODE);
mButtonWfcMode.setOnPreferenceChangeListener(this);
- mButtonWfcRoam = (SwitchPreference) findPreference(BUTTON_WFC_ROAM);
- mButtonWfcRoam.setOnPreferenceChangeListener(this);
-
mIntentFilter = new IntentFilter();
- mIntentFilter.addAction(ImsPhone.REGISTRATION_ERROR);
+ mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR);
}
@Override
@@ -183,10 +170,6 @@
mButtonWfcMode.setValue(Integer.toString(wfcMode));
mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode));
- mButtonWfcRoam.setChecked(wfcEnabled
- && (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY)
- && ImsManager.isWfcRoamingEnabledByUser(context));
-
context.registerReceiver(mIntentReceiver, mIntentFilter);
Intent intent = getActivity().getIntent();
@@ -223,10 +206,6 @@
int wfcMode = ImsManager.getWfcMode(context);
mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode));
mButtonWfcMode.setEnabled(isChecked);
- boolean wfcHandoffEnabled = (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY);
- mButtonWfcRoam.setEnabled(isChecked && wfcHandoffEnabled);
- mButtonWfcRoam.setChecked(isChecked && wfcHandoffEnabled
- && ImsManager.isWfcRoamingEnabledByUser(context));
}
@Override
@@ -240,15 +219,6 @@
ImsManager.setWfcMode(context, buttonMode);
mButtonWfcMode.setSummary(getWfcModeSummary(context, buttonMode));
}
- boolean wfcHandoffEnabled =
- (buttonMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY);
- mButtonWfcRoam.setEnabled(wfcHandoffEnabled);
- mButtonWfcRoam.setChecked(wfcHandoffEnabled &&
- ImsManager.isWfcRoamingEnabledByUser(context));
- } else if (preference == mButtonWfcRoam) {
- SwitchPreference wfcRoamPref = (SwitchPreference) preference;
- wfcRoamPref.setChecked(!wfcRoamPref.isChecked());
- ImsManager.setWfcRoamingSetting(context, wfcRoamPref.isChecked());
}
return true;
}
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index b71262e..d33acd9 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -431,7 +431,7 @@
mMyUserId = UserHandle.myUserId();
}
- public void doCreate(Bundle savedInstanceState) {
+ public void doCreate() {
mAm = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE);
mState = RunningState.getInstance(getContext());
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(
diff --git a/src/com/android/settings/applications/RunningServices.java b/src/com/android/settings/applications/RunningServices.java
new file mode 100644
index 0000000..a4cd4a7
--- /dev/null
+++ b/src/com/android/settings/applications/RunningServices.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2015 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.applications;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.AnimationUtils;
+
+import com.android.settings.R;
+
+public class RunningServices extends Fragment {
+
+ private static final int SHOW_RUNNING_SERVICES = 1;
+ private static final int SHOW_BACKGROUND_PROCESSES = 2;
+
+ private RunningProcessesView mRunningProcessesView;
+ private Menu mOptionsMenu;
+ private View mLoadingContainer;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.manage_applications_running, null);
+ mRunningProcessesView = (RunningProcessesView) rootView.findViewById(
+ R.id.running_processes);
+ mRunningProcessesView.doCreate();
+ mLoadingContainer = rootView.findViewById(R.id.loading_container);
+
+ return rootView;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ mOptionsMenu = menu;
+ menu.add(0, SHOW_RUNNING_SERVICES, 1, R.string.show_running_services)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, SHOW_BACKGROUND_PROCESSES, 2, R.string.show_background_processes)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ updateOptionsMenu();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ boolean haveData = mRunningProcessesView.doResume(this, mRunningProcessesAvail);
+ if (haveData) {
+ mRunningProcessesView.setVisibility(View.VISIBLE);
+ mLoadingContainer.setVisibility(View.INVISIBLE);
+ } else {
+ mLoadingContainer.setVisibility(View.VISIBLE);
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mRunningProcessesView.doPause();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case SHOW_RUNNING_SERVICES:
+ mRunningProcessesView.mAdapter.setShowBackground(false);
+ break;
+ case SHOW_BACKGROUND_PROCESSES:
+ mRunningProcessesView.mAdapter.setShowBackground(true);
+ break;
+ default:
+ return false;
+ }
+ updateOptionsMenu();
+ return true;
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ updateOptionsMenu();
+ }
+
+ private void updateOptionsMenu() {
+ boolean showingBackground = mRunningProcessesView.mAdapter.getShowBackground();
+ mOptionsMenu.findItem(SHOW_RUNNING_SERVICES).setVisible(showingBackground);
+ mOptionsMenu.findItem(SHOW_BACKGROUND_PROCESSES).setVisible(!showingBackground);
+ }
+
+ private void handleRunningProcessesAvail() {
+ mLoadingContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(),
+ android.R.anim.fade_out));
+ mRunningProcessesView.startAnimation(AnimationUtils.loadAnimation(getActivity(),
+ android.R.anim.fade_in));
+ mRunningProcessesView.setVisibility(View.VISIBLE);
+ mLoadingContainer.setVisibility(View.GONE);
+ }
+
+ private final Runnable mRunningProcessesAvail = new Runnable() {
+ @Override
+ public void run() {
+ handleRunningProcessesAvail();
+ }
+ };
+
+}
diff --git a/src/com/android/settings/dashboard/DashboardCategory.java b/src/com/android/settings/dashboard/DashboardCategory.java
index fedbf0a..69d0316 100644
--- a/src/com/android/settings/dashboard/DashboardCategory.java
+++ b/src/com/android/settings/dashboard/DashboardCategory.java
@@ -52,6 +52,16 @@
public CharSequence title;
/**
+ * Key used for placing external tiles.
+ */
+ public String key;
+
+ /**
+ * Optional index of where to place tiles specified by system apps.
+ */
+ public int externalIndex = -1;
+
+ /**
* List of the category's children
*/
public List<DashboardTile> tiles = new ArrayList<DashboardTile>();
@@ -105,7 +115,9 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(titleRes);
+ dest.writeInt(externalIndex);
TextUtils.writeToParcel(title, dest, flags);
+ dest.writeString(key);
final int count = tiles.size();
dest.writeInt(count);
@@ -118,7 +130,9 @@
public void readFromParcel(Parcel in) {
titleRes = in.readInt();
+ externalIndex = in.readInt();
title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ key = in.readString();
final int count = in.readInt();
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index cf398d7..8a92860 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
@@ -32,6 +33,7 @@
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+
import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -148,7 +150,15 @@
private void updateTileView(Context context, Resources res, DashboardTile tile,
ImageView tileIcon, TextView tileTextView, TextView statusTextView) {
- if (tile.iconRes > 0) {
+ if (!TextUtils.isEmpty(tile.iconPkg)) {
+ try {
+ tileIcon.setImageDrawable(context.getPackageManager()
+ .getResourcesForApplication(tile.iconPkg).getDrawable(tile.iconRes, null));
+ } catch (NameNotFoundException | Resources.NotFoundException e) {
+ tileIcon.setImageDrawable(null);
+ tileIcon.setBackground(null);
+ }
+ } else if (tile.iconRes > 0) {
tileIcon.setImageResource(tile.iconRes);
} else {
tileIcon.setImageDrawable(null);
diff --git a/src/com/android/settings/dashboard/DashboardTile.java b/src/com/android/settings/dashboard/DashboardTile.java
index 1f1d9c2..94833d3 100644
--- a/src/com/android/settings/dashboard/DashboardTile.java
+++ b/src/com/android/settings/dashboard/DashboardTile.java
@@ -21,8 +21,11 @@
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.UserHandle;
import android.text.TextUtils;
+import java.util.ArrayList;
+
/**
* Description of a single dashboard tile that the user can select.
*/
@@ -73,6 +76,11 @@
public int iconRes;
/**
+ * Optional package to pull the icon resource from.
+ */
+ public String iconPkg;
+
+ /**
* Full class name of the fragment to display when this tile is
* selected.
* @attr ref android.R.styleable#PreferenceHeader_fragment
@@ -91,6 +99,11 @@
public Intent intent;
/**
+ * Optional list of user handles which the intent should be launched on.
+ */
+ public ArrayList<UserHandle> userHandle = new ArrayList<>();
+
+ /**
* Optional additional data for use by subclasses of the activity
*/
public Bundle extras;
@@ -136,6 +149,7 @@
dest.writeInt(summaryRes);
TextUtils.writeToParcel(summary, dest, flags);
dest.writeInt(iconRes);
+ dest.writeString(iconPkg);
dest.writeString(fragment);
dest.writeBundle(fragmentArguments);
if (intent != null) {
@@ -144,6 +158,11 @@
} else {
dest.writeInt(0);
}
+ final int N = userHandle.size();
+ dest.writeInt(N);
+ for (int i = 0; i < N; i++) {
+ dest.writeParcelable(userHandle.get(i), flags);
+ }
dest.writeBundle(extras);
}
@@ -154,11 +173,16 @@
summaryRes = in.readInt();
summary = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
iconRes = in.readInt();
+ iconPkg = in.readString();
fragment = in.readString();
fragmentArguments = in.readBundle();
if (in.readInt() != 0) {
intent = Intent.CREATOR.createFromParcel(in);
}
+ final int N = in.readInt();
+ for (int i = 0; i < N; i++) {
+ userHandle.add(UserHandle.CREATOR.createFromParcel(in));
+ }
extras = in.readBundle();
}
diff --git a/src/com/android/settings/dashboard/DashboardTileView.java b/src/com/android/settings/dashboard/DashboardTileView.java
index a54217b..0896b82 100644
--- a/src/com/android/settings/dashboard/DashboardTileView.java
+++ b/src/com/android/settings/dashboard/DashboardTileView.java
@@ -16,14 +16,16 @@
package com.android.settings.dashboard;
+import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
-
import android.widget.ImageView;
import android.widget.TextView;
+
+import com.android.settings.ProfileSelectDialog;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -93,7 +95,14 @@
Utils.startWithFragment(getContext(), mTile.fragment, mTile.fragmentArguments, null, 0,
mTile.titleRes, mTile.getTitle(getResources()));
} else if (mTile.intent != null) {
- getContext().startActivity(mTile.intent);
+ int numUserHandles = mTile.userHandle.size();
+ if (numUserHandles > 1) {
+ ProfileSelectDialog.show(((Activity) getContext()).getFragmentManager(), mTile);
+ } else if (numUserHandles == 1) {
+ getContext().startActivityAsUser(mTile.intent, mTile.userHandle.get(0));
+ } else {
+ getContext().startActivity(mTile.intent);
+ }
}
}
}
diff --git a/src/com/android/settings/print/PrintSettingsFragment.java b/src/com/android/settings/print/PrintSettingsFragment.java
index 3e989e4..7317d79 100644
--- a/src/com/android/settings/print/PrintSettingsFragment.java
+++ b/src/com/android/settings/print/PrintSettingsFragment.java
@@ -52,13 +52,15 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.Spinner;
import android.widget.TextView;
import com.android.internal.content.PackageMonitor;
-import com.android.settings.UserSpinnerAdapter;
import com.android.settings.DialogCreatable;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.UserAdapter;
import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
@@ -68,9 +70,6 @@
import java.util.ArrayList;
import java.util.List;
-import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.Spinner;
-
/**
* Fragment with the top level print settings.
*/
@@ -120,7 +119,7 @@
private PreferenceCategory mPrintServicesCategory;
private PrintJobsController mPrintJobsController;
- private UserSpinnerAdapter mProfileSpinnerAdapter;
+ private UserAdapter mProfileSpinnerAdapter;
private Spinner mSpinner;
@Override
diff --git a/src/com/android/settings/sim/SimBootReceiver.java b/src/com/android/settings/sim/SimBootReceiver.java
index 2fe833b..1e802f0 100644
--- a/src/com/android/settings/sim/SimBootReceiver.java
+++ b/src/com/android/settings/sim/SimBootReceiver.java
@@ -24,8 +24,6 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
@@ -40,13 +38,8 @@
public class SimBootReceiver extends BroadcastReceiver {
private static final String TAG = "SimBootReceiver";
- private static final int SLOT_EMPTY = -1;
private static final int NOTIFICATION_ID = 1;
- private static final String SHARED_PREFERENCES_NAME = "sim_state";
- private static final String SLOT_PREFIX = "sim_slot_";
- private static final int INVALID_SLOT = -2; // Used when upgrading from K to LMR1
- private SharedPreferences mSharedPreferences = null;
private TelephonyManager mTelephonyManager;
private Context mContext;
private SubscriptionManager mSubscriptionManager;
@@ -56,9 +49,6 @@
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
mContext = context;
mSubscriptionManager = SubscriptionManager.from(mContext);
- mSharedPreferences = mContext.getSharedPreferences(SHARED_PREFERENCES_NAME,
- Context.MODE_PRIVATE);
-
mSubscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionListener);
}
@@ -75,6 +65,22 @@
return;
}
+ // Cancel any previous notifications
+ cancelNotification(mContext);
+
+ // Clear defaults for any subscriptions which no longer exist
+ mSubscriptionManager.clearDefaultsForInactiveSubIds();
+
+ boolean dataSelected = SubscriptionManager.isUsableSubIdValue(
+ SubscriptionManager.getDefaultDataSubId());
+ boolean smsSelected = SubscriptionManager.isUsableSubIdValue(
+ SubscriptionManager.getDefaultSmsSubId());
+
+ // If data and sms defaults are selected, dont show notification (Calls default is optional)
+ if (dataSelected && smsSelected) {
+ return;
+ }
+
// We wait until SubscriptionManager returns a valid list of Subscription informations
// by checking if the list is empty.
// This is not completely correct, but works for most cases.
@@ -82,57 +88,34 @@
List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
if (sil == null || sil.size() < 1) {
return;
- }
+ } else {
+ // Create a notification to tell the user that some defaults are missing
+ createNotification(mContext);
- for (int i = 0; i < numSlots; i++) {
- final SubscriptionInfo sir = Utils.findRecordBySlotId(mContext, i);
- final String key = SLOT_PREFIX+i;
- final int lastSubId = getLastSubId(key);
-
- if (sir != null) {
- numSIMsDetected++;
- final int currentSubId = sir.getSubscriptionId();
- if (lastSubId == INVALID_SLOT) {
- setLastSubId(key, currentSubId);
- } else if (lastSubId != currentSubId) {
- createNotification(mContext);
- setLastSubId(key, currentSubId);
- notificationSent = true;
- }
- lastSIMSlotDetected = i;
- } else if (lastSubId != SLOT_EMPTY) {
- createNotification(mContext);
- setLastSubId(key, SLOT_EMPTY);
- notificationSent = true;
- }
- }
-
- if (notificationSent) {
- Intent intent = new Intent(mContext, SimDialogActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- if (numSIMsDetected == 1) {
+ if (sil.size() == 1) {
+ // If there is only one subscription, ask if user wants to use if for everything
+ Intent intent = new Intent(mContext, SimDialogActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.PREFERRED_PICK);
- intent.putExtra(SimDialogActivity.PREFERRED_SIM, lastSIMSlotDetected);
- } else {
+ intent.putExtra(SimDialogActivity.PREFERRED_SIM, sil.get(0).getSimSlotIndex());
+ mContext.startActivity(intent);
+ } else if (!dataSelected) {
+ // TODO(sanketpadawe): This should not be shown if the user is looking at the
+ // SimSettings page - its just annoying
+ // If there are mulitple, ensure they pick default data
+ Intent intent = new Intent(mContext, SimDialogActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.DATA_PICK);
+ mContext.startActivity(intent);
}
- mContext.startActivity(intent);
}
- }
- private int getLastSubId(String strSlotId) {
- return mSharedPreferences.getInt(strSlotId, INVALID_SLOT);
- }
-
- private void setLastSubId(String strSlotId, int value) {
- Editor editor = mSharedPreferences.edit();
- editor.putInt(strSlotId, value);
- editor.commit();
}
private void createNotification(Context context){
final Resources resources = context.getResources();
+ // TODO(sanketpadawe): This notification should not be dissmissable by the user
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
diff --git a/src/com/android/settings/wifi/WifiApDialog.java b/src/com/android/settings/wifi/WifiApDialog.java
index eee3db9..3c4d912 100644
--- a/src/com/android/settings/wifi/WifiApDialog.java
+++ b/src/com/android/settings/wifi/WifiApDialog.java
@@ -184,6 +184,15 @@
validate();
}
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ mPassword.setInputType(
+ InputType.TYPE_CLASS_TEXT |
+ (((CheckBox) mView.findViewById(R.id.show_password)).isChecked() ?
+ InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
+ InputType.TYPE_TEXT_VARIATION_PASSWORD));
+ }
+
private void validate() {
if ((mSsid != null && mSsid.length() == 0) ||
((mSecurityTypeIndex == WPA2_INDEX)&&
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index e244b7f..cc8481d 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -971,14 +971,12 @@
/**
* Make the characters of the password visible if show_password is checked.
*/
- private void updatePasswordVisibility(boolean checked) {
- int pos = mPasswordView.getSelectionEnd();
- mPasswordView.setInputType(
- InputType.TYPE_CLASS_TEXT | (checked ?
- InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
- InputType.TYPE_TEXT_VARIATION_PASSWORD));
- if (pos >= 0) {
- ((EditText)mPasswordView).setSelection(pos);
- }
+ public void updatePassword() {
+ TextView passwdView = (TextView) mView.findViewById(R.id.password);
+ passwdView.setInputType(
+ InputType.TYPE_CLASS_TEXT |
+ (((CheckBox) mView.findViewById(R.id.show_password)).isChecked() ?
+ InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
+ InputType.TYPE_TEXT_VARIATION_PASSWORD));
}
}
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index 1f03fe3..1e8a981 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -75,6 +75,11 @@
}
}
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ mController.updatePassword();
+ }
+
@Override
public boolean isEdit() {
return mEdit;