Settings: Add platform and RAM to Model & Hardware
This seems kinda empty... Fill it with fun stuff Change-Id: Ia43cb31b7567bed07f2b8a1d8637de4e66320c90 [jaysonedson@gmail.com: Move to new HardwareInfo] Signed-off-by: Jason Edson <jaysonedson@gmail.com> Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
@@ -82,4 +82,8 @@
|
||||
<string name="wifi_per_connection_random_mac_addr">Use per-connection randomized MAC (default)</string>
|
||||
<string name="wifi_per_network_random_mac_addr">Use per-network randomized MAC</string>
|
||||
<string name="wifi_device_mac_addr">Use device MAC</string>
|
||||
|
||||
<!-- Hardware info -->
|
||||
<string name="platform_revision">Platform</string>
|
||||
<string name="total_ram">Total RAM</string>
|
||||
</resources>
|
||||
|
||||
@@ -30,6 +30,24 @@
|
||||
settings:controller="com.android.settings.deviceinfo.hardwareinfo.DeviceModelPreferenceController"
|
||||
settings:enableCopying="true"/>
|
||||
|
||||
<!-- Platform -->
|
||||
<Preference
|
||||
android:key="hardware_info_platform"
|
||||
android:title="@string/platform_revision"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:selectable="false"
|
||||
settings:controller="com.android.settings.deviceinfo.hardwareinfo.PlatformRevisionPreferenceController"
|
||||
settings:enableCopying="true"/>
|
||||
|
||||
<!-- Total RAM -->
|
||||
<Preference
|
||||
android:key="hardware_info_ram"
|
||||
android:title="@string/total_ram"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:selectable="false"
|
||||
settings:controller="com.android.settings.deviceinfo.hardwareinfo.TotalRAMPreferenceController"
|
||||
settings:enableCopying="true"/>
|
||||
|
||||
<!-- SerialNumber -->
|
||||
<Preference
|
||||
android:key="hardware_info_device_serial"
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source 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.hardwareinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.slices.Sliceable;
|
||||
|
||||
public class PlatformRevisionPreferenceController extends BasePreferenceController {
|
||||
|
||||
public PlatformRevisionPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_device_model)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useDynamicSliceSummary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return SystemProperties.get("ro.board.platform");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source 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.hardwareinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.Formatter;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.ProcStatsData;
|
||||
import com.android.settings.applications.ProcessStatsBase;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
public class TotalRAMPreferenceController extends BasePreferenceController implements
|
||||
PreferenceControllerMixin {
|
||||
|
||||
private ProcStatsData mProcStatsData;
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
|
||||
public TotalRAMPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_device_model)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
|
||||
mProcStatsData = getProcStatsData();
|
||||
mPreferenceScreen = screen;
|
||||
setDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
// This is posted on the background thread to speed up fragment launch time for dev options
|
||||
// mProcStasData.refreshStats(true) takes ~20ms to run.
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
mProcStatsData.refreshStats(true);
|
||||
final ProcStatsData.MemInfo memInfo = mProcStatsData.getMemInfo();
|
||||
final String totalResult = Formatter.formatShortFileSize(mContext,
|
||||
(long) memInfo.realTotalRam);
|
||||
ThreadUtils.postOnMainThread(
|
||||
() -> mPreferenceScreen.findPreference(mPreferenceKey).setSummary(totalResult));
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setDuration() {
|
||||
mProcStatsData.setDuration(ProcessStatsBase.sDurations[0] /* 3 hours */);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
ProcStatsData getProcStatsData() {
|
||||
return new ProcStatsData(mContext, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user