From f2fdb82e9c4f396657239ae68d300510c6be4b63 Mon Sep 17 00:00:00 2001
From: MSe1969 <mse1969@posteo.de>
Date: Mon, 24 Sep 2018 21:09:57 +0200
Subject: [PATCH] Settings/DeviceInfo - Provide "patch level" explanation and
 disclaimer

Make it clear to the user, that this is an outdated, no longer
supported Android version. And that we have only backported stuff
from newer Android versions in the monthly Android security bulletins.

Change-Id: I6d706dcb598dd836c6a6f0b499782be9bd59b4dc
---
 res/values/cm_strings.xml                        |  3 +++
 res/xml/device_info_settings.xml                 |  2 +-
 src/com/android/settings/DeviceInfoSettings.java | 11 ++++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 67348ac05ac..defc226c12e 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -1463,4 +1463,7 @@ two in order to insert additional control points. \'Remove\' deletes the selecte
     <string name="lock_to_cyanogen_disable_msg">Disabling this feature will allow unauthorized users to reset your phone to factory defaults if it is stolen. Your personal data may not be protected. Do you want to disable this feature?</string>
     <string name="lock_to_cyanogen_master_clear_warning">Device Protection is enabled. Please disable to continue resetting your device.</string>
 
+    <!-- "Legacy" Security Patch label -->
+    <string name="security_patch_legacy">Unofficial security backport</string>
+    <string name="security_patch_legacy_info">There are no official security patches for this Android version anymore.\nAll patches contained in this build are backports from newer versions.</string>
 </resources>
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index bcee3a76413..9081296a8aa 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -145,7 +145,7 @@
         <!-- Security patch level -->
         <Preference android:key="security_patch"
                 style="?android:preferenceInformationStyle"
-                android:title="@string/security_patch"
+                android:title="@string/security_patch_legacy"
                 android:summary="@string/device_info_default"/>
 
         <!-- Device FCC equipment id -->
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index cc7f7020c3a..b00f545ef99 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -17,6 +17,7 @@
 package com.android.settings;
 
 import android.app.Activity;
+import android.app.AlertDialog;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
@@ -111,7 +112,7 @@ public void onCreate(Bundle icicle) {
             try {
                 SimpleDateFormat template = new SimpleDateFormat("yyyy-MM-dd");
                 Date patchDate = template.parse(patch);
-                String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "dMMMMyyyy");
+                String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMMMyyyy");
                 patch = DateFormat.format(format, patchDate).toString();
             } catch (ParseException e) {
                 // broken parse; fall through and use the raw string
@@ -131,6 +132,7 @@ public void onCreate(Bundle icicle) {
         setValueSummary(KEY_MOD_VERSION, "ro.cm.display.version");
         findPreference(KEY_MOD_VERSION).setEnabled(true);
         setValueSummary(KEY_MOD_BUILD_DATE, "ro.build.date");
+        findPreference(KEY_SECURITY_PATCH).setEnabled(true);
 
         if (!SELinux.isSELinuxEnabled()) {
             String status = getResources().getString(R.string.selinux_status_disabled);
@@ -306,6 +308,13 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
                     Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
                 }
             }
+        } else if (preference.getKey().equals(KEY_SECURITY_PATCH)) {
+            new AlertDialog.Builder(getActivity())
+                .setTitle(R.string.security_patch)
+                .setIcon(android.R.drawable.ic_dialog_alert)
+                .setMessage(R.string.security_patch_legacy_info)
+                .setNegativeButton(R.string.cancel, null)
+                .create().show();
         }
         return super.onPreferenceTreeClick(preferenceScreen, preference);
     }
