summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/layout/installed_app_details.xml8
-rw-r--r--res/values/cm_strings.xml7
-rw-r--r--res/values/strings.xml4
-rw-r--r--res/xml/security_settings_app_cyanogenmod.xml6
-rw-r--r--src/com/android/settings/SecuritySettings.java26
-rw-r--r--src/com/android/settings/applications/InstalledAppDetails.java42
7 files changed, 89 insertions, 5 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index de3b0b1..4939009 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -63,6 +63,7 @@
<uses-permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SET_TIME" />
+ <uses-permission android:name="android.permission.CHANGE_PRIVACY_GUARD_STATE" />
<permission
android:name="android.permission.REQUEST_SUPERUSER"
diff --git a/res/layout/installed_app_details.xml b/res/layout/installed_app_details.xml
index b7f8f15..577cfd4 100644
--- a/res/layout/installed_app_details.xml
+++ b/res/layout/installed_app_details.xml
@@ -62,6 +62,14 @@
android:layout_marginTop="4dip"
android:text="@string/app_notifications_switch_label" />
+ <!-- Enable Privacy Guard for an application -->
+ <CheckBox android:id="@+id/privacy_guard_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start"
+ android:layout_marginTop="4dip"
+ android:text="@string/privacy_guard_switch_label" />
+
</LinearLayout>
<TextView
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 80eb7a4..9396d75 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -959,4 +959,11 @@ two in order to insert additional control points. \'Remove\' deletes the selecte
<!-- Delete apn confirmation dialog message -->
<string name="confirm_delete_apn">The APN will be deleted.</string>
+ <!-- Privacy Guard -->
+ <string name="privacy_guard_switch_label">Enable Privacy Guard</string>
+ <string name="privacy_guard_dlg_title">Enable Privacy Guard?</string>
+ <string name="privacy_guard_dlg_text">When Privacy Guard is enabled, the app will not be able to access personal data such as contacts, messages, or call logs.</string>
+ <string name="privacy_guard_default_title">Privacy Guard</string>
+ <string name="privacy_guard_default_summary">Enable Privacy Guard by default for newly-installed apps</string>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index edde20f..912782d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2550,7 +2550,8 @@
<li>Disabled apps</li>\n
<li>Disabled app notifications</li>\n
<li>Default applications for actions</li>\n
- <li>Background data restrictions for apps</li>\n\n
+ <li>Background data restrictions for apps</li>\n
+ <li>Privacy guard</li>\n\n
You will not lose any app data.</string>
<!-- [CHAR LIMIT=25] Manage applications screen, menu item. Confirmation button of dialog to confirm resetting user's app preferences. -->
<string name="reset_app_preferences_button">Reset apps</string>
@@ -2695,7 +2696,6 @@
<string name="app_disable_notifications_dlg_text">
If you turn off notifications for this app, you may miss important alerts and updates.
</string>
-
<!-- [CHAR LIMIT=25] Services settings screen, setting option name for the user to go to the screen to view app storage use -->
<string name="storageuse_settings_title">Storage use</string>
<!-- Services settings screen, setting option summary for the user to go to the screen to app storage use -->
diff --git a/res/xml/security_settings_app_cyanogenmod.xml b/res/xml/security_settings_app_cyanogenmod.xml
index 8aaddcd..fbaf10b 100644
--- a/res/xml/security_settings_app_cyanogenmod.xml
+++ b/res/xml/security_settings_app_cyanogenmod.xml
@@ -21,6 +21,12 @@
android:key="app_security"
android:title="@string/app_security_title">
+ <CheckBoxPreference
+ android:key="privacy_guard_default"
+ android:title="@string/privacy_guard_default_title"
+ android:summary="@string/privacy_guard_default_summary"
+ android:persistent="false" />
+
<ListPreference
android:key="sms_security_check_limit"
android:dialogTitle="@string/sms_security_check_limit_title"
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);
+ }
}
}
}