Merge "Add padlock to location for work profile when disabled by admin."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4366b0b..b661a1e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -454,6 +454,17 @@
<service android:name=".TetherService"
android:exported="true"
android:permission="android.permission.TETHER_PRIVILEGED" />
+
+ <activity android:name="TetherProvisioningActivity"
+ android:exported="true"
+ android:permission="android.permission.TETHER_PRIVILEGED"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.TETHER_PROVISIONING_UI" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<receiver
android:name=".HotspotOffReceiver" >
<intent-filter>
diff --git a/res/layout/device_admin_add.xml b/res/layout/device_admin_add.xml
index 4e8a6ac..b42b694 100644
--- a/res/layout/device_admin_add.xml
+++ b/res/layout/device_admin_add.xml
@@ -149,6 +149,15 @@
android:text="@string/cancel"
style="?android:attr/buttonBarButtonStyle"
android:layout_height="wrap_content" />
+ <Button android:id="@+id/uninstall_button"
+ android:layout_width="0dip"
+ android:layout_gravity="end"
+ android:layout_weight="1"
+ android:maxLines="2"
+ android:text="@string/uninstall_device_admin"
+ style="?android:attr/buttonBarButtonStyle"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
<Button android:id="@+id/action_button"
android:layout_width="0dip"
android:layout_gravity="start"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 84d98da..bce8fb0 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -502,6 +502,24 @@
android:inputType="textNoSuggestions" />
</LinearLayout>
</LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/wifi_section">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item" >
+ <CheckBox android:id="@+id/shared"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item_content"
+ android:textSize="14sp"
+ android:text="@string/wifi_shared"
+ android:checked="true" />
+ </LinearLayout>
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index e070505..b048b71 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -15,9 +15,6 @@
-->
<resources>
- <declare-styleable name="WifiEncryptionState">
- <attr name="state_encrypted" format="boolean" />
- </declare-styleable>
<declare-styleable name="IconPreferenceScreen">
<attr name="icon" />
</declare-styleable>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 6140c78..30aa52f 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -207,7 +207,6 @@
<!-- WiFi Preferences -->
<dimen name="wifi_divider_height">1px</dimen>
- <dimen name="wifi_preference_badge_padding">8dip</dimen>
<!-- Color picker -->
<dimen name="color_swatch_size">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index eca018c..f94893d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1020,6 +1020,15 @@
<!-- Summary specifying that this is the current screen lock setting [CHAR LIMIT=45] -->
<string name="current_screen_lock">Current screen lock</string>
+ <!-- Title for preference that guides the user through creating a backup unlock pattern for fingerprint [CHAR LIMIT=45]-->
+ <string name="fingerprint_unlock_set_unlock_pattern">Fingerprint + Pattern</string>
+
+ <!-- Title for preference that guides the user through creating a backup unlock PIN for fingerprint [CHAR LIMIT=45]-->
+ <string name="fingerprint_unlock_set_unlock_pin">Fingerprint + PIN</string>
+
+ <!-- Title for preference that guides the user through creating a backup unlock password for fingerprint [CHAR LIMIT=45]-->
+ <string name="fingerprint_unlock_set_unlock_password">Fingerprint + Password</string>
+
<!-- Summary for preference that has been disabled by because of the DevicePolicyAdmin, or because device encryption is enabled, or because there are credentials in the credential storage [CHAR LIMIT=50] -->
<string name="unlock_set_unlock_disabled_summary">Disabled by administrator, encryption policy, or credential storage</string>
@@ -1626,6 +1635,8 @@
<string name="wifi_ap_choose_5G">5 GHz Band</string>
<!-- Label for the spinner to show ip settings [CHAR LIMIT=25] -->
<string name="wifi_ip_settings">IP settings</string>
+ <!-- Label for the check box to share a network with other users on the same device -->
+ <string name="wifi_shared">Share with other device users</string>
<!-- Hint for unchanged fields -->
<string name="wifi_unchanged">(unchanged)</string>
<!-- Hint for unspecified fields -->
@@ -3811,8 +3822,6 @@
<string name="accessibility_feature_state_on">On</string>
<!-- Summary for the disabled state of an accessibility feature. [CHAR LIMIT=10] -->
<string name="accessibility_feature_state_off">Off</string>
- <!-- Summary when an accessibility feature or ime is not permitted. [CHAR LIMIT=40] -->
- <string name="accessibility_feature_or_input_method_not_allowed">Not allowed by your organization</string>
<!-- Title for the preference category containing the video caption preview. [CHAR LIMIT=35] -->
<string name="captioning_preview_title">Preview</string>
@@ -4521,6 +4530,8 @@
<string name="active_device_admin_msg">Device administrator</string>
<!-- Label for button to remove the active device admin -->
<string name="remove_device_admin">Deactivate</string>
+ <!-- Label for button to uninstall the device admin application [CHAR LIMIT=40] -->
+ <string name="uninstall_device_admin">Uninstall</string>
<!-- Label for screen showing to select device policy -->
<string name="select_device_admin_msg">Device administrators</string>
<!-- Message when there are no available device admins to display -->
diff --git a/res/values/themes.xml b/res/values/themes.xml
index f3a9369..da74348 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -24,7 +24,6 @@
<attr name="setup_divider_color" format="reference" />
<attr name="side_margin" format="reference|dimension" />
<attr name="wifi_signal_color" format="reference" />
- <attr name="wifi_signal" format="reference" />
<style name="SetupWizardDisableAppStartingTheme">
<!-- Theme to disable the app starting window. The actual theme of the activity needs to
diff --git a/res/xml/privacy_settings.xml b/res/xml/privacy_settings.xml
index f67c837..461d242 100644
--- a/res/xml/privacy_settings.xml
+++ b/res/xml/privacy_settings.xml
@@ -33,6 +33,11 @@
<intent android:action="dummy" />
</PreferenceScreen>
+ <PreferenceScreen
+ android:key="data_management"
+ android:persistent="false">
+ </PreferenceScreen>
+
<SwitchPreference
android:key="auto_restore"
android:title="@string/auto_restore_title"
@@ -51,6 +56,7 @@
android:key="network_reset"
android:title="@string/reset_network_title"
settings:keywords="@string/keywords_network_reset"
+ settings:useAdminDisabledSummary="true"
android:fragment="com.android.settings.ResetNetwork" />
<!-- Factory reset -->
@@ -59,6 +65,7 @@
android:title="@string/master_clear_title"
settings:keywords="@string/keywords_factory_data_reset"
settings:userRestriction="no_factory_reset"
+ settings:useAdminDisabledSummary="true"
android:fragment="com.android.settings.MasterClear" />
</PreferenceScreen>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index 2137490..2b8ae13 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -62,6 +62,7 @@
<com.android.settingslib.RestrictedPreference
android:key="zen_mode"
android:title="@string/zen_mode_settings_title"
+ settings:useAdminDisabledSummary="true"
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
android:fragment="com.android.settings.notification.ZenModeSettings" />
@@ -91,7 +92,8 @@
<com.android.settingslib.RestrictedPreference
android:key="cell_broadcast_settings"
- android:title="@string/cell_broadcast_settings" >
+ android:title="@string/cell_broadcast_settings"
+ settings:useAdminDisabledSummary="true">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.cellbroadcastreceiver"
diff --git a/res/xml/user_details_settings.xml b/res/xml/user_details_settings.xml
index 96c8ab9..0b0c6d9 100644
--- a/res/xml/user_details_settings.xml
+++ b/res/xml/user_details_settings.xml
@@ -23,6 +23,7 @@
android:persistent="false" />
<com.android.settingslib.RestrictedPreference
android:key="remove_user"
- android:title="@string/user_remove_user" />
+ android:title="@string/user_remove_user"
+ settings:useAdminDisabledSummary="true" />
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/wifi_settings.xml b/res/xml/wifi_settings.xml
index 99a0c4e..b4ab126 100644
--- a/res/xml/wifi_settings.xml
+++ b/res/xml/wifi_settings.xml
@@ -21,7 +21,7 @@
<!-- Needed so PreferenceGroupAdapter allows AccessPointPreference to be
recycled. Removed in onResume -->
- <com.android.settings.wifi.AccessPointPreference
+ <com.android.settings.wifi.LongPressAccessPointPreference
android:key="dummy" />
</PreferenceScreen>
diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
index db7e18a..10ec484 100644
--- a/res/xml/wireless_settings.xml
+++ b/res/xml/wireless_settings.xml
@@ -44,12 +44,14 @@
<com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.TetherSettings"
android:key="tether_settings"
- android:title="@string/tether_settings_title_all" />
+ android:title="@string/tether_settings_title_all"
+ settings:useAdminDisabledSummary="true" />
<com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.vpn2.VpnSettings"
android:key="vpn_settings"
- android:title="@string/vpn_settings_title" />
+ android:title="@string/vpn_settings_title"
+ settings:useAdminDisabledSummary="true" />
<PreferenceScreen
android:key="mobile_network_settings"
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index 0e6cf3b..6461b93 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -300,6 +300,7 @@
}
addPreferencesFromResource(R.xml.security_settings_picker);
disableUnusablePreferences(quality, hideDisabledPrefs);
+ updatePreferenceText();
updateCurrentPreference();
updatePreferenceSummaryIfNeeded();
} else {
@@ -307,6 +308,19 @@
}
}
+ private void updatePreferenceText() {
+ if (mForFingerprint) {
+ Preference pattern = findPreference(KEY_UNLOCK_SET_PATTERN);
+ pattern.setTitle(R.string.fingerprint_unlock_set_unlock_pattern);
+
+ Preference pin = findPreference(KEY_UNLOCK_SET_PIN);
+ pin.setTitle(R.string.fingerprint_unlock_set_unlock_pin);
+
+ Preference password = findPreference(KEY_UNLOCK_SET_PASSWORD);
+ password.setTitle(R.string.fingerprint_unlock_set_unlock_password);
+ }
+ }
+
private void updateCurrentPreference() {
String currentKey = getKeyForCurrent();
Preference preference = findPreference(currentKey);
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index 3067ca2..1ce72f9 100644
--- a/src/com/android/settings/DeviceAdminAdd.java
+++ b/src/com/android/settings/DeviceAdminAdd.java
@@ -36,6 +36,7 @@
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
+import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -74,6 +75,8 @@
private static final int MAX_ADD_MSG_LINES_LANDSCAPE = 2;
private static final int MAX_ADD_MSG_LINES = 15;
+ private static final int REQUEST_CODE_UNINSTALL = 1;
+
Handler mHandler;
DevicePolicyManager mDPM;
@@ -93,6 +96,7 @@
TextView mSupportMessage;
ViewGroup mAdminPolicies;
Button mActionButton;
+ Button mUninstallButton;
Button mCancelButton;
boolean mAdding;
@@ -285,6 +289,7 @@
mAdminWarning = (TextView) findViewById(R.id.admin_warning);
mAdminPolicies = (ViewGroup) findViewById(R.id.admin_policies);
mSupportMessage = (TextView) findViewById(R.id.admin_support_message);
+
mCancelButton = (Button) findViewById(R.id.cancel_button);
mCancelButton.setFilterTouchesWhenObscured(true);
mCancelButton.setOnClickListener(new View.OnClickListener() {
@@ -294,6 +299,17 @@
finish();
}
});
+
+ mUninstallButton = (Button) findViewById(R.id.uninstall_button);
+ mUninstallButton.setFilterTouchesWhenObscured(true);
+ mUninstallButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ EventLog.writeEvent(EventLogTags.EXP_DET_DEVICE_ADMIN_UNINSTALLED_BY_USER,
+ mDeviceAdmin.getActivityInfo().applicationInfo.uid);
+ uninstall();
+ }
+ });
+
mActionButton = (Button) findViewById(R.id.action_button);
mActionButton.setFilterTouchesWhenObscured(true);
mActionButton.setOnClickListener(new View.OnClickListener() {
@@ -448,6 +464,18 @@
}
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ switch (requestCode) {
+ case REQUEST_CODE_UNINSTALL:
+ if (resultCode == RESULT_OK) {
+ finish();
+ }
+ return;
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
void updateInterface() {
mAdminIcon.setImageDrawable(mDeviceAdmin.loadIcon(getPackageManager()));
mAdminName.setText(mDeviceAdmin.loadLabel(getPackageManager()));
@@ -516,6 +544,9 @@
setTitle(getText(R.string.add_device_admin_msg));
}
mActionButton.setText(getText(R.string.add_device_admin));
+ if (isAdminUninstallable()) {
+ mUninstallButton.setVisibility(View.VISIBLE);
+ }
mSupportMessage.setVisibility(View.GONE);
mAdding = true;
}
@@ -564,4 +595,18 @@
UserHandle.getUserId(adminInfo.getActivityInfo().applicationInfo.uid));
return info != null ? info.isManagedProfile() : false;
}
+
+ private boolean isAdminUninstallable() {
+ // System apps can't be uninstalled.
+ return !mDeviceAdmin.getActivityInfo().applicationInfo.isSystemApp();
+ }
+
+ private void uninstall() {
+ final Uri packageURI = Uri.parse("package:" + mDeviceAdmin.getPackageName());
+ final Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
+ uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, false);
+ uninstallIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
+
+ startActivityForResult(uninstallIntent, REQUEST_CODE_UNINSTALL);
+ }
}
diff --git a/src/com/android/settings/DimmableIconPreference.java b/src/com/android/settings/DimmableIconPreference.java
index 98bf551..8f09c53 100644
--- a/src/com/android/settings/DimmableIconPreference.java
+++ b/src/com/android/settings/DimmableIconPreference.java
@@ -44,11 +44,13 @@
public DimmableIconPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContentDescription = null;
+ useAdminDisabledSummary(true);
}
public DimmableIconPreference(Context context, @Nullable CharSequence contentDescription) {
super(context);
mContentDescription = contentDescription;
+ useAdminDisabledSummary(true);
}
private void dimIcon(boolean dimmed) {
diff --git a/src/com/android/settings/EventLogTags.logtags b/src/com/android/settings/EventLogTags.logtags
index b21623c..1811866 100644
--- a/src/com/android/settings/EventLogTags.logtags
+++ b/src/com/android/settings/EventLogTags.logtags
@@ -10,3 +10,6 @@
# log whether user declined activation of device admin
90202 exp_det_device_admin_declined_by_user (app_signature|3)
+
+# log whether user uninstalled device admin on activation screen
+90203 exp_det_device_admin_uninstalled_by_user (app_signature|3)
diff --git a/src/com/android/settings/HotspotOffReceiver.java b/src/com/android/settings/HotspotOffReceiver.java
index f3c3fee..3db0ee9 100644
--- a/src/com/android/settings/HotspotOffReceiver.java
+++ b/src/com/android/settings/HotspotOffReceiver.java
@@ -4,6 +4,7 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.util.Log;
@@ -25,7 +26,8 @@
if (wifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED) {
if (DEBUG) Log.d(TAG, "TetherService.cancelRecheckAlarmIfNecessary called");
// The hotspot has been turned off, we don't need to recheck tethering.
- TetherService.cancelRecheckAlarmIfNecessary(context, TetherUtil.TETHERING_WIFI);
+ TetherService.cancelRecheckAlarmIfNecessary(
+ context, ConnectivityManager.TETHERING_WIFI);
}
}
}
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index dbceb2b..df73fec 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -56,6 +56,7 @@
private static final String BACKUP_DATA = "backup_data";
private static final String AUTO_RESTORE = "auto_restore";
private static final String CONFIGURE_ACCOUNT = "configure_account";
+ private static final String DATA_MANAGEMENT = "data_management";
private static final String BACKUP_INACTIVE = "backup_inactive";
private static final String NETWORK_RESET = "network_reset";
private static final String FACTORY_RESET = "factory_reset";
@@ -64,6 +65,7 @@
private PreferenceScreen mBackup;
private SwitchPreference mAutoRestore;
private PreferenceScreen mConfigure;
+ private PreferenceScreen mManageData;
private boolean mEnabled;
@Override
@@ -92,6 +94,7 @@
mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
+ mManageData = (PreferenceScreen) screen.findPreference(DATA_MANAGEMENT);
Set<String> keysToRemove = new HashSet<>();
getNonVisibleKeys(getActivity(), keysToRemove);
@@ -146,11 +149,15 @@
boolean backupEnabled = false;
Intent configIntent = null;
String configSummary = null;
+ Intent manageIntent = null;
+ String manageLabel = null;
try {
backupEnabled = mBackupManager.isBackupEnabled();
String transport = mBackupManager.getCurrentTransport();
configIntent = mBackupManager.getConfigurationIntent(transport);
configSummary = mBackupManager.getDestinationString(transport);
+ manageIntent = mBackupManager.getDataManagementIntent(transport);
+ manageLabel = mBackupManager.getDataManagementLabel(transport);
mBackup.setSummary(backupEnabled
? R.string.accessibility_feature_state_on
@@ -169,6 +176,17 @@
mConfigure.setIntent(configIntent);
setConfigureSummary(configSummary);
+ final boolean manageEnabled = (manageIntent != null) && backupEnabled;
+ if (manageEnabled) {
+ mManageData.setIntent(manageIntent);
+ if (manageLabel != null) {
+ mManageData.setTitle(manageLabel);
+ }
+ } else {
+ // Hide the item if data management intent is not supported by transport.
+ getPreferenceScreen().removePreference(mManageData);
+ }
+
RestrictedPreference networkResetPref = (RestrictedPreference) findPreference(
NETWORK_RESET);
if (networkResetPref != null) {
diff --git a/src/com/android/settings/TetherProvisioningActivity.java b/src/com/android/settings/TetherProvisioningActivity.java
new file mode 100644
index 0000000..408e001
--- /dev/null
+++ b/src/com/android/settings/TetherProvisioningActivity.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2016 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.Activity;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.os.Bundle;
+import android.os.ResultReceiver;
+import android.os.UserHandle;
+import android.util.Log;
+
+/**
+ * Activity which acts as a proxy to the tether provisioning app for sanity checks and permission
+ * restrictions. Specifically, the provisioning apps require
+ * {@link android.permission.CONNECTIVITY_INTERNAL}, while this activity can be started by a caller
+ * with {@link android.permission.TETHER_PRIVILEGED}.
+ */
+public class TetherProvisioningActivity extends Activity {
+ private static final int PROVISION_REQUEST = 0;
+ private static final String TAG = "TetherProvisioningAct";
+ private static final String EXTRA_TETHER_TYPE = "TETHER_TYPE";
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+ private ResultReceiver mResultReceiver;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mResultReceiver = (ResultReceiver)getIntent().getParcelableExtra(
+ ConnectivityManager.EXTRA_PROVISION_CALLBACK);
+
+ // TODO: Move isProvisioningNeededButUnavailable into ConnectivityManager and check
+ // it here to short-circuit and fail.
+
+ int tetherType = getIntent().getIntExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE,
+ ConnectivityManager.TETHERING_INVALID);
+ String[] provisionApp = getResources().getStringArray(
+ com.android.internal.R.array.config_mobile_hotspot_provision_app);
+
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setClassName(provisionApp[0], provisionApp[1]);
+ intent.putExtra(EXTRA_TETHER_TYPE, tetherType);
+ if (DEBUG) {
+ Log.d(TAG, "Starting provisioning app: " + provisionApp[0] + "." + provisionApp[1]);
+ }
+ startActivityForResultAsUser(intent, PROVISION_REQUEST, UserHandle.CURRENT);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ super.onActivityResult(requestCode, resultCode, intent);
+ if (requestCode == PROVISION_REQUEST) {
+ if (DEBUG) Log.d(TAG, "Got result from app: " + resultCode);
+ int result = resultCode == Activity.RESULT_OK ?
+ ConnectivityManager.TETHER_ERROR_NO_ERROR :
+ ConnectivityManager.TETHER_ERROR_PROVISION_FAILED;
+ mResultReceiver.send(result, null);
+ finish();
+ }
+ }
+}
diff --git a/src/com/android/settings/TetherService.java b/src/com/android/settings/TetherService.java
index 346a175..d4944ef 100644
--- a/src/com/android/settings/TetherService.java
+++ b/src/com/android/settings/TetherService.java
@@ -31,13 +31,16 @@
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.os.IBinder;
+import android.os.ResultReceiver;
import android.os.SystemClock;
import android.text.TextUtils;
+import android.util.ArrayMap;
import android.util.Log;
import com.android.settingslib.TetherUtil;
import java.util.ArrayList;
+import java.util.List;
public class TetherService extends Service {
private static final String TAG = "TetherService";
@@ -57,9 +60,9 @@
private static final String KEY_TETHERS = "currentTethers";
private int mCurrentTypeIndex;
- private boolean mEnableWifiAfterCheck;
private boolean mInProvisionCheck;
private ArrayList<Integer> mCurrentTethers;
+ private ArrayMap<Integer, List<ResultReceiver>> mPendingCallbacks;
@Override
public IBinder onBind(Intent intent) {
@@ -77,23 +80,42 @@
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
mCurrentTethers = stringToTethers(prefs.getString(KEY_TETHERS, ""));
mCurrentTypeIndex = 0;
+ mPendingCallbacks = new ArrayMap<>(3);
+ mPendingCallbacks.put(ConnectivityManager.TETHERING_WIFI, new ArrayList<ResultReceiver>());
+ mPendingCallbacks.put(ConnectivityManager.TETHERING_USB, new ArrayList<ResultReceiver>());
+ mPendingCallbacks.put(
+ ConnectivityManager.TETHERING_BLUETOOTH, new ArrayList<ResultReceiver>());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- if (intent.hasExtra(TetherUtil.EXTRA_ADD_TETHER_TYPE)) {
- int type = intent.getIntExtra(TetherUtil.EXTRA_ADD_TETHER_TYPE,
- TetherUtil.TETHERING_INVALID);
+ if (intent.hasExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE)) {
+ int type = intent.getIntExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE,
+ ConnectivityManager.TETHERING_INVALID);
+ ResultReceiver callback =
+ intent.getParcelableExtra(ConnectivityManager.EXTRA_PROVISION_CALLBACK);
+ if (callback != null) {
+ List<ResultReceiver> callbacksForType = mPendingCallbacks.get(type);
+ if (callbacksForType != null) {
+ callbacksForType.add(callback);
+ } else {
+ // Invalid tether type. Just ignore this request and report failure.
+ callback.send(ConnectivityManager.TETHER_ERROR_UNKNOWN_IFACE, null);
+ stopSelf();
+ return START_NOT_STICKY;
+ }
+ }
+
if (!mCurrentTethers.contains(type)) {
if (DEBUG) Log.d(TAG, "Adding tether " + type);
mCurrentTethers.add(type);
}
}
- if (intent.hasExtra(TetherUtil.EXTRA_REM_TETHER_TYPE)) {
+ if (intent.hasExtra(ConnectivityManager.EXTRA_REM_TETHER_TYPE)) {
if (!mInProvisionCheck) {
- int type = intent.getIntExtra(TetherUtil.EXTRA_REM_TETHER_TYPE,
- TetherUtil.TETHERING_INVALID);
+ int type = intent.getIntExtra(ConnectivityManager.EXTRA_REM_TETHER_TYPE,
+ ConnectivityManager.TETHERING_INVALID);
int index = mCurrentTethers.indexOf(type);
if (DEBUG) Log.d(TAG, "Removing tether " + type + ", index " + index);
if (index >= 0) {
@@ -114,19 +136,16 @@
// Only set the alarm if we have one tether, meaning the one just added,
// to avoid setting it when it was already set previously for another
// type.
- if (intent.getBooleanExtra(TetherUtil.EXTRA_SET_ALARM, false)
+ if (intent.getBooleanExtra(ConnectivityManager.EXTRA_SET_ALARM, false)
&& mCurrentTethers.size() == 1) {
scheduleAlarm();
}
- if (intent.getBooleanExtra(TetherUtil.EXTRA_ENABLE_WIFI_TETHER, false)) {
- mEnableWifiAfterCheck = true;
- }
-
- if (intent.getBooleanExtra(TetherUtil.EXTRA_RUN_PROVISION, false)) {
+ if (intent.getBooleanExtra(ConnectivityManager.EXTRA_RUN_PROVISION, false)) {
startProvisioning(mCurrentTypeIndex);
} else if (!mInProvisionCheck) {
// If we aren't running any provisioning, no reason to stay alive.
+ if (DEBUG) Log.d(TAG, "Stopping self. startid: " + startId);
stopSelf();
return START_NOT_STICKY;
}
@@ -173,12 +192,6 @@
return buffer.toString();
}
- private void enableWifiTetheringIfNeeded() {
- if (!TetherUtil.isWifiTetherEnabled(this)) {
- TetherUtil.setWifiTethering(true, this);
- }
- }
-
private void disableWifiTethering() {
TetherUtil.setWifiTethering(false, this);
}
@@ -221,14 +234,14 @@
public static void scheduleRecheckAlarm(Context context, int type) {
Intent intent = new Intent(context, TetherService.class);
- intent.putExtra(TetherUtil.EXTRA_ADD_TETHER_TYPE, type);
- intent.putExtra(TetherUtil.EXTRA_SET_ALARM, true);
+ intent.putExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE, type);
+ intent.putExtra(ConnectivityManager.EXTRA_SET_ALARM, true);
context.startService(intent);
}
private void scheduleAlarm() {
Intent intent = new Intent(this, TetherService.class);
- intent.putExtra(TetherUtil.EXTRA_RUN_PROVISION, true);
+ intent.putExtra(ConnectivityManager.EXTRA_RUN_PROVISION, true);
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
@@ -248,7 +261,7 @@
*/
public static void cancelRecheckAlarmIfNecessary(final Context context, int type) {
Intent intent = new Intent(context, TetherService.class);
- intent.putExtra(TetherUtil.EXTRA_REM_TETHER_TYPE, type);
+ intent.putExtra(ConnectivityManager.EXTRA_REM_TETHER_TYPE, type);
context.startService(intent);
}
@@ -264,6 +277,20 @@
if (DEBUG) Log.d(TAG, "Tethering no longer active, canceling recheck");
}
+ private void fireCallbacksForType(int type, int result) {
+ List<ResultReceiver> callbacksForType = mPendingCallbacks.get(type);
+ if (callbacksForType == null) {
+ return;
+ }
+ int errorCode = result == RESULT_OK ? ConnectivityManager.TETHER_ERROR_NO_ERROR :
+ ConnectivityManager.TETHER_ERROR_PROVISION_FAILED;
+ for (ResultReceiver callback : callbacksForType) {
+ if (DEBUG) Log.d(TAG, "Firing result: " + errorCode + " to callback");
+ callback.send(errorCode, null);
+ }
+ callbacksForType.clear();
+ }
+
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -278,24 +305,21 @@
}
int checkType = mCurrentTethers.get(mCurrentTypeIndex);
mInProvisionCheck = false;
- if (intent.getIntExtra(EXTRA_RESULT, RESULT_DEFAULT) == RESULT_OK) {
- if (checkType == TetherUtil.TETHERING_WIFI && mEnableWifiAfterCheck) {
- enableWifiTetheringIfNeeded();
- mEnableWifiAfterCheck = false;
- }
- } else {
+ int result = intent.getIntExtra(EXTRA_RESULT, RESULT_DEFAULT);
+ if (result != RESULT_OK) {
switch (checkType) {
- case TetherUtil.TETHERING_WIFI:
+ case ConnectivityManager.TETHERING_WIFI:
disableWifiTethering();
break;
- case TetherUtil.TETHERING_BLUETOOTH:
+ case ConnectivityManager.TETHERING_BLUETOOTH:
disableBtTethering();
break;
- case TetherUtil.TETHERING_USB:
+ case ConnectivityManager.TETHERING_USB:
disableUsbTethering();
break;
}
}
+ fireCallbacksForType(checkType, result);
if (++mCurrentTypeIndex >= mCurrentTethers.size()) {
// We are done with all checks, time to die.
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index ee8900e..4b5f23d 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -47,10 +47,10 @@
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicReference;
-import static com.android.settingslib.TetherUtil.TETHERING_BLUETOOTH;
-import static com.android.settingslib.TetherUtil.TETHERING_INVALID;
-import static com.android.settingslib.TetherUtil.TETHERING_USB;
-import static com.android.settingslib.TetherUtil.TETHERING_WIFI;
+import static android.net.ConnectivityManager.TETHERING_BLUETOOTH;
+import static android.net.ConnectivityManager.TETHERING_INVALID;
+import static android.net.ConnectivityManager.TETHERING_USB;
+import static android.net.ConnectivityManager.TETHERING_WIFI;
/*
* Displays preferences for Tethering.
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index f56ebe0..411256c 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -481,6 +481,7 @@
AccessibilityServiceInfo info = installedServices.get(i);
RestrictedPreference preference = new RestrictedPreference(getActivity());
+ preference.useAdminDisabledSummary(true);
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
@@ -515,13 +516,9 @@
preference.setEnabled(true);
}
- String summaryString;
if (serviceAllowed) {
- summaryString = serviceEnabledString;
- } else {
- summaryString = getString(R.string.accessibility_feature_or_input_method_not_allowed);
+ preference.setSummary(serviceEnabledString);
}
- preference.setSummary(summaryString);
preference.setOrder(i);
preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
diff --git a/src/com/android/settings/accounts/ProviderPreference.java b/src/com/android/settings/accounts/ProviderPreference.java
index 863fef4..31f0c8e 100644
--- a/src/com/android/settings/accounts/ProviderPreference.java
+++ b/src/com/android/settings/accounts/ProviderPreference.java
@@ -39,6 +39,7 @@
setIcon(icon);
setPersistent(false);
setTitle(providerName);
+ useAdminDisabledSummary(true);
}
public String getAccountType() {
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java
index beb1a8f..61cecf4 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java
@@ -18,11 +18,13 @@
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
+import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.View;
import com.android.internal.logging.MetricsLogger;
+import com.android.settings.ChooseLockGeneric;
import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.HelpUtils;
import com.android.settings.R;
@@ -32,6 +34,9 @@
*/
public class FingerprintEnrollIntroduction extends FingerprintEnrollBase {
+ private static final int CHOOSE_LOCK_GENERIC_REQUEST = 1;
+ private static final int FINGERPRINT_FIND_SENSOR_REQUEST = 2;
+
private boolean mHasPassword;
@Override
@@ -43,24 +48,48 @@
findViewById(R.id.learn_more_button).setOnClickListener(this);
final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
.getActivePasswordQuality(UserHandle.myUserId());
+ updatePasswordQuality();
+ }
+
+ private void updatePasswordQuality() {
+ final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
+ .getActivePasswordQuality(UserHandle.myUserId());
mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
}
@Override
protected void onNextButtonClick() {
- Intent intent;
if (!mHasPassword) {
// No fingerprints registered, launch into enrollment wizard.
- intent = getOnboardIntent();
+ launchChooseLock();
} else {
// Lock thingy is already set up, launch directly into find sensor step from wizard.
- intent = getFindSensorIntent();
+ launchFindSensor(null);
}
- startActivityForResult(intent, 0);
}
- protected Intent getOnboardIntent() {
- return new Intent(this, FingerprintEnrollOnboard.class);
+ private void launchChooseLock() {
+ Intent intent = getChooseLockIntent();
+ long challenge = getSystemService(FingerprintManager.class).preEnroll();
+ intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
+ DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
+ intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
+ intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
+ intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
+ intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true);
+ startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST);
+ }
+
+ private void launchFindSensor(byte[] token) {
+ Intent intent = getFindSensorIntent();
+ if (token != null) {
+ intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
+ }
+ startActivityForResult(intent, FINGERPRINT_FIND_SENSOR_REQUEST);
+ }
+
+ protected Intent getChooseLockIntent() {
+ return new Intent(this, ChooseLockGeneric.class);
}
protected Intent getFindSensorIntent() {
@@ -70,8 +99,15 @@
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_FINISHED) {
- setResult(RESULT_OK);
- finish();
+ if (requestCode == FINGERPRINT_FIND_SENSOR_REQUEST) {
+ setResult(RESULT_OK);
+ finish();
+ } else if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
+ updatePasswordQuality();
+ byte[] token = data.getByteArrayExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
+ launchFindSensor(token);
+ }
} else {
super.onActivityResult(requestCode, resultCode, data);
}
diff --git a/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java b/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java
index c7e39e5..0f0d35f 100644
--- a/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java
@@ -23,6 +23,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.settings.R;
+import com.android.settings.SetupChooseLockGeneric;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.view.NavigationBar;
@@ -30,8 +31,8 @@
implements NavigationBar.NavigationBarListener {
@Override
- protected Intent getOnboardIntent() {
- final Intent intent = new Intent(this, SetupFingerprintEnrollOnboard.class);
+ protected Intent getChooseLockIntent() {
+ Intent intent = new Intent(this, SetupChooseLockGeneric.class);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java
index 8c87080..e38f181 100755
--- a/src/com/android/settings/inputmethod/InputMethodPreference.java
+++ b/src/com/android/settings/inputmethod/InputMethodPreference.java
@@ -119,6 +119,7 @@
&& mInputMethodSettingValues.isValidSystemNonAuxAsciiCapableIme(imi, context);
setOnPreferenceClickListener(this);
setOnPreferenceChangeListener(this);
+ useAdminDisabledSummary(true);
if (!isAllowedByOrganization) {
EnforcedAdmin admin =
RestrictedLockUtils.getProfileOrDeviceOwnerOnCallingUser(context);
@@ -194,7 +195,9 @@
// this preference should be disabled to prevent accidentally disabling an input method.
setEnabled(!((isAlwaysChecked && isImeEnabler()) || (!mIsAllowedByOrganization)));
setChecked(mInputMethodSettingValues.isEnabledImi(mImi));
- setSummary(getSummaryString());
+ if (mIsAllowedByOrganization) {
+ setSummary(getSummaryString());
+ }
}
private InputMethodManager getInputMethodManager() {
@@ -203,9 +206,6 @@
private String getSummaryString() {
final Context context = getContext();
- if (!mIsAllowedByOrganization) {
- return context.getString(R.string.accessibility_feature_or_input_method_not_allowed);
- }
final InputMethodManager imm = getInputMethodManager();
final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(mImi, true);
final ArrayList<CharSequence> subtypeLabels = new ArrayList<>();
diff --git a/src/com/android/settings/users/UserPreference.java b/src/com/android/settings/users/UserPreference.java
index 61ad6df..eff8b9a 100644
--- a/src/com/android/settings/users/UserPreference.java
+++ b/src/com/android/settings/users/UserPreference.java
@@ -76,6 +76,7 @@
mDeleteClickListener = deleteListener;
mSettingsClickListener = settingsListener;
mUserId = userId;
+ useAdminDisabledSummary(true);
}
private void dimIcon(boolean dimmed) {
diff --git a/src/com/android/settings/wifi/AccessPointPreference.java b/src/com/android/settings/wifi/AccessPointPreference.java
deleted file mode 100644
index 061055a..0000000
--- a/src/com/android/settings/wifi/AccessPointPreference.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * 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.wifi;
-
-import android.app.Fragment;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.StateListDrawable;
-import android.net.wifi.WifiConfiguration;
-import android.os.Looper;
-import android.os.UserHandle;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.util.SparseArray;
-import android.view.View;
-import android.widget.TextView;
-
-import com.android.settings.R;
-import com.android.settingslib.wifi.AccessPoint;
-
-public class AccessPointPreference extends Preference {
-
- private static final int[] STATE_SECURED = {
- R.attr.state_encrypted
- };
- private static final int[] STATE_NONE = {};
-
- private static int[] wifi_signal_attributes = { R.attr.wifi_signal };
-
- private final StateListDrawable mWifiSld;
- private final int mBadgePadding;
- private final UserBadgeCache mBadgeCache;
-
- private final Fragment mFragment;
-
- private TextView mTitleView;
- private boolean mForSavedNetworks = false;
- private AccessPoint mAccessPoint;
- private Drawable mBadge;
- private int mLevel;
- private CharSequence mContentDescription;
-
- static final int[] WIFI_CONNECTION_STRENGTH = {
- R.string.accessibility_wifi_one_bar,
- R.string.accessibility_wifi_two_bars,
- R.string.accessibility_wifi_three_bars,
- R.string.accessibility_wifi_signal_full
- };
-
- // Used for dummy pref.
- public AccessPointPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- mWifiSld = null;
- mBadgePadding = 0;
- mBadgeCache = null;
- mFragment = null;
- }
-
- public AccessPointPreference(AccessPoint accessPoint, Context context, UserBadgeCache cache,
- boolean forSavedNetworks, Fragment fragment) {
- super(context);
- mFragment = fragment;
- mBadgeCache = cache;
- mAccessPoint = accessPoint;
- mForSavedNetworks = forSavedNetworks;
- mAccessPoint.setTag(this);
- mLevel = -1;
-
- mWifiSld = (StateListDrawable) context.getTheme()
- .obtainStyledAttributes(wifi_signal_attributes).getDrawable(0);
-
- // Distance from the end of the title at which this AP's user badge should sit.
- mBadgePadding = context.getResources()
- .getDimensionPixelSize(R.dimen.wifi_preference_badge_padding);
- refresh();
- }
-
- public AccessPoint getAccessPoint() {
- return mAccessPoint;
- }
-
- @Override
- public void onBindViewHolder(final PreferenceViewHolder view) {
- super.onBindViewHolder(view);
- if (mFragment != null) {
- view.itemView.setOnCreateContextMenuListener(mFragment);
- view.itemView.setTag(this);
- view.itemView.setLongClickable(true);
- }
- if (mAccessPoint == null) {
- // Used for dummy pref.
- return;
- }
- Drawable drawable = getIcon();
- if (drawable != null) {
- drawable.setLevel(mLevel);
- }
-
- mTitleView = (TextView) view.findViewById(com.android.internal.R.id.title);
- if (mTitleView != null) {
- // Attach to the end of the title view
- mTitleView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, mBadge, null);
- mTitleView.setCompoundDrawablePadding(mBadgePadding);
- }
- view.itemView.setContentDescription(mContentDescription);
- }
-
- protected void updateIcon(int level, Context context) {
- if (level == -1) {
- setIcon(null);
- } else {
- if (getIcon() == null) {
- // To avoid a drawing race condition, we first set the state (SECURE/NONE) and then
- // set the icon (drawable) to that state's drawable.
- // If sld is null then we are indexing and therefore do not have access to
- // (nor need to display) the drawable.
- if (mWifiSld != null) {
- mWifiSld.setState((mAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE)
- ? STATE_SECURED
- : STATE_NONE);
- Drawable drawable = mWifiSld.getCurrent();
- if (!mForSavedNetworks) {
- setIcon(drawable);
- } else {
- setIcon(null);
- }
- }
- }
- }
- }
-
- protected void updateBadge(Context context) {
- WifiConfiguration config = mAccessPoint.getConfig();
- if (config != null) {
- // Fetch badge (may be null)
- // Get the badge using a cache since the PM will ask the UserManager for the list
- // of profiles every time otherwise.
- mBadge = mBadgeCache.getUserBadge(config.creatorUid);
- }
- }
-
- /**
- * Updates the title and summary; may indirectly call notifyChanged().
- */
- public void refresh() {
- if (mForSavedNetworks) {
- setTitle(mAccessPoint.getConfigName());
- } else {
- setTitle(mAccessPoint.getSsid());
- }
-
- final Context context = getContext();
- int level = mAccessPoint.getLevel();
- if (level != mLevel) {
- mLevel = level;
- updateIcon(mLevel, context);
- notifyChanged();
- }
- updateBadge(context);
-
- setSummary(mForSavedNetworks ? mAccessPoint.getSavedNetworkSummary()
- : mAccessPoint.getSettingsSummary());
-
- mContentDescription = getTitle();
- if (getSummary() != null) {
- mContentDescription = TextUtils.concat(mContentDescription, ",", getSummary());
- }
- if (level >= 0 && level < WIFI_CONNECTION_STRENGTH.length) {
- mContentDescription = TextUtils.concat(mContentDescription, ",",
- getContext().getString(WIFI_CONNECTION_STRENGTH[level]));
- }
- }
-
- @Override
- protected void notifyChanged() {
- if (Looper.getMainLooper() != Looper.myLooper()) {
- // Let our BG thread callbacks call setTitle/setSummary.
- postNotifyChanged();
- } else {
- super.notifyChanged();
- }
- }
-
- public void onLevelChanged() {
- postNotifyChanged();
- }
-
- private void postNotifyChanged() {
- if (mTitleView != null) {
- mTitleView.post(mNotifyChanged);
- } // Otherwise we haven't been bound yet, and don't need to update.
- }
-
- private final Runnable mNotifyChanged = new Runnable() {
- @Override
- public void run() {
- notifyChanged();
- }
- };
-
- public static class UserBadgeCache {
- private final SparseArray<Drawable> mBadges = new SparseArray<>();
- private final PackageManager mPm;
-
- UserBadgeCache(PackageManager pm) {
- mPm = pm;
- }
-
- private Drawable getUserBadge(int userId) {
- int index = mBadges.indexOfKey(userId);
- if (index < 0) {
- Drawable badge = mPm.getUserBadgeForDensity(new UserHandle(userId), 0 /* dpi */);
- mBadges.put(userId, badge);
- return badge;
- }
- return mBadges.valueAt(index);
- }
- }
-}
diff --git a/src/com/android/settings/wifi/LongPressAccessPointPreference.java b/src/com/android/settings/wifi/LongPressAccessPointPreference.java
new file mode 100644
index 0000000..46746cb
--- /dev/null
+++ b/src/com/android/settings/wifi/LongPressAccessPointPreference.java
@@ -0,0 +1,63 @@
+/*
+ * 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.wifi;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.StateListDrawable;
+import android.net.wifi.WifiConfiguration;
+import android.os.Looper;
+import android.os.UserHandle;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.SparseArray;
+import android.view.View;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settingslib.wifi.AccessPoint;
+import com.android.settingslib.wifi.AccessPointPreference;
+
+public class LongPressAccessPointPreference extends AccessPointPreference {
+
+ private final Fragment mFragment;
+
+ // Used for dummy pref.
+ public LongPressAccessPointPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mFragment = null;
+ }
+
+ public LongPressAccessPointPreference(AccessPoint accessPoint, Context context,
+ UserBadgeCache cache, boolean forSavedNetworks, Fragment fragment) {
+ super(accessPoint, context, cache, forSavedNetworks);
+ mFragment = fragment;
+ }
+
+ @Override
+ public void onBindViewHolder(final PreferenceViewHolder view) {
+ super.onBindViewHolder(view);
+ if (mFragment != null) {
+ view.itemView.setOnCreateContextMenuListener(mFragment);
+ view.itemView.setTag(this);
+ view.itemView.setLongClickable(true);
+ }
+ }
+}
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index e0ea23a..c5aca20 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -31,8 +31,8 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
-import com.android.settings.wifi.AccessPointPreference.UserBadgeCache;
import com.android.settingslib.wifi.AccessPoint;
+import com.android.settingslib.wifi.AccessPointPreference;
import com.android.settingslib.wifi.WifiTracker;
import java.util.ArrayList;
@@ -53,7 +53,7 @@
private Bundle mAccessPointSavedState;
private AccessPoint mSelectedAccessPoint;
- private UserBadgeCache mUserBadgeCache;
+ private AccessPointPreference.UserBadgeCache mUserBadgeCache;
// Instance state key
private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
@@ -67,7 +67,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.wifi_display_saved_access_points);
- mUserBadgeCache = new UserBadgeCache(getPackageManager());
+ mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
}
@Override
@@ -108,8 +108,9 @@
final int accessPointsSize = accessPoints.size();
for (int i = 0; i < accessPointsSize; ++i){
- AccessPointPreference preference = new AccessPointPreference(accessPoints.get(i),
- context, mUserBadgeCache, true, this);
+ LongPressAccessPointPreference preference =
+ new LongPressAccessPointPreference(accessPoints.get(i), context,
+ mUserBadgeCache, true, this);
preference.setIcon(null);
preferenceScreen.addPreference(preference);
}
@@ -119,7 +120,7 @@
}
}
- private void showDialog(AccessPointPreference accessPoint, boolean edit) {
+ private void showDialog(LongPressAccessPointPreference accessPoint, boolean edit) {
if (mDialog != null) {
removeDialog(WifiSettings.WIFI_DIALOG_ID);
mDialog = null;
@@ -184,8 +185,8 @@
@Override
public boolean onPreferenceTreeClick(Preference preference) {
- if (preference instanceof AccessPointPreference) {
- showDialog((AccessPointPreference) preference, false);
+ if (preference instanceof LongPressAccessPointPreference) {
+ showDialog((LongPressAccessPointPreference) preference, false);
return true;
} else{
return super.onPreferenceTreeClick(preference);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index abe700e..a7cb18d 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -35,6 +35,7 @@
import android.net.wifi.WifiEnterpriseConfig.Phase2;
import android.net.wifi.WifiInfo;
import android.os.Handler;
+import android.os.UserManager;
import android.security.Credentials;
import android.security.KeyStore;
import android.text.Editable;
@@ -138,6 +139,8 @@
private TextView mProxyExclusionListView;
private TextView mProxyPacView;
+ private CheckBox mSharedCheckBox;
+
private IpAssignment mIpAssignment = IpAssignment.UNASSIGNED;
private ProxySettings mProxySettings = ProxySettings.UNASSIGNED;
private ProxyInfo mHttpProxy = null;
@@ -179,6 +182,7 @@
mIpSettingsSpinner.setOnItemSelectedListener(this);
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
mProxySettingsSpinner.setOnItemSelectedListener(this);
+ mSharedCheckBox = (CheckBox) mView.findViewById(R.id.shared);
if (mAccessPoint == null) { // new network
mConfigUi.setTitle(R.string.wifi_add_network);
@@ -218,6 +222,10 @@
mIpSettingsSpinner.setSelection(DHCP);
}
+ mSharedCheckBox.setEnabled(config.shared);
+ if (!config.shared) {
+ showAdvancedFields = true;
+ }
if (config.getProxySettings() == ProxySettings.STATIC) {
mProxySettingsSpinner.setSelection(PROXY_STATIC);
@@ -308,6 +316,12 @@
}
}
+ final UserManager userManager =
+ (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ if (!userManager.isSplitSystemUser()) {
+ mSharedCheckBox.setVisibility(View.GONE);
+ }
+
mConfigUi.setCancelButton(res.getString(R.string.wifi_cancel));
if (mConfigUi.getSubmitButton() != null) {
enableSubmitIfAppropriate();
@@ -393,6 +407,8 @@
config.networkId = mAccessPoint.getConfig().networkId;
}
+ config.shared = mSharedCheckBox.isChecked();
+
switch (mAccessPointSecurity) {
case AccessPoint.SECURITY_NONE:
config.allowedKeyManagement.set(KeyMgmt.NONE);
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 8be0e79..67f1c43 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -63,6 +63,7 @@
import android.widget.TextView;
import android.widget.TextView.BufferType;
import android.widget.Toast;
+
import com.android.internal.logging.MetricsLogger;
import com.android.settings.LinkifyUtils;
import com.android.settings.R;
@@ -73,9 +74,9 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
-import com.android.settings.wifi.AccessPointPreference.UserBadgeCache;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPoint.AccessPointListener;
+import com.android.settingslib.wifi.AccessPointPreference;
import com.android.settingslib.wifi.WifiStatusTracker;
import com.android.settingslib.wifi.WifiTracker;
@@ -154,7 +155,7 @@
private HandlerThread mBgThread;
- private UserBadgeCache mUserBadgeCache;
+ private AccessPointPreference.UserBadgeCache mUserBadgeCache;
private Preference mAddPreference;
/* End of "used in Wifi Setup context" */
@@ -184,7 +185,7 @@
mAddPreference.setIcon(ic_add);
mAddPreference.setTitle(R.string.wifi_add_network);
- mUserBadgeCache = new UserBadgeCache(getPackageManager());
+ mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
mBgThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
mBgThread.start();
@@ -446,8 +447,9 @@
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {
Preference preference = (Preference) view.getTag();
- if (preference instanceof AccessPointPreference) {
- mSelectedAccessPoint = ((AccessPointPreference) preference).getAccessPoint();
+ if (preference instanceof LongPressAccessPointPreference) {
+ mSelectedAccessPoint =
+ ((LongPressAccessPointPreference) preference).getAccessPoint();
menu.setHeaderTitle(mSelectedAccessPoint.getSsid());
if (mSelectedAccessPoint.isConnectable()) {
menu.add(Menu.NONE, MENU_ID_CONNECT, 0, R.string.wifi_menu_connect);
@@ -513,8 +515,8 @@
@Override
public boolean onPreferenceTreeClick(Preference preference) {
- if (preference instanceof AccessPointPreference) {
- mSelectedAccessPoint = ((AccessPointPreference) preference).getAccessPoint();
+ if (preference instanceof LongPressAccessPointPreference) {
+ mSelectedAccessPoint = ((LongPressAccessPointPreference) preference).getAccessPoint();
if (mSelectedAccessPoint == null) {
return false;
}
@@ -651,7 +653,8 @@
getPreferenceScreen().addPreference(pref);
continue;
}
- AccessPointPreference preference = new AccessPointPreference(accessPoint,
+ LongPressAccessPointPreference
+ preference = new LongPressAccessPointPreference(accessPoint,
getPrefContext(), mUserBadgeCache, false, this);
preference.setOrder(index++);
@@ -876,15 +879,6 @@
}
/**
- * Refreshes acccess points and ask Wifi module to scan networks again.
- */
- /* package */ void refreshAccessPoints() {
- mWifiTracker.resumeScanning();
-
- getPreferenceScreen().removeAll();
- }
-
- /**
* Called when "add network" button is pressed.
*/
/* package */ void onAddNetworkPressed() {
@@ -894,29 +888,6 @@
showDialog(null, WifiConfigUiBase.MODE_CONNECT);
}
- /* package */ int getAccessPointsCount() {
- final boolean wifiIsEnabled = mWifiTracker.isWifiEnabled();
- if (wifiIsEnabled) {
- return getPreferenceScreen().getPreferenceCount();
- } else {
- return 0;
- }
- }
-
- /**
- * Requests wifi module to pause wifi scan. May be ignored when the module is disabled.
- */
- /* package */ void pauseWifiScan() {
- mWifiTracker.pauseScanning();
- }
-
- /**
- * Requests wifi module to resume wifi scan. May be ignored when the module is disabled.
- */
- /* package */ void resumeWifiScan() {
- mWifiTracker.resumeScanning();
- }
-
@Override
protected int getHelpResource() {
return R.string.help_url_wifi;
@@ -924,19 +895,19 @@
@Override
public void onAccessPointChanged(AccessPoint accessPoint) {
- ((AccessPointPreference) accessPoint.getTag()).refresh();
+ ((LongPressAccessPointPreference) accessPoint.getTag()).refresh();
}
@Override
public void onLevelChanged(AccessPoint accessPoint) {
- ((AccessPointPreference) accessPoint.getTag()).onLevelChanged();
+ ((LongPressAccessPointPreference) accessPoint.getTag()).onLevelChanged();
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
+ final List<SearchIndexableRaw> result = new ArrayList<>();
final Resources res = context.getResources();
// Add fragment title
diff --git a/tests/unit/src/com/android/settings/UserCredentialsTests.java b/tests/unit/src/com/android/settings/UserCredentialsTest.java
similarity index 81%
rename from tests/unit/src/com/android/settings/UserCredentialsTests.java
rename to tests/unit/src/com/android/settings/UserCredentialsTest.java
index da1e58b..6de252e 100644
--- a/tests/unit/src/com/android/settings/UserCredentialsTests.java
+++ b/tests/unit/src/com/android/settings/UserCredentialsTest.java
@@ -18,8 +18,7 @@
import android.os.Parcel;
import android.test.InstrumentationTestCase;
-import android.test.InstrumentationTestRunner;
-import android.test.suitebuilder.annotation.LargeTest;
+import android.test.suitebuilder.annotation.SmallTest;
import static com.android.settings.UserCredentialsSettings.Credential;
@@ -27,13 +26,14 @@
* User credentials settings fragment tests
*
* To run the test, use command:
- * adb shell am instrument -e class com.android.settings.security.UserCredentialsTests
- * -w com.android.settings.tests/android.test.InstrumentationTestRunner
+ * adb shell am instrument -e class com.android.settings.UserCredentialsTest
+ * -w com.android.settings.tests.unit/android.support.test.runner.AndroidJUnitRunner
*
*/
-public class UserCredentialsTests extends InstrumentationTestCase {
+public class UserCredentialsTest extends InstrumentationTestCase {
private static final String TAG = "UserCredentialsTests";
+ @SmallTest
public void testCredentialIsParcelable() {
final String alias = "credential-test-alias";
Credential c = new Credential(alias);