Convert android version dialog into a full screen UI
Bug: 112427717 Test: robotests Change-Id: I09c4130c4284670278fa7cab8a21641c663bb365
This commit is contained in:
@@ -77,7 +77,6 @@ public class MyDeviceInfoFragment extends DashboardFragment
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
use(FirmwareVersionPreferenceController.class).setHost(this /* parent */);
|
||||
use(DeviceModelPreferenceController.class).setHost(this /* parent */);
|
||||
use(ImeiInfoPreferenceController.class).setHost(this /* parent */);
|
||||
use(DeviceNamePreferenceController.class).setHost(this /* parent */);
|
||||
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.firmwareversion;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
public class BasebandVersionDialogController {
|
||||
|
||||
@VisibleForTesting
|
||||
static final int BASEBAND_VERSION_LABEL_ID = R.id.baseband_version_label;
|
||||
@VisibleForTesting
|
||||
static final int BASEBAND_VERSION_VALUE_ID = R.id.baseband_version_value;
|
||||
@VisibleForTesting
|
||||
static final String BASEBAND_PROPERTY = "gsm.version.baseband";
|
||||
|
||||
private final FirmwareVersionDialogFragment mDialog;
|
||||
|
||||
public BasebandVersionDialogController(FirmwareVersionDialogFragment dialog) {
|
||||
mDialog = dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the baseband version field of the dialog.
|
||||
*/
|
||||
public void initialize() {
|
||||
final Context context = mDialog.getContext();
|
||||
if (Utils.isWifiOnly(context)) {
|
||||
mDialog.removeSettingFromScreen(BASEBAND_VERSION_LABEL_ID);
|
||||
mDialog.removeSettingFromScreen(BASEBAND_VERSION_VALUE_ID);
|
||||
return;
|
||||
}
|
||||
|
||||
mDialog.setText(BASEBAND_VERSION_VALUE_ID, SystemProperties.get(BASEBAND_PROPERTY,
|
||||
context.getString(R.string.device_info_default)));
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.firmwareversion;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class BasebandVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
@VisibleForTesting
|
||||
static final String BASEBAND_PROPERTY = "gsm.version.baseband";
|
||||
|
||||
public BasebandVersionPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !Utils.isWifiOnly(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return SystemProperties.get(BASEBAND_PROPERTY,
|
||||
mContext.getString(R.string.device_info_default));
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -22,42 +22,61 @@ import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
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.Copyable;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
|
||||
public class FirmwareVersionDialogController implements View.OnClickListener {
|
||||
public class FirmwareVersionDetailPreferenceController extends BasePreferenceController implements
|
||||
Copyable {
|
||||
|
||||
private static final String TAG = "firmwareDialogCtrl";
|
||||
private static final int DELAY_TIMER_MILLIS = 500;
|
||||
private static final int ACTIVITY_TRIGGER_COUNT = 3;
|
||||
|
||||
@VisibleForTesting
|
||||
static final int FIRMWARE_VERSION_VALUE_ID = R.id.firmware_version_value;
|
||||
@VisibleForTesting
|
||||
static final int FIRMWARE_VERSION_LABEL_ID = R.id.firmware_version_label;
|
||||
|
||||
private final FirmwareVersionDialogFragment mDialog;
|
||||
private final Context mContext;
|
||||
private final UserManager mUserManager;
|
||||
private final long[] mHits = new long[ACTIVITY_TRIGGER_COUNT];
|
||||
|
||||
private RestrictedLockUtils.EnforcedAdmin mFunDisallowedAdmin;
|
||||
private boolean mFunDisallowedBySystem;
|
||||
|
||||
public FirmwareVersionDialogController(FirmwareVersionDialogFragment dialog) {
|
||||
mDialog = dialog;
|
||||
mContext = dialog.getContext();
|
||||
public FirmwareVersionDetailPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
initializeAdminPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return Build.VERSION.RELEASE;
|
||||
}
|
||||
|
||||
@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)) {
|
||||
@@ -67,7 +86,7 @@ public class FirmwareVersionDialogController implements View.OnClickListener {
|
||||
mFunDisallowedAdmin);
|
||||
}
|
||||
Log.d(TAG, "Sorry, no fun for you!");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent(Intent.ACTION_MAIN)
|
||||
@@ -79,21 +98,7 @@ public class FirmwareVersionDialogController implements View.OnClickListener {
|
||||
Log.e(TAG, "Unable to start activity " + intent.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the Android version field in the dialog and registers click listeners.
|
||||
*/
|
||||
public void initialize() {
|
||||
initializeAdminPermissions();
|
||||
registerClickListeners();
|
||||
|
||||
mDialog.setText(FIRMWARE_VERSION_VALUE_ID, Build.VERSION.RELEASE);
|
||||
}
|
||||
|
||||
private void registerClickListeners() {
|
||||
mDialog.registerClickListener(FIRMWARE_VERSION_LABEL_ID, this /* listener */);
|
||||
mDialog.registerClickListener(FIRMWARE_VERSION_VALUE_ID, this /* listener */);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,4 +116,10 @@ public class FirmwareVersionDialogController implements View.OnClickListener {
|
||||
mFunDisallowedBySystem = RestrictedLockUtilsInternal.hasBaseUserRestriction(
|
||||
mContext, UserManager.DISALLOW_FUN, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy() {
|
||||
Copyable.setCopyContent(mContext, getSummary(),
|
||||
mContext.getText(R.string.firmware_version));
|
||||
}
|
||||
}
|
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.firmwareversion;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
|
||||
public class FirmwareVersionDialogFragment extends InstrumentedDialogFragment {
|
||||
|
||||
private static final String TAG = "firmwareVersionDialog";
|
||||
|
||||
private View mRootView;
|
||||
|
||||
public static void show(Fragment host) {
|
||||
final FragmentManager manager = host.getChildFragmentManager();
|
||||
if (manager.findFragmentByTag(TAG) == null) {
|
||||
final FirmwareVersionDialogFragment dialog = new FirmwareVersionDialogFragment();
|
||||
dialog.show(manager, TAG);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.DIALOG_FIRMWARE_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.firmware_title)
|
||||
.setPositiveButton(android.R.string.ok, null /* listener */);
|
||||
|
||||
mRootView = LayoutInflater.from(getActivity()).inflate(
|
||||
R.layout.dialog_firmware_version, null /* parent */);
|
||||
|
||||
initializeControllers();
|
||||
|
||||
return builder.setView(mRootView).create();
|
||||
}
|
||||
|
||||
public void setText(int viewId, CharSequence text) {
|
||||
final TextView view = mRootView.findViewById(viewId);
|
||||
if (view != null) {
|
||||
view.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSettingFromScreen(int viewId) {
|
||||
final View view = mRootView.findViewById(viewId);
|
||||
if (view != null) {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerClickListener(int viewId, View.OnClickListener listener) {
|
||||
final View view = mRootView.findViewById(viewId);
|
||||
if (view != null) {
|
||||
view.setOnClickListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeControllers() {
|
||||
new FirmwareVersionDialogController(this).initialize();
|
||||
new SecurityPatchLevelDialogController(this).initialize();
|
||||
new BasebandVersionDialogController(this).initialize();
|
||||
new KernelVersionDialogController(this).initialize();
|
||||
new BuildNumberDialogController(this).initialize();
|
||||
new ModuleVersionDialogController(this).initialize();
|
||||
}
|
||||
}
|
@@ -18,56 +18,22 @@ package com.android.settings.deviceinfo.firmwareversion;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.slices.Copyable;
|
||||
|
||||
public class FirmwareVersionPreferenceController extends BasePreferenceController implements
|
||||
Copyable {
|
||||
|
||||
private Fragment mFragment;
|
||||
public class FirmwareVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
public FirmwareVersionPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
public void setHost(Fragment fragment) {
|
||||
mFragment = fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return Build.VERSION.RELEASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!TextUtils.equals(preference.getKey(), mPreferenceKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FirmwareVersionDialogFragment.show(mFragment);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy() {
|
||||
Copyable.setCopyContent(mContext, getSummary(),
|
||||
mContext.getText(R.string.firmware_version));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.firmwareversion;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class FirmwareVersionSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.firmware_version;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return "FirmwareVersionSettings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.DIALOG_FIRMWARE_VERSION;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.firmware_version;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -16,27 +16,24 @@
|
||||
|
||||
package com.android.settings.deviceinfo.firmwareversion;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.DeviceInfoUtils;
|
||||
|
||||
public class KernelVersionDialogController {
|
||||
public class KernelVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
@VisibleForTesting
|
||||
static int KERNEL_VERSION_VALUE_ID = R.id.kernel_version_value;
|
||||
|
||||
private final FirmwareVersionDialogFragment mDialog;
|
||||
|
||||
public KernelVersionDialogController(FirmwareVersionDialogFragment dialog) {
|
||||
mDialog = dialog;
|
||||
public KernelVersionPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates kernel version to the dialog.
|
||||
*/
|
||||
public void initialize() {
|
||||
mDialog.setText(KERNEL_VERSION_VALUE_ID,
|
||||
DeviceInfoUtils.getFormattedKernelVersion(mDialog.getContext()));
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return DeviceInfoUtils.getFormattedKernelVersion(mContext);
|
||||
}
|
||||
}
|
@@ -22,51 +22,51 @@ import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
public class ModuleVersionDialogController {
|
||||
public class MainlineModuleVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String TAG = "MainlineModuleControl";
|
||||
|
||||
@VisibleForTesting
|
||||
static final int MODULE_VERSION_LABEL_ID = R.id.module_version_label;
|
||||
@VisibleForTesting
|
||||
static final int MODULE_VERSION_VALUE_ID = R.id.module_version_value;
|
||||
|
||||
private final FirmwareVersionDialogFragment mDialog;
|
||||
private final Context mContext;
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
public ModuleVersionDialogController(FirmwareVersionDialogFragment dialog) {
|
||||
mDialog = dialog;
|
||||
mContext = mDialog.getContext();
|
||||
private String mModuleVersion;
|
||||
|
||||
public MainlineModuleVersionPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mPackageManager = mContext.getPackageManager();
|
||||
initModules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the mainline module version field of the dialog.
|
||||
*/
|
||||
public void initialize() {
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!FeatureFlagUtils.isEnabled(mContext, FeatureFlags.MAINLINE_MODULE)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
return !TextUtils.isEmpty(mModuleVersion) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
private void initModules() {
|
||||
if (!FeatureFlagUtils.isEnabled(mContext, FeatureFlags.MAINLINE_MODULE)) {
|
||||
mDialog.removeSettingFromScreen(MODULE_VERSION_LABEL_ID);
|
||||
mDialog.removeSettingFromScreen(MODULE_VERSION_VALUE_ID);
|
||||
return;
|
||||
}
|
||||
final String moduleProvider = mContext.getString(
|
||||
com.android.internal.R.string.config_defaultModuleMetadataProvider);
|
||||
com.android.internal.R.string.config_defaultModuleMetadataProvider);
|
||||
if (!TextUtils.isEmpty(moduleProvider)) {
|
||||
try {
|
||||
mDialog.setText(MODULE_VERSION_VALUE_ID,
|
||||
mPackageManager.getPackageInfo(moduleProvider, 0 /* flags */).versionName);
|
||||
mModuleVersion =
|
||||
mPackageManager.getPackageInfo(moduleProvider, 0 /* flags */).versionName;
|
||||
return;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Failed to get mainline version.", e);
|
||||
mModuleVersion = null;
|
||||
}
|
||||
}
|
||||
mDialog.removeSettingFromScreen(MODULE_VERSION_LABEL_ID);
|
||||
mDialog.removeSettingFromScreen(MODULE_VERSION_VALUE_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mModuleVersion;
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -22,66 +22,54 @@ import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.DeviceInfoUtils;
|
||||
|
||||
public class SecurityPatchLevelDialogController implements View.OnClickListener {
|
||||
public class SecurityPatchLevelPreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String TAG = "SecurityPatchCtrl";
|
||||
private static final Uri INTENT_URI_DATA = Uri.parse(
|
||||
"https://source.android.com/security/bulletin/");
|
||||
|
||||
@VisibleForTesting
|
||||
static final int SECURITY_PATCH_VALUE_ID = R.id.security_patch_level_value;
|
||||
@VisibleForTesting
|
||||
static final int SECURITY_PATCH_LABEL_ID = R.id.security_patch_level_label;
|
||||
|
||||
private final FirmwareVersionDialogFragment mDialog;
|
||||
private final Context mContext;
|
||||
private final PackageManager mPackageManager;
|
||||
private final String mCurrentPatch;
|
||||
|
||||
public SecurityPatchLevelDialogController(FirmwareVersionDialogFragment dialog) {
|
||||
mDialog = dialog;
|
||||
mContext = dialog.getContext();
|
||||
public SecurityPatchLevelPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mPackageManager = mContext.getPackageManager();
|
||||
mCurrentPatch = DeviceInfoUtils.getSecurityPatch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
public int getAvailabilityStatus() {
|
||||
return !TextUtils.isEmpty(mCurrentPatch)
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mCurrentPatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setData(INTENT_URI_DATA);
|
||||
if (mPackageManager.queryIntentActivities(intent, 0).isEmpty()) {
|
||||
// Don't send out the intent to stop crash
|
||||
Log.w(TAG, "Stop click action on " + SECURITY_PATCH_VALUE_ID + ": "
|
||||
+ "queryIntentActivities() returns empty");
|
||||
return;
|
||||
Log.w(TAG, "queryIntentActivities() returns empty");
|
||||
return true;
|
||||
}
|
||||
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the security patch level field in the dialog and registers click listeners.
|
||||
*/
|
||||
public void initialize() {
|
||||
if (TextUtils.isEmpty(mCurrentPatch)) {
|
||||
mDialog.removeSettingFromScreen(SECURITY_PATCH_LABEL_ID);
|
||||
mDialog.removeSettingFromScreen(SECURITY_PATCH_VALUE_ID);
|
||||
return;
|
||||
}
|
||||
registerListeners();
|
||||
mDialog.setText(SECURITY_PATCH_VALUE_ID, mCurrentPatch);
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
mDialog.registerClickListener(SECURITY_PATCH_LABEL_ID, this /* listener */);
|
||||
mDialog.registerClickListener(SECURITY_PATCH_VALUE_ID, this /* listener */);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -16,29 +16,26 @@
|
||||
|
||||
package com.android.settings.deviceinfo.firmwareversion;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.BidiFormatter;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import com.android.settings.R;
|
||||
public class SimpleBuildNumberPreferenceController extends BasePreferenceController {
|
||||
|
||||
public class BuildNumberDialogController {
|
||||
|
||||
@VisibleForTesting
|
||||
static final int BUILD_NUMBER_VALUE_ID = R.id.build_number_value;
|
||||
|
||||
private final FirmwareVersionDialogFragment mDialog;
|
||||
|
||||
public BuildNumberDialogController(FirmwareVersionDialogFragment dialog) {
|
||||
mDialog = dialog;
|
||||
public SimpleBuildNumberPreferenceController(Context context,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the build number to the dialog.
|
||||
*/
|
||||
public void initialize() {
|
||||
mDialog.setText(BUILD_NUMBER_VALUE_ID,
|
||||
BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY));
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user