summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuK1337 <priv.luk@gmail.com>2018-08-26 15:00:21 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-12-01 13:33:56 +0100
commit1d45f6658f7ec4ced6470e878432bac124f767fc (patch)
tree43cae824f0cf6f3b7305ffdc46ca472e29a61329
parent3403005e833ca7eda968e72ae99c2b92653d8a78 (diff)
downloadpackages_apps_Settings-history/replicant-11-lineage-sdk.tar.gz
packages_apps_Settings-history/replicant-11-lineage-sdk.tar.bz2
packages_apps_Settings-history/replicant-11-lineage-sdk.zip
Settings: Add LineageOS entries into device infohistory/replicant-11-lineage-sdk
Author: Harry Youd <harry@harryyoud.co.uk> Date: Fri Nov 24 09:49:51 2017 -0800 Settings: Add LineageOS version, API level and build date to device info Change-Id: I4acf834442712954f8e9db15370bffafd4547174 Author: Tobias Tefke <tobias.tefke@tutanota.com> Date: Wed Jun 13 11:27:22 2018 +0200 [1/2] Add vendor security patch level to device info Change-Id: I523fcce65cc4155591c12ea1ac04807ebfc5c716 Change-Id: I8d4c6869f8dfa34a96567bec18f9f8276b66a64e
-rw-r--r--res/xml/firmware_version.xml39
-rw-r--r--src/com/android/settings/deviceinfo/firmwareversion/LineageApiVersionPreferenceController.java44
-rw-r--r--src/com/android/settings/deviceinfo/firmwareversion/LineageBuildDatePreferenceController.java45
-rw-r--r--src/com/android/settings/deviceinfo/firmwareversion/LineageVendorSecurityPatchLevelPreferenceController.java73
-rw-r--r--src/com/android/settings/deviceinfo/firmwareversion/LineageVersionDetailPreferenceController.java136
5 files changed, 337 insertions, 0 deletions
diff --git a/res/xml/firmware_version.xml b/res/xml/firmware_version.xml
index edc910b36c..fe8fd0deb0 100644
--- a/res/xml/firmware_version.xml
+++ b/res/xml/firmware_version.xml
@@ -30,6 +30,22 @@
settings:searchable="false"
settings:controller="com.android.settings.deviceinfo.firmwareversion.FirmwareVersionDetailPreferenceController"/>
+ <!-- Lineage version -->
+ <Preference
+ android:key="lineage_version"
+ android:title="@*lineageos.platform:string/lineage_version"
+ android:summary="@string/summary_placeholder"
+ settings:enableCopying="true"
+ settings:controller="com.android.settings.deviceinfo.firmwareversion.LineageVersionDetailPreferenceController"/>
+
+ <!-- Lineage API version -->
+ <Preference
+ android:key="lineage_api_version"
+ android:title="@*lineageos.platform:string/lineage_api_level"
+ android:summary="@string/summary_placeholder"
+ settings:enableCopying="true"
+ settings:controller="com.android.settings.deviceinfo.firmwareversion.LineageApiVersionPreferenceController"/>
+
<!-- Security patch -->
<Preference
android:key="security_key"
@@ -37,6 +53,21 @@
settings:enableCopying="true"
settings:controller="com.android.settings.deviceinfo.firmwareversion.SecurityPatchLevelPreferenceController"/>
+ <!-- Vendor security patch -->
+ <Preference
+ android:key="vendor_security_key"
+ android:title="@*lineageos.platform:string/lineage_vendor_security_patch"
+ settings:enableCopying="true"
+ settings:controller="com.android.settings.deviceinfo.firmwareversion.LineageVendorSecurityPatchLevelPreferenceController"/>
+
+ <!-- Mainline module version -->
+ <Preference
+ android:key="module_version"
+ android:title="@string/module_version"
+ android:summary="@string/summary_placeholder"
+ settings:enableCopying="true"
+ settings:controller="com.android.settings.deviceinfo.firmwareversion.MainlineModuleVersionPreferenceController"/>
+
<!-- Baseband -->
<Preference
android:key="base_band"
@@ -55,6 +86,14 @@
settings:enableCopying="true"
settings:controller="com.android.settings.deviceinfo.firmwareversion.KernelVersionPreferenceController"/>
+ <!-- Build date -->
+ <Preference
+ android:key="os_build_date"
+ android:title="@*lineageos.platform:string/build_date"
+ android:summary="@string/summary_placeholder"
+ settings:enableCopying="true"
+ settings:controller="com.android.settings.deviceinfo.firmwareversion.LineageBuildDatePreferenceController"/>
+
<!-- Build -->
<Preference
android:key="os_build_number"
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/LineageApiVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/LineageApiVersionPreferenceController.java
new file mode 100644
index 0000000000..9650d2b470
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/firmwareversion/LineageApiVersionPreferenceController.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.firmwareversion;
+
+import android.content.Context;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class LineageApiVersionPreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "LineageApiVersionCtrl";
+
+ public LineageApiVersionPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ final int sdk = lineageos.os.Build.LINEAGE_VERSION.SDK_INT;
+ StringBuilder builder = new StringBuilder();
+ builder.append(lineageos.os.Build.getNameForSDKInt(sdk))
+ .append(" (" + sdk + ")");
+ return builder.toString();
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/LineageBuildDatePreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/LineageBuildDatePreferenceController.java
new file mode 100644
index 0000000000..468ea5e5dd
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/firmwareversion/LineageBuildDatePreferenceController.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.firmwareversion;
+
+import android.content.Context;
+import android.os.SystemProperties;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+public class LineageBuildDatePreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "LineageBuildDateCtrl";
+
+ private static final String KEY_BUILD_DATE_PROP = "ro.build.date";
+
+ public LineageBuildDatePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return SystemProperties.get(KEY_BUILD_DATE_PROP,
+ mContext.getString(R.string.unknown));
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/LineageVendorSecurityPatchLevelPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/LineageVendorSecurityPatchLevelPreferenceController.java
new file mode 100644
index 0000000000..40887ee580
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/firmwareversion/LineageVendorSecurityPatchLevelPreferenceController.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.firmwareversion;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.text.format.DateFormat;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+public class LineageVendorSecurityPatchLevelPreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "LineageVendorSecurityPatchCtrl";
+
+ private static final String KEY_AOSP_VENDOR_SECURITY_PATCH =
+ "ro.vendor.build.security_patch";
+
+ private static final String KEY_LINEAGE_VENDOR_SECURITY_PATCH =
+ "ro.lineage.build.vendor_security_patch";
+
+ public LineageVendorSecurityPatchLevelPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ String patchLevel = SystemProperties.get(KEY_AOSP_VENDOR_SECURITY_PATCH);
+
+ if (patchLevel.isEmpty()) {
+ patchLevel = SystemProperties.get(KEY_LINEAGE_VENDOR_SECURITY_PATCH);
+ }
+
+ if (!patchLevel.isEmpty()) {
+ try {
+ SimpleDateFormat template = new SimpleDateFormat("yyyy-MM-dd");
+ Date patchLevelDate = template.parse(patchLevel);
+ String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "dMMMMyyyy");
+ patchLevel = DateFormat.format(format, patchLevelDate).toString();
+ } catch (ParseException e) {
+ // parsing failed, use raw string
+ }
+ } else {
+ patchLevel = mContext.getString(R.string.unknown);
+ }
+
+ return patchLevel;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/LineageVersionDetailPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/LineageVersionDetailPreferenceController.java
new file mode 100644
index 0000000000..3cd42a77ab
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/firmwareversion/LineageVersionDetailPreferenceController.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.firmwareversion;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.SystemClock;
+import android.os.SystemProperties;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.slices.Sliceable;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtilsInternal;
+
+public class LineageVersionDetailPreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "lineageVersionDialogCtrl";
+ private static final int DELAY_TIMER_MILLIS = 500;
+ private static final int ACTIVITY_TRIGGER_COUNT = 3;
+
+ private static final String KEY_LINEAGE_VERSION_PROP = "ro.lineage.version";
+
+ private static final String PLATLOGO_PACKAGE_NAME = "org.lineageos.lineageparts";
+ private static final String PLATLOGO_ACTIVITY_CLASS =
+ PLATLOGO_PACKAGE_NAME + ".logo.PlatLogoActivity";
+
+ private final UserManager mUserManager;
+ private final long[] mHits = new long[ACTIVITY_TRIGGER_COUNT];
+
+ private RestrictedLockUtils.EnforcedAdmin mFunDisallowedAdmin;
+ private boolean mFunDisallowedBySystem;
+
+ public LineageVersionDetailPreferenceController(Context context, String key) {
+ super(context, key);
+ mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ initializeAdminPermissions();
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return SystemProperties.get(KEY_LINEAGE_VERSION_PROP,
+ mContext.getString(R.string.unknown));
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+ return false;
+ }
+ if (Utils.isMonkeyRunning()) {
+ return false;
+ }
+ arrayCopy();
+ mHits[mHits.length - 1] = SystemClock.uptimeMillis();
+ if (mHits[0] >= (SystemClock.uptimeMillis() - DELAY_TIMER_MILLIS)) {
+ if (mUserManager.hasUserRestriction(UserManager.DISALLOW_FUN)) {
+ if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext,
+ mFunDisallowedAdmin);
+ }
+ Log.d(TAG, "Sorry, no fun for you!");
+ return true;
+ }
+
+ final Intent intent = new Intent(Intent.ACTION_MAIN)
+ .setClassName(PLATLOGO_PACKAGE_NAME, PLATLOGO_ACTIVITY_CLASS);
+ try {
+ mContext.startActivity(intent);
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to start activity " + intent.toString());
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Copies the array onto itself to remove the oldest hit.
+ */
+ @VisibleForTesting
+ void arrayCopy() {
+ System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
+ }
+
+ @VisibleForTesting
+ void initializeAdminPermissions() {
+ mFunDisallowedAdmin = RestrictedLockUtilsInternal.checkIfRestrictionEnforced(
+ mContext, UserManager.DISALLOW_FUN, UserHandle.myUserId());
+ mFunDisallowedBySystem = RestrictedLockUtilsInternal.hasBaseUserRestriction(
+ mContext, UserManager.DISALLOW_FUN, UserHandle.myUserId());
+ }
+
+ @Override
+ public void copy() {
+ Sliceable.setCopyContent(mContext, getSummary(),
+ mContext.getText(org.lineageos.platform.internal.R.string.lineage_version));
+ }
+}