summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2013-06-11 22:46:00 -0700
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-06-24 11:50:46 -0700
commit855a3fcab6da25b84e82af767a1d1afb7106a827 (patch)
tree6e57ad1ffb8b6078d3992a606367f48f7e46fba6 /src
parent4c564f53ad3c31267703457b771b5da12f6c88fe (diff)
downloadpackages_apps_Settings-855a3fcab6da25b84e82af767a1d1afb7106a827.zip
packages_apps_Settings-855a3fcab6da25b84e82af767a1d1afb7106a827.tar.gz
packages_apps_Settings-855a3fcab6da25b84e82af767a1d1afb7106a827.tar.bz2
settings: Privacy Guard support
* Add toggle to InstalledAppDetails to enable/disable privacy guard flag on a per-application basis. * Add toggle to enable privacy guard by default for applications. Change-Id: If03aa5319c520b6c4a78887f0f46ef1443ddaa83
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/SecuritySettings.java26
-rw-r--r--src/com/android/settings/applications/InstalledAppDetails.java42
2 files changed, 65 insertions, 3 deletions
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index e124fa2..b01dc74 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -40,6 +40,7 @@ import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
import android.security.KeyStore;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -93,6 +94,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String LOCKSCREEN_QUICK_UNLOCK_CONTROL = "quick_unlock_control";
private static final String KEY_VIBRATE_PREF = "lockscreen_vibrate";
private static final String KEY_SMS_SECURITY_CHECK_PREF = "sms_security_check_limit";
+ private static final String KEY_PRIVACY_GUARD_DEFAULT = "privacy_guard_default";
+ private static final String KEY_APP_SECURITY_CATEGORY = "app_security";
DevicePolicyManager mDPM;
@@ -125,6 +128,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private CheckBoxPreference mHomeUnlock;
private CheckBoxPreference mQuickUnlockScreen;
private ListPreference mSmsSecurityCheck;
+ private CheckBoxPreference mPrivacyGuardDefault;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -393,13 +397,26 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
- boolean isTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
- if (isTelephony) {
- addPreferencesFromResource(R.xml.security_settings_app_cyanogenmod);
+ // App security settings
+ addPreferencesFromResource(R.xml.security_settings_app_cyanogenmod);
+ mSmsSecurityCheck = (ListPreference) root.findPreference(KEY_SMS_SECURITY_CHECK_PREF);
+ if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
mSmsSecurityCheck = (ListPreference) root.findPreference(KEY_SMS_SECURITY_CHECK_PREF);
mSmsSecurityCheck.setOnPreferenceChangeListener(this);
int smsSecurityCheck = Integer.valueOf(mSmsSecurityCheck.getValue());
updateSmsSecuritySummary(smsSecurityCheck);
+ } else {
+ PreferenceGroup appCategory = (PreferenceGroup)
+ root.findPreference(KEY_APP_SECURITY_CATEGORY);
+ appCategory.removePreference(mSmsSecurityCheck);
+ }
+
+ mPrivacyGuardDefault = (CheckBoxPreference) findPreference(KEY_PRIVACY_GUARD_DEFAULT);
+ try {
+ mPrivacyGuardDefault.setChecked(Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.PRIVACY_GUARD_DEFAULT) == 1);
+ } catch (SettingNotFoundException e) {
+ mPrivacyGuardDefault.setChecked(false);
}
}
@@ -691,6 +708,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
} else if (KEY_TOGGLE_VERIFY_APPLICATIONS.equals(key)) {
Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_ENABLE,
mToggleVerifyApps.isChecked() ? 1 : 0);
+ } else if (KEY_PRIVACY_GUARD_DEFAULT.equals(key)) {
+ Settings.Secure.putInt(getContentResolver(), Settings.Secure.PRIVACY_GUARD_DEFAULT,
+ mPrivacyGuardDefault.isChecked() ? 1 : 0);
} else {
// If we didn't handle it, let preferences handle it.
return super.onPreferenceTreeClick(preferenceScreen, preference);
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index be515df..36adae2 100644
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -140,6 +140,7 @@ public class InstalledAppDetails extends Fragment
private Button mClearDataButton;
private Button mMoveAppButton;
private CompoundButton mNotificationSwitch;
+ private CompoundButton mPrivacyGuardSwitch;
private PackageMoveObserver mPackageMoveObserver;
@@ -179,6 +180,7 @@ public class InstalledAppDetails extends Fragment
private static final int DLG_DISABLE = DLG_BASE + 7;
private static final int DLG_DISABLE_NOTIFICATIONS = DLG_BASE + 8;
private static final int DLG_SPECIAL_DISABLE = DLG_BASE + 9;
+ private static final int DLG_PRIVACY_GUARD = DLG_BASE + 10;
// Menu identifiers
public static final int UNINSTALL_ALL_USERS_MENU = 1;
@@ -398,6 +400,13 @@ public class InstalledAppDetails extends Fragment
}
}
+ private void initPrivacyGuardButton() {
+ // TODO: We probably want to disable this optional for the built-in apps
+ boolean enabled = mPm.getPrivacyGuardSetting(mAppEntry.info.packageName);
+ mPrivacyGuardSwitch.setChecked(enabled);
+ mPrivacyGuardSwitch.setOnCheckedChangeListener(this);
+ }
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
@@ -475,6 +484,8 @@ public class InstalledAppDetails extends Fragment
mNotificationSwitch = (CompoundButton) view.findViewById(R.id.notification_switch);
+ mPrivacyGuardSwitch = (CompoundButton) view.findViewById(R.id.privacy_guard_switch);
+
return view;
}
@@ -981,6 +992,7 @@ public class InstalledAppDetails extends Fragment
initDataButtons();
initMoveButton();
initNotificationButton();
+ initPrivacyGuardButton();
} else {
mMoveAppButton.setText(R.string.moving);
mMoveAppButton.setEnabled(false);
@@ -1184,6 +1196,25 @@ public class InstalledAppDetails extends Fragment
})
.setNegativeButton(R.string.dlg_cancel, null)
.create();
+ case DLG_PRIVACY_GUARD:
+ return new AlertDialog.Builder(getActivity())
+ .setTitle(getActivity().getText(R.string.privacy_guard_dlg_title))
+ .setIconAttribute(android.R.attr.alertDialogIcon)
+ .setMessage(getActivity().getText(R.string.privacy_guard_dlg_text))
+ .setPositiveButton(R.string.dlg_ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ getOwner().setPrivacyGuard(true);
+ }
+ })
+ .setNegativeButton(R.string.dlg_cancel,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ // Re-enable the checkbox
+ getOwner().mPrivacyGuardSwitch.setChecked(false);
+ }
+ })
+ .create();
}
throw new IllegalArgumentException("unknown id " + id);
}
@@ -1273,6 +1304,11 @@ public class InstalledAppDetails extends Fragment
}
}
+ private void setPrivacyGuard(boolean enabled) {
+ String packageName = mAppEntry.info.packageName;
+ mPm.setPrivacyGuardSetting(packageName, enabled);
+ }
+
private int getPremiumSmsPermission(String packageName) {
try {
if (mSmsManager != null) {
@@ -1370,6 +1406,12 @@ public class InstalledAppDetails extends Fragment
} else {
setNotificationsEnabled(true);
}
+ } else if (buttonView == mPrivacyGuardSwitch) {
+ if (isChecked) {
+ showDialogInner(DLG_PRIVACY_GUARD, 0);
+ } else {
+ setPrivacyGuard(false);
+ }
}
}
}