Convert android version dialog into a full screen UI
Bug: 112427717 Test: robotests Change-Id: I09c4130c4284670278fa7cab8a21641c663bb365
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
|
||||
public class MainlineModuleVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String TAG = "MainlineModuleControl";
|
||||
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
private String mModuleVersion;
|
||||
|
||||
public MainlineModuleVersionPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mPackageManager = mContext.getPackageManager();
|
||||
initModules();
|
||||
}
|
||||
|
||||
@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)) {
|
||||
return;
|
||||
}
|
||||
final String moduleProvider = mContext.getString(
|
||||
com.android.internal.R.string.config_defaultModuleMetadataProvider);
|
||||
if (!TextUtils.isEmpty(moduleProvider)) {
|
||||
try {
|
||||
mModuleVersion =
|
||||
mPackageManager.getPackageInfo(moduleProvider, 0 /* flags */).versionName;
|
||||
return;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Failed to get mainline version.", e);
|
||||
mModuleVersion = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mModuleVersion;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user