Settings: Show full proc/version information
patch set 2: view unformatted kernel version on clicking the formatted kernel version [ Stallix - Evo X ] * Adapted for KernelVersionPreferenceController on Pie Change-Id: I2b211fb72c25cc119f2a464b04821fcef77a8908 Signed-off-by: Arghya Chanda <arghyac35@gmail.com> Signed-off-by: SagarMakhar <sagarmakhar@gmail.com> Signed-off-by: Joey Huab <joey@evolution-x.org> Signed-off-by: AnierinB <anierin@evolution-x.org>
This commit is contained in:
@@ -84,7 +84,6 @@
|
||||
android:key="kernel_version"
|
||||
android:title="@string/kernel_version"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:selectable="false"
|
||||
settings:enableCopying="true"
|
||||
settings:controller="com.android.settings.deviceinfo.firmwareversion.KernelVersionPreferenceController"/>
|
||||
|
||||
|
||||
@@ -20,10 +20,21 @@ import android.content.Context;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.DeviceInfoUtils;
|
||||
import androidx.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
// LINT.IfChange
|
||||
public class KernelVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String KEY_KERNEL_VERSION = "kernel_version";
|
||||
private static final String FILENAME_PROC_VERSION = "/proc/version";
|
||||
private static final String LOG_TAG = "KernelVersionPreferenceController";
|
||||
|
||||
public KernelVersionPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
@@ -37,5 +48,46 @@ public class KernelVersionPreferenceController extends BasePreferenceController
|
||||
public CharSequence getSummary() {
|
||||
return DeviceInfoUtils.getFormattedKernelVersion(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_KERNEL_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!TextUtils.equals(preference.getKey(), KEY_KERNEL_VERSION)) {
|
||||
return false;
|
||||
}
|
||||
preference.setSummary(getFullKernelVersion());
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getFullKernelVersion() {
|
||||
String procVersionStr;
|
||||
try {
|
||||
procVersionStr = readLine(FILENAME_PROC_VERSION);
|
||||
return procVersionStr;
|
||||
} catch (IOException e) {
|
||||
Log.e(LOG_TAG,
|
||||
"IO Exception when getting kernel version for Device Info screen", e);
|
||||
return "Unavailable";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a line from the specified file.
|
||||
* @param filename the file to read from
|
||||
* @return the first line, if any.
|
||||
* @throws IOException if the file couldn't be read
|
||||
*/
|
||||
private static String readLine(String filename) throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filename), 256);
|
||||
try {
|
||||
return reader.readLine();
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
// LINT.ThenChange(KernelVersionPreference.kt)
|
||||
|
||||
Reference in New Issue
Block a user