Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
......@@ -25,9 +25,12 @@ import android.os.Bundle;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.settings.deviceinfo.Status;
/**
* {@link Activity} that displays regulatory information for the "Regulatory information"
......@@ -56,9 +59,11 @@ public class RegulatoryInfoDisplayActivity extends Activity implements
}
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.regulatory_labels)
.setTitle(R.string.regulatory_information_dialog_title)
.setOnDismissListener(this);
View view = getLayoutInflater().inflate(R.layout.regulatory_info, null);
boolean regulatoryInfoDrawableExists = false;
int resId = getResourceId();
if (resId != 0) {
......@@ -73,24 +78,29 @@ public class RegulatoryInfoDisplayActivity extends Activity implements
}
}
CharSequence regulatoryText = resources.getText(R.string.regulatory_info_text);
if (regulatoryInfoDrawableExists) {
View view = getLayoutInflater().inflate(R.layout.regulatory_info, null);
ImageView image = (ImageView) view.findViewById(R.id.regulatoryInfo);
image.setVisibility(View.VISIBLE);
image.setImageResource(resId);
builder.setView(view);
builder.show();
} else if (regulatoryText.length() > 0) {
builder.setMessage(regulatoryText);
AlertDialog dialog = builder.show();
// we have to show the dialog first, or the setGravity() call will throw a NPE
TextView messageText = (TextView) dialog.findViewById(android.R.id.message);
messageText.setGravity(Gravity.CENTER);
} else {
// neither drawable nor text resource exists, finish activity
finish();
}
String sarValues = Status.getSarValues(getResources());
TextView sarText = (TextView) view.findViewById(R.id.sarValues);
if (!TextUtils.isEmpty(sarValues)) {
sarText.setVisibility(resources.getBoolean(R.bool.config_show_sar_enable)
? View.VISIBLE : View.GONE);
sarText.setText(sarValues);
}
String icCodes = Status.getIcCodes(getResources());
TextView icCode = (TextView) view.findViewById(R.id.icCodes);
if (!TextUtils.isEmpty(icCodes)) {
icCode.setVisibility(resources.getBoolean(R.bool.config_show_ic_enable)
? View.VISIBLE : View.GONE);
icCode.setText(icCodes);
}
builder.setView(view);
builder.show();
}
private int getResourceId() {
......
......@@ -64,6 +64,10 @@ import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.RestrictedSwitchPreference;
import cyanogenmod.providers.CMSettings;
import org.cyanogenmod.internal.util.CmLockPatternUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -102,6 +106,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
// Misc Settings
private static final String KEY_SIM_LOCK = "sim_lock";
private static final String KEY_SIM_LOCK_SETTINGS = "sim_lock_settings";
private static final String KEY_SHOW_PASSWORD = "show_password";
private static final String KEY_CREDENTIAL_STORAGE_TYPE = "credential_storage_type";
private static final String KEY_USER_CREDENTIALS = "user_credentials";
......@@ -112,6 +117,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
private static final String KEY_TRUST_AGENT = "trust_agent";
private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
private static final String KEY_LOCK_SCREEN_BLUR_ENABLED = "lock_screen_blur_enabled";
private static final int PASSWORD_VISIBLE = 1;
private static final int PASSWORD_INVISIBLE = 0;
// These switch preferences need special handling since they're not all stored in Settings.
private static final String SWITCH_PREFERENCE_KEYS[] = {
......@@ -301,17 +309,67 @@ public class SecuritySettings extends SettingsPreferenceFragment
addPreferencesFromResource(R.xml.security_settings_misc);
// Do not display SIM lock for devices without an Icc card
TelephonyManager tm = TelephonyManager.getDefault();
CarrierConfigManager cfgMgr = (CarrierConfigManager)
getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE);
PersistableBundle b = cfgMgr.getConfig();
if (!mIsAdmin || !isSimIccReady() ||
b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
root.removePreference(root.findPreference(KEY_SIM_LOCK));
PreferenceGroup iccLockGroup = (PreferenceGroup) root.findPreference(KEY_SIM_LOCK);
Preference iccLock = root.findPreference(KEY_SIM_LOCK_SETTINGS);
if (!mIsAdmin
|| b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
root.removePreference(iccLockGroup);
} else {
// Disable SIM lock if there is no ready SIM card.
root.findPreference(KEY_SIM_LOCK).setEnabled(isSimReady());
SubscriptionManager subMgr = SubscriptionManager.from(getActivity());
TelephonyManager tm = TelephonyManager.getDefault();
int numPhones = tm.getPhoneCount();
boolean hasAnySim = false;
for (int i = 0; i < numPhones; i++) {
final Preference pref;
if (numPhones > 1) {
SubscriptionInfo sir = subMgr.getActiveSubscriptionInfoForSimSlotIndex(i);
if (sir == null) {
continue;
}
pref = new Preference(getActivity());
pref.setOrder(iccLock.getOrder());
pref.setTitle(getString(R.string.sim_card_lock_settings_title, i + 1));
pref.setSummary(sir.getDisplayName());
Intent intent = new Intent(getActivity(),
com.android.settings.Settings.IccLockSettingsActivity.class);
intent.putExtra(IccLockSettings.EXTRA_SUB_ID, sir.getSubscriptionId());
intent.putExtra(IccLockSettings.EXTRA_SUB_DISPLAY_NAME,
sir.getDisplayName());
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
pref.setIntent(intent);
iccLockGroup.addPreference(pref);
} else {
pref = iccLock;
}
// Do not display SIM lock for devices without an Icc card
hasAnySim |= tm.hasIccCard(i);
int simState = tm.getSimState(i);
boolean simPresent = simState != TelephonyManager.SIM_STATE_ABSENT
&& simState != TelephonyManager.SIM_STATE_UNKNOWN
&& simState != TelephonyManager.SIM_STATE_CARD_IO_ERROR;
if (!simPresent) {
pref.setEnabled(false);
}
}
if (!hasAnySim) {
root.removePreference(iccLockGroup);
} else if (numPhones > 1) {
iccLockGroup.removePreference(iccLock);
}
}
if (Settings.System.getInt(getContentResolver(),
Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) {
root.findPreference(KEY_SCREEN_PINNING).setSummary(
......@@ -456,43 +514,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
/* Return true if a there is a Slot that has Icc.
*/
private boolean isSimIccReady() {
TelephonyManager tm = TelephonyManager.getDefault();
final List<SubscriptionInfo> subInfoList =
mSubscriptionManager.getActiveSubscriptionInfoList();
if (subInfoList != null) {
for (SubscriptionInfo subInfo : subInfoList) {
if (tm.hasIccCard(subInfo.getSimSlotIndex())) {
return true;
}
}
}
return false;
}
/* Return true if a SIM is ready for locking.
* TODO: consider adding to TelephonyManager or SubscritpionManasger.
*/
private boolean isSimReady() {
int simState = TelephonyManager.SIM_STATE_UNKNOWN;
final List<SubscriptionInfo> subInfoList =
mSubscriptionManager.getActiveSubscriptionInfoList();
if (subInfoList != null) {
for (SubscriptionInfo subInfo : subInfoList) {
simState = TelephonyManager.getDefault().getSimState(subInfo.getSimSlotIndex());
if((simState != TelephonyManager.SIM_STATE_ABSENT) &&
(simState != TelephonyManager.SIM_STATE_UNKNOWN)){
return true;
}
}
}
return false;
}
private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(
Context context, LockPatternUtils utils, DevicePolicyManager dpm) {
PackageManager pm = context.getPackageManager();
......@@ -602,8 +623,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
updateUnificationPreference();
if (mShowPassword != null) {
mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
mShowPassword.setChecked(isPasswordVisible());
}
if (mResetCredentials != null && !mResetCredentials.isDisabledByAdmin()) {
......@@ -611,6 +631,16 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
private boolean isPasswordVisible() {
int defaultValue = PASSWORD_VISIBLE ;
if (getResources().getBoolean(
R.bool.config_regional_security_show_password_enable)) {
defaultValue = PASSWORD_INVISIBLE ;
}
return Settings.System.getInt(getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, defaultValue) != 0 ;
}
private void updateUnificationPreference() {
if (mUnifyProfile != null) {
mUnifyProfile.setChecked(!mLockPatternUtils.isSeparateProfileChallengeEnabled(
......@@ -710,9 +740,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
private void unifyLocks() {
int profileQuality =
mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId);
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
mLockPatternUtils.saveLockPattern(
LockPatternUtils.stringToPattern(mCurrentProfilePassword),
LockPatternUtils.stringToPattern(mCurrentProfilePassword,
lockPatternUtils.getLockPatternSize(MY_USER_ID)),
mCurrentDevicePassword, MY_USER_ID);
} else {
mLockPatternUtils.saveLockPassword(
......@@ -986,6 +1018,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
keys.add(KEY_MANAGE_TRUST_AGENTS);
}
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_uiBlurEnabled)) {
keys.add(KEY_LOCK_SCREEN_BLUR_ENABLED);
}
return keys;
}
}
......@@ -997,17 +1034,20 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
private static final String KEY_DIRECTLY_SHOW_LOCK = "directly_show_lock";
// These switch preferences need special handling since they're not all stored in Settings.
private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT,
KEY_VISIBLE_PATTERN, KEY_POWER_INSTANTLY_LOCKS };
KEY_VISIBLE_PATTERN, KEY_POWER_INSTANTLY_LOCKS, KEY_DIRECTLY_SHOW_LOCK };
private TimeoutListPreference mLockAfter;
private SwitchPreference mVisiblePattern;
private SwitchPreference mPowerButtonInstantlyLocks;
private SwitchPreference mDirectlyShowLock;
private RestrictedPreference mOwnerInfoPref;
private LockPatternUtils mLockPatternUtils;
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private DevicePolicyManager mDPM;
@Override
......@@ -1019,6 +1059,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mLockPatternUtils = new LockPatternUtils(getContext());
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
mDPM = getContext().getSystemService(DevicePolicyManager.class);
createPreferenceHierarchy();
}
......@@ -1037,6 +1078,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
mPowerButtonInstantlyLocks.setChecked(mLockPatternUtils.getPowerButtonInstantlyLocks(
MY_USER_ID));
}
final CmLockPatternUtils cmLockPatternUtils = mChooseLockSettingsHelper.cmUtils();
if (mDirectlyShowLock != null) {
mDirectlyShowLock.setChecked(cmLockPatternUtils.shouldPassToSecurityView(
MY_USER_ID));
}
updateOwnerInfo();
}
......@@ -1060,6 +1106,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
ManagedLockPasswordProvider.get(getContext(), MY_USER_ID));
addPreferencesFromResource(resid);
// directly show lock
mDirectlyShowLock = (SwitchPreference) findPreference(KEY_DIRECTLY_SHOW_LOCK);
// lock after preference
mLockAfter = (TimeoutListPreference) findPreference(KEY_LOCK_AFTER_TIMEOUT);
if (mLockAfter != null) {
......@@ -1205,6 +1254,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
String key = preference.getKey();
if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value, MY_USER_ID);
} else if (KEY_DIRECTLY_SHOW_LOCK.equals(key)) {
final CmLockPatternUtils cmLockPatternUtils = mChooseLockSettingsHelper.cmUtils();
cmLockPatternUtils.setPassToSecurityView((Boolean) value, MY_USER_ID);
} else if (KEY_LOCK_AFTER_TIMEOUT.equals(key)) {
int timeout = Integer.parseInt((String) value);
try {
......
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2016 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -64,7 +65,7 @@ public class Settings extends SettingsActivity {
return true;
}
return super.isValidFragment(className);
}
}
}
public static class BackgroundCheckSummaryActivity extends SettingsActivity { /* empty */ }
public static class StorageUseActivity extends SettingsActivity { /* empty */ }
......@@ -90,6 +91,7 @@ public class Settings extends SettingsActivity {
public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
public static class DeviceAdminSettingsActivity extends SettingsActivity { /* empty */ }
public static class DataUsageSummaryActivity extends SettingsActivity { /* empty */ }
public static class RoamingSettingsActivity extends SettingsActivity { /* empty */ }
public static class AdvancedWifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class SavedAccessPointsSettingsActivity extends SettingsActivity { /* empty */ }
public static class TextToSpeechSettingsActivity extends SettingsActivity { /* empty */ }
......@@ -142,6 +144,7 @@ public class Settings extends SettingsActivity {
public static class ScreenLockSuggestionActivity extends ChooseLockGeneric { /* empty */ }
public static class WallpaperSettingsActivity extends SettingsActivity { /* empty */ }
public static class ManagedProfileSettingsActivity extends SettingsActivity { /* empty */ }
public static class TimerSwitchSettingsActivity extends SettingsActivity { /* empty */ }
public static class DeletionHelperActivity extends SettingsActivity { /* empty */ }
public static class ApnEditorActivity extends SettingsActivity { /* empty */ }
......@@ -153,6 +156,7 @@ public class Settings extends SettingsActivity {
public static class TestingSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiAPITestActivity extends SettingsActivity { /* empty */ }
public static class WifiInfoActivity extends SettingsActivity { /* empty */ }
public static class MicroGActivity extends SettingsActivity { /* empty */ }
// Categories.
public static class WirelessSettings extends SettingsActivity { /* empty */ }
......
......@@ -20,6 +20,7 @@ import android.app.ActivityManager;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.ActivityNotFoundException;
import android.app.ActionBar;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
......@@ -29,6 +30,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.nfc.NfcAdapter;
......@@ -217,16 +219,24 @@ public class SettingsActivity extends SettingsDrawerActivity
public static final String EXTRA_HIDE_DRAWER = ":settings:hide_drawer";
public static final String EXTRA_LAUNCH_ACTIVITY_ACTION = ":settings:launch_activity_action";
public static final String META_DATA_KEY_FRAGMENT_CLASS =
"com.android.settings.FRAGMENT_CLASS";
public static final String META_DATA_KEY_LAUNCH_ACTIVITY_ACTION =
"com.android.settings.ACTIVITY_ACTION";
private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
private static final String EMPTY_QUERY = "";
private static final int REQUEST_SUGGESTION = 42;
private static final String ACTION_TIMER_SWITCH = "qualcomm.intent.action.TIMER_SWITCH";
private String mFragmentClass;
private String mActivityAction;
private CharSequence mInitialTitle;
private int mInitialTitleResId;
......@@ -237,6 +247,7 @@ public class SettingsActivity extends SettingsDrawerActivity
WifiSettingsActivity.class.getName(),
Settings.BluetoothSettingsActivity.class.getName(),
Settings.DataUsageSummaryActivity.class.getName(),
Settings.RoamingSettingsActivity.class.getName(),
Settings.SimSettingsActivity.class.getName(),
Settings.WirelessSettingsActivity.class.getName(),
//device_section
......@@ -259,6 +270,7 @@ public class SettingsActivity extends SettingsDrawerActivity
Settings.AccessibilitySettingsActivity.class.getName(),
Settings.PrintSettingsActivity.class.getName(),
Settings.PaymentSettingsActivity.class.getName(),
Settings.TimerSwitchSettingsActivity.class.getName(),
};
private static final String[] ENTRY_FRAGMENTS = {
......@@ -357,7 +369,8 @@ public class SettingsActivity extends SettingsDrawerActivity
MasterClear.class.getName(),
NightDisplaySettings.class.getName(),
ManageDomainUrls.class.getName(),
AutomaticStorageManagerSettings.class.getName()
AutomaticStorageManagerSettings.class.getName(),
MicroGSettings.class.getName()
};
......@@ -528,6 +541,18 @@ public class SettingsActivity extends SettingsDrawerActivity
getMetaData();
final Intent intent = getIntent();
if (intent.hasExtra(EXTRA_LAUNCH_ACTIVITY_ACTION)) {
if (mActivityAction != null) {
try{
startActivity(new Intent(mActivityAction));
}catch(ActivityNotFoundException e){
Log.w(LOG_TAG, "Activity not found for action: " + mActivityAction);
}
}
finish();
return;
}
if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
}
......@@ -625,8 +650,8 @@ public class SettingsActivity extends SettingsDrawerActivity
} else {
// No UP affordance if we are displaying the main Dashboard
mDisplayHomeAsUpEnabled = false;
// Show Search affordance
mDisplaySearch = true;
// Show Search affordance (if device is provisioned)
mDisplaySearch = Utils.isDeviceProvisioned(this);
mInitialTitleResId = R.string.dashboard_title;
// add argument to indicate which settings tab should be initially selected
......@@ -843,10 +868,11 @@ public class SettingsActivity extends SettingsDrawerActivity
@Override
public void onDestroy() {
super.onDestroy();
mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
mDevelopmentPreferencesListener);
mDevelopmentPreferencesListener = null;
if (mDevelopmentPreferencesListener != null) {
mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
mDevelopmentPreferencesListener);
mDevelopmentPreferencesListener = null;
}
}
protected boolean isValidFragment(String fragmentName) {
......@@ -876,6 +902,12 @@ public class SettingsActivity extends SettingsDrawerActivity
args.putParcelable("intent", superIntent);
modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
return modIntent;
} else {
if (mActivityAction != null) {
Intent modIntent = new Intent(superIntent);
modIntent.putExtra(EXTRA_LAUNCH_ACTIVITY_ACTION, mActivityAction);
return modIntent;
}
}
return superIntent;
}
......@@ -1065,6 +1097,10 @@ public class SettingsActivity extends SettingsDrawerActivity
Settings.DataUsageSummaryActivity.class.getName()),
Utils.isBandwidthControlEnabled(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.RoamingSettingsActivity.class.getName()),
getResources().getBoolean(R.bool.config_roamingsettings_enabled), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.SimSettingsActivity.class.getName()),
Utils.showSimCardTile(this), isAdmin, pm);
......@@ -1091,7 +1127,6 @@ public class SettingsActivity extends SettingsDrawerActivity
pm.hasSystemFeature(PackageManager.FEATURE_NFC)
&& pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)
&& adapter != null && adapter.isEnabled(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.PrintSettingsActivity.class.getName()),
pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm);
......@@ -1106,6 +1141,18 @@ public class SettingsActivity extends SettingsDrawerActivity
// Reveal development-only quick settings tiles
DevelopmentTiles.setTilesEnabled(this, showDev);
// Show scheduled power on and off if support
boolean showTimerSwitch = false;
Intent intent = new Intent(ACTION_TIMER_SWITCH);
List<ResolveInfo> infos = getBaseContext().getPackageManager()
.queryIntentActivities(intent, 0);
if (infos != null && !infos.isEmpty()) {
showTimerSwitch = true;
}
setTileEnabled(new ComponentName(packageName,
Settings.TimerSwitchSettingsActivity.class.getName()),
showTimerSwitch, isAdmin, pm);
if (UserHandle.MU_ENABLED && !isAdmin) {
// When on restricted users, disable all extra categories (but only the settings ones).
List<DashboardCategory> categories = getDashboardCategories();
......@@ -1122,17 +1169,23 @@ public class SettingsActivity extends SettingsDrawerActivity
String backupIntent = getResources().getString(R.string.config_backup_settings_intent);
boolean useDefaultBackup = TextUtils.isEmpty(backupIntent);
// /e/ Do NOT display Backup & reset item for the moment.
useDefaultBackup = false;
setTileEnabled(new ComponentName(packageName,
Settings.PrivacySettingsActivity.class.getName()), useDefaultBackup, isAdmin, pm);
boolean hasBackupActivity = false;
if (!useDefaultBackup) {
try {
Intent intent = Intent.parseUri(backupIntent, 0);
intent = Intent.parseUri(backupIntent, 0);
hasBackupActivity = !getPackageManager().queryIntentActivities(intent, 0).isEmpty();
} catch (URISyntaxException e) {
Log.e(LOG_TAG, "Invalid backup intent URI!", e);
}
}
// /e/ Do NOT display Backup & reset item for the moment.
hasBackupActivity = false;
setTileEnabled(new ComponentName(packageName,
BackupSettingsActivity.class.getName()), hasBackupActivity,
isAdmin || Utils.isCarrierDemoUser(this), pm);
......@@ -1154,6 +1207,7 @@ public class SettingsActivity extends SettingsDrawerActivity
PackageManager.GET_META_DATA);
if (ai == null || ai.metaData == null) return;
mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
mActivityAction = ai.metaData.getString(META_DATA_KEY_LAUNCH_ACTIVITY_ACTION);
} catch (NameNotFoundException nnfe) {
// No recovery
Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString());
......@@ -1195,6 +1249,18 @@ public class SettingsActivity extends SettingsDrawerActivity
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (super.onOptionsItemSelected(item)) {
return true;
}
if (mDisplayHomeAsUpEnabled && item.getItemId() == android.R.id.home) {
finish();
return true;
}
return false;
}
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
if (item.getItemId() == mSearchMenuItem.getItemId()) {
......@@ -1271,7 +1337,8 @@ public class SettingsActivity extends SettingsDrawerActivity
}
public void startSuggestion(Intent intent) {
if (intent == null || ActivityManager.isUserAMonkey()) {
if (intent == null || ActivityManager.isUserAMonkey()
|| getPackageManager().queryIntentActivities(intent, 0).isEmpty()) {
return;
}
mCurrentSuggestion = intent.getComponent();
......
......@@ -525,6 +525,18 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
mDialogFragment = null;
}
protected void removeDialog(int dialogId, boolean stateLossAllowed) {
if (stateLossAllowed) {
if (mDialogFragment != null && mDialogFragment.getDialogId() == dialogId) {
getFragmentManager().beginTransaction().remove(mDialogFragment).
commitAllowingStateLoss();
}
mDialogFragment = null;
} else {
removeDialog(dialogId);
}
}
/**
* Sets the OnCancelListener of the dialog shown. This method can only be
* called after showDialog(int) and before removeDialog(int). The method
......@@ -758,14 +770,16 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
super.onBindViewHolder(holder, position);
if (position == mHighlightPosition) {
View v = holder.itemView;
if (v.getBackground() != null) {
final int centerX = v.getWidth() / 2;
final int centerY = v.getHeight() / 2;
v.getBackground().setHotspot(centerX, centerY);
}
v.setPressed(true);
v.setPressed(false);
mHighlightPosition = -1;
v.post(() -> {
if (v.getBackground() != null) {
final int centerX = v.getWidth() / 2;
final int centerY = v.getHeight() / 2;
v.getBackground().setHotspot(centerX, centerY);
}
v.setPressed(true);
v.setPressed(false);
mHighlightPosition = -1;
});
}
}
}
......
......@@ -138,6 +138,11 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
}
@Override
protected boolean canRunBeforeDeviceProvisioned() {
return true;
}
/***
* Disables preferences that are less secure than required quality and shows only secure
* screen lock options here.
......
......@@ -35,4 +35,6 @@ public class SubSettings extends SettingsActivity {
Log.d("SubSettings", "Launching fragment " + fragmentName);
return true;
}
public static class BluetoothSubSettings extends SubSettings { /* empty */ }
public static class SavedAccessPointsSubSettings extends SubSettings { /* empty */ }
}
......@@ -17,6 +17,7 @@
package com.android.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothPan;
......@@ -27,17 +28,25 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.hardware.usb.UsbManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.UserManager;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import com.android.internal.logging.MetricsProto.MetricsEvent;
......@@ -63,9 +72,22 @@ public class TetherSettings extends RestrictedSettingsFragment
private static final String USB_TETHER_SETTINGS = "usb_tether_settings";
private static final String ENABLE_WIFI_AP = "enable_wifi_ap";
private static final String ENABLE_WIFI_AP_EXT = "enable_wifi_ap_ext";
private static final String ENABLE_BLUETOOTH_TETHERING = "enable_bluetooth_tethering";
private static final String TETHER_CHOICE = "TETHER_TYPE";
private static final String HOTSPOT_TIMEOUT = "hotstpot_inactivity_timeout";
private static final String TETHERING_HELP = "tethering_help";
private static final String DATA_SAVER_FOOTER = "disabled_on_data_saver";
private static final String ACTION_EXTRA = "choice";
private static final String ACTION_EXTRA_VALUE = "value";
private static final String SHAREPREFERENCE_DEFAULT_WIFI = "def_wifiap_set";
private static final String SHAREPREFERENCE_FIFE_NAME = "MY_PERFS";
private static final String ACTION_HOTSPOT_CONFIGURE = "Hotspot_PreConfigure";
private static final String ACTION_HOTSPOT_POST_CONFIGURE = "Hotspot_PostConfigure";
private static final String CONFIGURE_RESULT = "PreConfigure_result";
private static final String ACTION_HOTSPOT_CONFIGURE_RRSPONSE =
"Hotspot_PreConfigure_Response";
private static final int DIALOG_AP_SETTINGS = 1;
......@@ -74,10 +96,13 @@ public class TetherSettings extends RestrictedSettingsFragment
private SwitchPreference mUsbTether;
private WifiApEnabler mWifiApEnabler;
private SwitchPreference mEnableWifiAp;
private Preference mEnableWifiAp;
private PreferenceScreen mTetherHelp;
private SwitchPreference mBluetoothTether;
private ListPreference mHotspotInactivityTimeout;
private BroadcastReceiver mTetherChangeReceiver;
private String[] mUsbRegexs;
......@@ -108,12 +133,15 @@ public class TetherSettings extends RestrictedSettingsFragment
private boolean mBluetoothEnableForTether;
/* One of INVALID, WIFI_TETHERING, USB_TETHERING or BLUETOOTH_TETHERING */
private int mTetherChoice = -1;
/* Stores the package name and the class name of the provisioning app */
private String[] mProvisionApp;
private static final int PROVISION_REQUEST = 0;
private boolean mUnavailable;
private BroadcastReceiver mConfigureReceiver;
private DataSaverBackend mDataSaverBackend;
private boolean mDataSaverEnabled;
private Preference mDataSaverFooter;
......@@ -131,6 +159,9 @@ public class TetherSettings extends RestrictedSettingsFragment
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if(icicle != null) {
mTetherChoice = icicle.getInt(TETHER_CHOICE);
}
addPreferencesFromResource(R.xml.tether_prefs);
mDataSaverBackend = new DataSaverBackend(getContext());
......@@ -151,11 +182,40 @@ public class TetherSettings extends RestrictedSettingsFragment
BluetoothProfile.PAN);
}
mEnableWifiAp =
(SwitchPreference) findPreference(ENABLE_WIFI_AP);
Preference wifiApSettings = findPreference(WIFI_AP_SSID_AND_SECURITY);
mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);
boolean enableWifiApSettingsExt = getResources().getBoolean(R.bool.show_wifi_hotspot_settings);
boolean isWifiApEnabled = getResources().getBoolean(R.bool.hide_wifi_hotspot);
checkDefaultValue(getActivity());
if (enableWifiApSettingsExt) {
mEnableWifiAp =
(HotspotPreference) findPreference(ENABLE_WIFI_AP_EXT);
getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP));
getPreferenceScreen().removePreference(mCreateNetwork);
Intent intent = new Intent();
intent.setAction("com.qti.ap.settings");
intent.setPackage("com.qualcomm.qti.extsettings");
mEnableWifiAp.setIntent(intent);
} else {
mEnableWifiAp =
(SwitchPreference) findPreference(ENABLE_WIFI_AP);
getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP_EXT));
}
if (isWifiApEnabled) {
getPreferenceScreen().removePreference(mEnableWifiAp);
getPreferenceScreen().removePreference(mCreateNetwork);
}
if (getResources().getBoolean(
R.bool.config_regional_hotspot_tether_help_enable)) {
mTetherHelp = (PreferenceScreen) findPreference(TETHERING_HELP);
} else {
getPreferenceScreen().removePreference(findPreference(TETHERING_HELP));
}
mUsbTether = (SwitchPreference) findPreference(USB_TETHER_SETTINGS);
mBluetoothTether = (SwitchPreference) findPreference(ENABLE_BLUETOOTH_TETHERING);
mHotspotInactivityTimeout = (ListPreference) findPreference(HOTSPOT_TIMEOUT);
mDataSaverBackend.addListener(this);
......@@ -179,7 +239,7 @@ public class TetherSettings extends RestrictedSettingsFragment
initWifiTethering();
} else {
getPreferenceScreen().removePreference(mEnableWifiAp);
getPreferenceScreen().removePreference(wifiApSettings);
getPreferenceScreen().removePreference(mCreateNetwork);
}
if (!bluetoothAvailable) {
......@@ -192,6 +252,7 @@ public class TetherSettings extends RestrictedSettingsFragment
mBluetoothTether.setChecked(false);
}
}
mHotspotInactivityTimeout.setOnPreferenceChangeListener(this);
// Set initial state based on Data Saver mode.
onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled());
}
......@@ -223,11 +284,12 @@ public class TetherSettings extends RestrictedSettingsFragment
final Activity activity = getActivity();
mWifiConfig = mWifiManager.getWifiApConfiguration();
mSecurityType = getResources().getStringArray(R.array.wifi_ap_security);
mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);
mRestartWifiApAfterConfigChange = false;
if (mCreateNetwork == null) {
return;
}
if (mWifiConfig == null) {
final String s = activity.getString(
com.android.internal.R.string.wifi_tether_configure_ssid_default);
......@@ -239,6 +301,25 @@ public class TetherSettings extends RestrictedSettingsFragment
mWifiConfig.SSID,
mSecurityType[index]));
}
updateHotspotTimeoutSummary(mWifiConfig);
}
private void updateHotspotTimeoutSummary(WifiConfiguration wifiConfig) {
if (wifiConfig == null) {
mHotspotInactivityTimeout.setValue("0");
mHotspotInactivityTimeout.setSummary(
getString(R.string.hotstpot_inactivity_timeout_never_summary_text));
} else {
mHotspotInactivityTimeout.setValue(Long.toString(wifiConfig.wifiApInactivityTimeout));
if (wifiConfig.wifiApInactivityTimeout > 0) {
mHotspotInactivityTimeout.setSummary(String.format(
getString(R.string.hotstpot_inactivity_timeout_summary_text,
mHotspotInactivityTimeout.getEntry())));
} else {
mHotspotInactivityTimeout.setSummary(
getString(R.string.hotstpot_inactivity_timeout_never_summary_text));
}
}
}
@Override
......@@ -356,6 +437,7 @@ public class TetherSettings extends RestrictedSettingsFragment
}
updateState();
registerConfigureReceiver(getActivity());
}
@Override
......@@ -372,6 +454,7 @@ public class TetherSettings extends RestrictedSettingsFragment
mEnableWifiAp.setOnPreferenceChangeListener(null);
mWifiApEnabler.pause();
}
unRegisterConfigureReceiver();
}
private void updateState() {
......@@ -491,12 +574,27 @@ public class TetherSettings extends RestrictedSettingsFragment
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
boolean enable = (Boolean) value;
if (preference == mEnableWifiAp) {
boolean enable = (Boolean) value;
if (enable) {
startTethering(TETHERING_WIFI);
} else {
mCm.stopTethering(TETHERING_WIFI);
if (enable) {
startTethering(TETHERING_WIFI);
} else {
mCm.stopTethering(TETHERING_WIFI);
}
return false;
} else if (preference == mHotspotInactivityTimeout) {
if (mWifiConfig != null) {
mWifiConfig.wifiApInactivityTimeout = Long.parseLong((String) value);
updateHotspotTimeoutSummary(mWifiConfig);
if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED) {
mWifiManager.setWifiApEnabled(null, false);
mWifiManager.setWifiApEnabled(mWifiConfig, true);
} else {
mWifiManager.setWifiApConfiguration(mWifiConfig);
}
return true;
}
}
return false;
}
......@@ -555,6 +653,14 @@ public class TetherSettings extends RestrictedSettingsFragment
}
} else if (preference == mCreateNetwork) {
showDialog(DIALOG_AP_SETTINGS);
} else if (getResources().getBoolean(
R.bool.config_regional_hotspot_tether_help_enable)
&& preference == mTetherHelp) {
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setTitle(R.string.tethering_help_dialog_title);
alert.setMessage(R.string.tethering_help_dialog_text);
alert.setPositiveButton(R.string.okay, null);
alert.show();
}
return super.onPreferenceTreeClick(preference);
......@@ -589,6 +695,80 @@ public class TetherSettings extends RestrictedSettingsFragment
return R.string.help_url_tether;
}
private void checkDefaultValue(Context ctx) {
boolean def_ssid = ctx.getResources().getBoolean(
R.bool.hotspot_default_ssid_with_imei_enable);
boolean clear_pwd = ctx.getResources().getBoolean( R.bool.use_empty_password_default);
if (def_ssid || clear_pwd) {
SharedPreferences sharedPreferences = ctx.getSharedPreferences(
SHAREPREFERENCE_FIFE_NAME,Activity.MODE_PRIVATE);
boolean hasSetDefaultValue = sharedPreferences.getBoolean(
SHAREPREFERENCE_DEFAULT_WIFI, false);
if ((!hasSetDefaultValue) && (setDefaultValue(ctx , def_ssid , clear_pwd))) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(SHAREPREFERENCE_DEFAULT_WIFI,true);
editor.commit();
}
}
}
private boolean setDefaultValue(Context ctx, boolean default_ssid, boolean clear_password) {
WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null) {
return false;
}
WifiConfiguration wifiAPConfig = wifiManager.getWifiApConfiguration();
if (wifiAPConfig == null) {
return false;
}
if (default_ssid) {
TelephonyManager tm = (TelephonyManager) ctx.getSystemService(
Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId();
String lastFourDigits = "";
if ((deviceId != null) && (deviceId.length() > 3)) {
lastFourDigits = deviceId.substring(deviceId.length()-4);
}
wifiAPConfig.SSID = Build.MODEL;
if ((!TextUtils.isEmpty(lastFourDigits)) && (wifiAPConfig.SSID != null)
&& (wifiAPConfig.SSID.indexOf(lastFourDigits) < 0)) {
wifiAPConfig.SSID += " " + lastFourDigits;
}
}
if (clear_password) {
wifiAPConfig.preSharedKey = "";
}
wifiManager.setWifiApConfiguration(wifiAPConfig);
return true;
}
private void unRegisterConfigureReceiver() {
if (mConfigureReceiver != null) {
getActivity().unregisterReceiver(mConfigureReceiver);
mConfigureReceiver = null;
}
}
private void registerConfigureReceiver(Context ctx) {
IntentFilter filter = new IntentFilter(ACTION_HOTSPOT_CONFIGURE_RRSPONSE);
if (mConfigureReceiver == null) {
mConfigureReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(ACTION_HOTSPOT_CONFIGURE_RRSPONSE)) {
boolean result = intent.getBooleanExtra(CONFIGURE_RESULT,true);
if (result) {
startTethering(mTetherChoice);
} else {
mWifiApEnabler.setChecked(false);
}
}
}
};
}
ctx.registerReceiver(mConfigureReceiver, filter);
}
private BluetoothProfile.ServiceListener mProfileServiceListener =
new BluetoothProfile.ServiceListener() {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
......
......@@ -740,6 +740,9 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
} catch (InterruptedException e) {
Log.e(TAG, "InterruptedException while loading aliases.", e);
return new SparseArray<List<CertHolder>>();
} catch (AssertionError e){
Log.e(TAG, "AssertionError while loading aliases.", e);
return new SparseArray<List<CertHolder>>();
}
}
@Override protected void onProgressUpdate(Integer... progressAndMax) {
......
......@@ -91,6 +91,8 @@ import android.widget.TabWidget;
import com.android.internal.app.UnlaunchableAppActivity;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.UserIcons;
import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.internal.widget.LockPatternUtils;
import java.io.IOException;
......@@ -463,6 +465,11 @@ public final class Utils extends com.android.settingslib.Utils {
.getUsers().size() > 1;
}
public static boolean isRestrictedProfile(Context context) {
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
return um.getUserInfo(um.getUserHandle()).isRestricted();
}
/**
* Start a new instance of the activity, showing only the given fragment.
* When launched in this mode, the given preference fragment will be instantiated and fill the
......@@ -583,7 +590,15 @@ public final class Utils extends com.android.settingslib.Utils {
Bundle args, String titleResPackageName, int titleResId, CharSequence title,
boolean isShortcut) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(context, SubSettings.class);
if (BluetoothSettings.class.getName().equals(fragmentName)) {
intent.setClass(context, SubSettings.BluetoothSubSettings.class);
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
} else if(SavedAccessPointsWifiSettings.class.getName().equals(fragmentName)) {
intent.setClass(context, SubSettings.SavedAccessPointsSubSettings.class);
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
}else {
intent.setClass(context, SubSettings.class);
}
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, fragmentName);
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME,
......@@ -776,7 +791,7 @@ public final class Utils extends com.android.settingslib.Utils {
static boolean isOemUnlockEnabled(Context context) {
PersistentDataBlockManager manager =(PersistentDataBlockManager)
context.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
return manager.getOemUnlockEnabled();
return manager != null && manager.getOemUnlockEnabled();
}
/**
......@@ -805,6 +820,19 @@ public final class Utils extends com.android.settingslib.Utils {
return tm.getSimCount() > 1;
}
/**
* Returns if need show the account with the given account type.
*/
public static boolean showAccount(Context context, String accountType) {
String[] hideAccounts = context.getResources().getStringArray(R.array.hide_account_list);
if (hideAccounts == null || hideAccounts.length == 0) return true;
for (String account : hideAccounts) {
if (account.equals(accountType)) return false;
}
return true;
}
/**
* Returns elapsed time for the given millis, in the following format:
* 2d 5h 40m 29s
......@@ -1208,6 +1236,27 @@ public final class Utils extends com.android.settingslib.Utils {
return false;
}
public static String join(Resources res, List<String> items) {
final int count = items.size();
if (items.isEmpty()) {
return null;
} else if (count == 1) {
return items.get(0);
} else if (count == 2) {
return res.getString(R.string.join_two_items, items.get(0), items.get(1));
} else {
String middle = items.get(count - 2);
for (int i = count - 3; i > 0; i--) {
middle = res.getString(R.string.join_many_items_middle,
items.get(i), middle);
}
final String allButLast = res.getString(R.string.join_many_items_first,
items.get(0), middle);
return res.getString(R.string.join_many_items_last, allButLast,
items.get(count - 1));
}
}
public static boolean isCarrierDemoUser(Context context) {
final String carrierDemoModeSetting =
context.getString(com.android.internal.R.string.config_carrierDemoModeSetting);
......
......@@ -22,6 +22,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -40,6 +41,7 @@ import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceScreen;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
......@@ -73,11 +75,17 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
private static final String KEY_NETWORK_RESET = "network_reset";
private static final String KEY_NFC_CATEGORY_SETTINGS = "nfc_category_settings";
private static final String KEY_NFC_PAYMENT_SETTINGS = "nfc_payment_settings";
private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
public static final int REQUEST_CODE_EXIT_ECM = 1;
private Context mContext;
private AirplaneModeEnabler mAirplaneModeEnabler;
private SwitchPreference mAirplaneModePreference;
private NfcEnabler mNfcEnabler;
......@@ -110,6 +118,20 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
return true;
} else if (preference == findPreference(KEY_MANAGE_MOBILE_PLAN)) {
onManageMobilePlanClick();
} else if (preference == findPreference(KEY_CELL_BROADCAST_SETTINGS)) {
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName(
"com.android.cellbroadcastreceiver",
"com.android.cellbroadcastreceiver.CellBroadcastSettings"));
if (mContext.getPackageManager()
.queryIntentActivities(intent, 0).isEmpty()) {
Log.d(TAG, "Activity com.android.cellbroadcastreceiver" +
".CellBroadcastSettings does not exist");
return false;
}
startActivity(intent);
return true;
}
// Let the intents be launched by the Preference manager
return super.onPreferenceTreeClick(preference);
......@@ -219,6 +241,8 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
}
log("onCreate: mManageMobilePlanMessage=" + mManageMobilePlanMessage);
mContext = getActivity();
mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mPm = getPackageManager();
......@@ -233,9 +257,12 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
SwitchPreference nfc = (SwitchPreference) findPreference(KEY_TOGGLE_NFC);
RestrictedPreference androidBeam = (RestrictedPreference) findPreference(
KEY_ANDROID_BEAM_SETTINGS);
PreferenceScreen nfcPayment = (PreferenceScreen) findPreference(KEY_NFC_PAYMENT_SETTINGS);
PreferenceCategory nfcCategory = (PreferenceCategory)
findPreference(KEY_NFC_CATEGORY_SETTINGS);
mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam, nfcPayment);
mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS);
......@@ -278,19 +305,22 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_NFC)) {
findPreference(KEY_TOGGLE_NFC).setDependency(KEY_TOGGLE_AIRPLANE);
findPreference(KEY_ANDROID_BEAM_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
findPreference(KEY_NFC_PAYMENT_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
}
// Remove NFC if not available
mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);
if (mNfcAdapter == null) {
getPreferenceScreen().removePreference(nfc);
getPreferenceScreen().removePreference(androidBeam);
getPreferenceScreen().removePreference(nfcCategory);
mNfcEnabler = null;
} else if (!mPm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
// Only show if we have the HCE feature
nfcCategory.removePreference(nfcPayment);
}
// Remove Mobile Network Settings and Manage Mobile Plan for secondary users,
// if it's a wifi-only device.
if (!isAdmin || Utils.isWifiOnly(getActivity()) ||
// if it's a wifi-only device, or for MSIM devices
if (!isAdmin || Utils.isWifiOnly(getActivity()) || Utils.showSimCardTile(getActivity()) ||
RestrictedLockUtils.hasBaseUserRestriction(activity,
UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, UserHandle.myUserId())) {
removePreference(KEY_MOBILE_NETWORK_SETTINGS);
......@@ -344,6 +374,25 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId())) {
removePreference(KEY_NETWORK_RESET);
}
// Enable link to CMAS app settings depending on the value in config.xml.
boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
com.android.internal.R.bool.config_cellBroadcastAppLinks);
try {
if (isCellBroadcastAppLinkEnabled) {
if (mPm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
}
}
} catch (IllegalArgumentException ignored) {
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
}
if (!mUm.isAdminUser() || !isCellBroadcastAppLinkEnabled ||
RestrictedLockUtils.hasBaseUserRestriction(mContext,
UserManager.DISALLOW_CONFIG_CELL_BROADCASTS, UserHandle.myUserId())) {
removePreference(KEY_CELL_BROADCAST_SETTINGS);
}
}
@Override
......@@ -366,6 +415,12 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
} else {
removePreference(KEY_WFC_SETTINGS);
}
RestrictedPreference broadcastSettingsPref = (RestrictedPreference) findPreference(
KEY_CELL_BROADCAST_SETTINGS);
if (broadcastSettingsPref != null) {
broadcastSettingsPref.checkRestrictionAndSetDisabled(
UserManager.DISALLOW_CONFIG_CELL_BROADCASTS);
}
}
@Override
......@@ -424,6 +479,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
public List<String> getNonIndexableKeys(Context context) {
final ArrayList<String> result = new ArrayList<String>();
final PackageManager pm = context.getPackageManager();
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
final boolean isSecondaryUser = !um.isAdminUser();
final boolean isWimaxEnabled = !isSecondaryUser
......@@ -445,6 +501,11 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
if (adapter == null) {
result.add(KEY_TOGGLE_NFC);
result.add(KEY_ANDROID_BEAM_SETTINGS);
result.add(KEY_NFC_PAYMENT_SETTINGS);
} else if (!pm.hasSystemFeature(
PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
// Only show if we have the HCE feature
result.add(KEY_NFC_PAYMENT_SETTINGS);
}
}
......@@ -462,8 +523,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
result.add(KEY_MANAGE_MOBILE_PLAN);
}
final PackageManager pm = context.getPackageManager();
// Remove Airplane Mode settings if it's a stationary device such as a TV.
if (pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
result.add(KEY_TOGGLE_AIRPLANE);
......@@ -489,6 +548,23 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
result.add(KEY_NETWORK_RESET);
}
// Enable link to CMAS app settings depending on the value in config.xml.
boolean isCellBroadcastAppLinkEnabled = context.getResources().getBoolean(
com.android.internal.R.bool.config_cellBroadcastAppLinks);
try {
if (isCellBroadcastAppLinkEnabled) {
if (pm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
}
}
} catch (IllegalArgumentException ignored) {
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
}
if (!um.isAdminUser() || !isCellBroadcastAppLinkEnabled) {
result.add(KEY_CELL_BROADCAST_SETTINGS);
}
return result;
}
};
......
......@@ -118,6 +118,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
AccessibilityServiceInfo info = findFirstServiceWithSpokenFeedback();
if (info == null) {
mScreenReaderPreference.setEnabled(false);
return;
} else {
mScreenReaderPreference.setEnabled(true);
}
......
......@@ -39,6 +39,8 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -55,6 +57,8 @@ import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.List;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
public class ToggleAccessibilityServicePreferenceFragment
extends ToggleFeaturePreferenceFragment implements DialogInterface.OnClickListener {
......@@ -178,6 +182,10 @@ public class ToggleAccessibilityServicePreferenceFragment
ad.create();
ad.getButton(AlertDialog.BUTTON_POSITIVE).setOnTouchListener(filterTouchListener);
Window window = ad.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.privateFlags |= PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
window.setAttributes(params);
return ad;
}
case DIALOG_ID_DISABLE_WARNING: {
......
......@@ -145,7 +145,8 @@ abstract class AccountPreferenceBase extends SettingsPreferenceFragment
AuthenticatorDescription desc = null;
try {
desc = mAuthenticatorHelper.getAccountTypeDescription(accountType);
if (desc != null && desc.accountPreferencesId != 0) {
if (desc != null && desc.accountPreferencesId != 0
&& Utils.showAccount(getActivity(), accountType)) {
// Load the context of the target package, then apply the
// base Settings theme (no references to local resources)
// and create a context theme wrapper so that we get the
......
......@@ -433,6 +433,10 @@ public class AccountSettings extends SettingsPreferenceFragment
for (int i = 0; i < accountTypes.length; i++) {
final String accountType = accountTypes[i];
if (!Utils.showAccount(getActivity(), accountType)) {
// If needn't to show the account, skip this account.
continue;
}
// Skip showing any account that does not have any of the requested authorities
if (!accountTypeHasAnyRequestedAuthorities(helper, accountType)) {
continue;
......
......@@ -42,6 +42,8 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
......@@ -55,6 +57,7 @@ import android.widget.TextView;
import com.google.android.collect.Lists;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.telephony.OperatorSimInfo;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
......@@ -85,6 +88,9 @@ public class AccountSyncSettings extends AccountPreferenceBase {
new ArrayList<SyncStateSwitchPreference>();
private ArrayList<SyncAdapterType> mInvisibleAdapters = Lists.newArrayList();
private final String SIM1_ACCOUNT_NAME = "SIM1";
private final String SIM2_ACCOUNT_NAME = "SIM2";
@Override
public Dialog onCreateDialog(final int id) {
Dialog dialog = null;
......@@ -645,6 +651,20 @@ public class AccountSyncSettings extends AccountPreferenceBase {
if (mAccount != null) {
mProviderIcon.setImageDrawable(getDrawableForType(mAccount.type));
mProviderId.setText(getLabelForType(mAccount.type));
//Sim Icon Customisation feature change
OperatorSimInfo operatorSimInfo = new OperatorSimInfo(getActivity().
getApplicationContext());
boolean isCustomSimFeatureEnabled = operatorSimInfo.
isOperatorFeatureEnabled();
if (isCustomSimFeatureEnabled) {
String accountName = mAccount.name;
if (accountName.equalsIgnoreCase(SIM1_ACCOUNT_NAME)) {
showOperatorSimIcon(0, operatorSimInfo);
} else if (accountName.equalsIgnoreCase(SIM2_ACCOUNT_NAME)) {
showOperatorSimIcon(1, operatorSimInfo);
}
}
}
}
......@@ -652,4 +672,18 @@ public class AccountSyncSettings extends AccountPreferenceBase {
protected int getHelpResource() {
return R.string.help_url_accounts;
}
private void showOperatorSimIcon(int slotIndex, OperatorSimInfo operatorSimInfo) {
boolean isSimTypeOperator = operatorSimInfo.isSimTypeOperator(slotIndex);
if (isSimTypeOperator) {
mProviderIcon.setImageDrawable(operatorSimInfo.getOperatorDrawable());
mUserId.setText(operatorSimInfo.getOperatorDisplayName());
} else {
mProviderIcon.setImageDrawable(operatorSimInfo.getGenericSimDrawable());
int subId = SubscriptionManager.getSubId(slotIndex)[0];
String operatorName = TelephonyManager.from(getActivity().
getApplicationContext()).getSimOperator(subId);
mUserId.setText(operatorName);
}
}
}
......@@ -22,6 +22,7 @@ import static android.content.Intent.EXTRA_USER;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
......@@ -136,6 +137,11 @@ public class ChooseAccountActivity extends SettingsPreferenceFragment {
// Create list of providers to show on preference screen
for (int i = 0; i < mAuthDescs.length; i++) {
String accountType = mAuthDescs[i].type;
if (!Utils.showAccount(getPreferenceScreen().getContext(), accountType)) {
// If needn't to show the account, skip this account.
continue;
}
CharSequence providerName = getLabelForType(accountType);
// Skip preferences for authorities not specified. If no authorities specified,
......@@ -165,7 +171,7 @@ public class ChooseAccountActivity extends SettingsPreferenceFragment {
}
final Context context = getPreferenceScreen().getContext();
if (mProviderList.size() == 1) {
if (mProviderList.size() == 1 && getResources().getBoolean(R.bool.config_show_email)) {
// There's only one provider that matches. If it is disabled by admin show the
// support dialog otherwise run it.
EnforcedAdmin admin = RestrictedLockUtils.checkIfAccountManagementDisabled(
......@@ -173,7 +179,7 @@ public class ChooseAccountActivity extends SettingsPreferenceFragment {
if (admin != null) {
setResult(RESULT_CANCELED, RestrictedLockUtils.getShowAdminSupportDetailsIntent(
context, admin));
finish();
finishAccountActivity();
} else {
finishWithAccountType(mProviderList.get(0).type);
}
......@@ -197,7 +203,7 @@ public class ChooseAccountActivity extends SettingsPreferenceFragment {
Log.v(TAG, "No providers found for authorities: " + auths);
}
setResult(RESULT_CANCELED);
finish();
finishAccountActivity();
}
}
......@@ -292,4 +298,13 @@ public class ChooseAccountActivity extends SettingsPreferenceFragment {
setResult(RESULT_OK, intent);
finish();
}
// SettingsPreferenceFragment finish() will cause "Recursive entry" IllegalStateException.
// Use Activity finish() directly in onCreate() call stack.
private void finishAccountActivity() {
Activity activity = getActivity();
if (activity != null) {
activity.finish();
}
}
}
......@@ -36,6 +36,7 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
import android.view.LayoutInflater;
......@@ -83,7 +84,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
// If an account type is set, then show only accounts of that type
private String mAccountType;
// Temporary hack, to deal with backward compatibility
// Temporary hack, to deal with backward compatibility
// mFirstAccount is used for the injected preferences
private Account mFirstAccount;
......@@ -369,6 +370,10 @@ public class ManageAccountsSettings extends AccountPreferenceBase
addPreferencesFromResource(R.xml.manage_accounts_settings);
for (int i = 0, n = accounts.length; i < n; i++) {
final Account account = accounts[i];
if (!Utils.showAccount(getActivity(), account.type)) {
// If needn't to show the account, skip this account.
continue;
}
// If an account type is specified for this screen, skip other types
if (mAccountType != null && !account.type.equals(mAccountType)) continue;
final ArrayList<String> auths = getAuthoritiesForAccountType(account.type);
......@@ -440,15 +445,18 @@ public class ManageAccountsSettings extends AccountPreferenceBase
}
/**
* Filters through the preference list provided by GoogleLoginService.
* Recursively filters through the preference list provided by GoogleLoginService.
*
* This method removes all the invalid intent from the list, adds account name as extra into the
* intent, and hack the location settings to start it as a fragment.
*/
private void updatePreferenceIntents(PreferenceScreen prefs) {
private void updatePreferenceIntents(PreferenceGroup prefs) {
final PackageManager pm = getActivity().getPackageManager();
for (int i = 0; i < prefs.getPreferenceCount();) {
Preference pref = prefs.getPreference(i);
if (pref instanceof PreferenceGroup) {
updatePreferenceIntents((PreferenceGroup) pref);
}
Intent intent = pref.getIntent();
if (intent != null) {
// Hack. Launch "Location" as fragment instead of as activity.
......@@ -497,8 +505,8 @@ public class ManageAccountsSettings extends AccountPreferenceBase
} else {
Log.e(TAG,
"Refusing to launch authenticator intent because"
+ "it exploits Settings permissions: "
+ prefIntent);
+ " it exploits Settings permissions: "
+ prefIntent);
}
return true;
}
......@@ -518,20 +526,26 @@ public class ManageAccountsSettings extends AccountPreferenceBase
private boolean isSafeIntent(PackageManager pm, Intent intent) {
AuthenticatorDescription authDesc =
mAuthenticatorHelper.getAccountTypeDescription(mAccountType);
ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
ResolveInfo resolveInfo =
pm.resolveActivityAsUser(intent, 0, mUserHandle.getIdentifier());
if (resolveInfo == null) {
return false;
}
ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo;
ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo;
try {
if (resolvedActivityInfo.exported) {
if (resolvedActivityInfo.permission == null) {
return true; // exported activity without permission.
} else if (pm.checkPermission(resolvedActivityInfo.permission,
authDesc.packageName) == PackageManager.PERMISSION_GRANTED) {
return true;
}
}
ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0);
return resolvedActivityInfo.exported
|| resolvedAppInfo.uid == authenticatorAppInf.uid;
return resolvedAppInfo.uid == authenticatorAppInf.uid;
} catch (NameNotFoundException e) {
Log.e(TAG,
"Intent considered unsafe due to exception.",
e);
Log.e(TAG, "Intent considered unsafe due to exception.", e);
return false;
}
}
......
......@@ -63,7 +63,10 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements
addPreferencesFromResource(R.xml.advanced_apps);
Preference permissions = getPreferenceScreen().findPreference(KEY_APP_PERM);
permissions.setIntent(new Intent(Intent.ACTION_MANAGE_PERMISSIONS));
final Intent intent = new Intent(Intent.ACTION_MANAGE_PERMISSIONS);
if (!getPackageManager().queryIntentActivities(intent, 0).isEmpty()) {
permissions.setIntent(intent);
}
ApplicationsState applicationsState = ApplicationsState.getInstance(
getActivity().getApplication());
......
......@@ -142,7 +142,8 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
PackageManager.GET_DISABLED_COMPONENTS |
PackageManager.GET_UNINSTALLED_PACKAGES |
PackageManager.GET_SIGNATURES |
PackageManager.GET_PERMISSIONS);
PackageManager.GET_PERMISSIONS |
PackageManager.GET_ACTIVITIES);
} catch (NameNotFoundException e) {
Log.e(TAG, "Exception when retrieving package:" + mAppEntry.info.packageName, e);
}
......