Skip to contentSkip to conversation

Initial support for translatable SEAndroid strings

PATCH New William Roberts 2 participants 3 messages Jul 18, 2012 – Jul 19, 2012 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Initial support for translatable SEAndroid strings

This patch is to start addressing the concerns of Google when adding support for the selinux status in the Settings app. They want the strings in the resource file. If you look at the per language resource directory, they have strings.xml where strings have msgid fields. I have been scouring the net trying to figure out how these are generated so I can move onto finishing the multilanguage support, does anyone know how to generate msgid values and do multilanguage support in general?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw

PATCH 1/1 Initial support for translatable SEAndroid strings

---
 res/values/strings.xml                           |    5 +++++
 src/com/android/settings/DeviceInfoSettings.java |   14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
res/values/strings.xml +5 -0
index fb70aa2..2d2f028 100644
@@ -3785,5 +3785,10 @@ found in the list of installed apps.</string>
     from their cell phone carrier. The use of the string is similar to the string
     "system_update_settings_list_item_title" in this project. [CHAR LIMIT=25] -->
     <string name="additional_system_update_settings_list_item_title">Additional system updates</string>
+    <!-- SELinux statuses that are displayed if the user has a SE Android enabled
+    device. These are displayed by the settings app in the about section. -->
+    <string name="selinux_status_disabled">"Disabled"</string>
+    <string name="selinux_status_permissive">"Permissive"</string>
+    <string name="selinux_status_enforcing">"Enforcing"</string>
 
 </resources>
src/com/android/settings/DeviceInfoSettings.java +11 -3
index c2418b6..a8a5510 100644
@@ -55,6 +55,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
     private static final String KEY_COPYRIGHT = "copyright";
     private static final String KEY_SYSTEM_UPDATE_SETTINGS = "system_update_settings";
     private static final String PROPERTY_URL_SAFETYLEGAL = "ro.url.safetylegal";
+    private static final String PROPERTY_SELINUX_STATUS = "ro.build.selinux";
     private static final String KEY_KERNEL_VERSION = "kernel_version";
     private static final String KEY_BUILD_NUMBER = "build_number";
     private static final String KEY_DEVICE_MODEL = "device_model";
@@ -77,14 +78,21 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
         setStringSummary(KEY_DEVICE_MODEL, Build.MODEL + getMsvSuffix());
         setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY);
         findPreference(KEY_KERNEL_VERSION).setSummary(getFormattedKernelVersion());
+
         if (!SELinux.isSELinuxEnabled()) {
-            setStringSummary(KEY_SELINUX_STATUS, "disabled");
+            String status = getResources().getString(R.string.selinux_status_disabled);
+            setStringSummary(KEY_SELINUX_STATUS, status);
         } else if (!SELinux.isSELinuxEnforced()) {
-            setStringSummary(KEY_SELINUX_STATUS, "permissive");
+            String status = getResources().getString(R.string.selinux_status_permissive);
+            setStringSummary(KEY_SELINUX_STATUS, status);
         } else {
-            setStringSummary(KEY_SELINUX_STATUS, "enforcing");
+            String status = getResources().getString(R.string.selinux_status_enforcing);
+            setStringSummary(KEY_SELINUX_STATUS, status);
         }
 
+        // Remove selinux information if property is not present
+        removePreferenceIfPropertyMissing(getPreferenceScreen(), "selinux_status", PROPERTY_SELINUX_STATUS);
+
         // Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
         removePreferenceIfPropertyMissing(getPreferenceScreen(), "safetylegal",
                 PROPERTY_URL_SAFETYLEGAL);
Signature · 7 lines
1.7.0.4


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

src/com/android/settings/DeviceInfoSettings.java public class DeviceInfoSettings extends SettingsPreferenceFragment { · line 95

Quoted 9 lines · William Roberts
---
 res/values/strings.xml                           |    5 +++++
 src/com/android/settings/DeviceInfoSettings.java |   14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
src/com/android/settings/DeviceInfoSettings.java +3 -0
+        // Remove selinux information if property is not present
+        removePreferenceIfPropertyMissing(getPreferenceScreen(), "selinux_status", PROPERTY_SELINUX_STATUS);
+

Any particular reason for not using KEY_SELINUX_STATUS rather than the inlined "selinux_status" string above?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.