DO NOT MERGE - Merge build QP1A.190711.019 into stage-aosp-master
Bug: 139893257 Change-Id: I54b340294458df6016b7893838e1b0f6e61daf11
This commit is contained in:
@@ -10666,13 +10666,11 @@
|
|||||||
<string-array name="game_driver_all_apps_preference_values">
|
<string-array name="game_driver_all_apps_preference_values">
|
||||||
<item>@string/game_driver_app_preference_default</item>
|
<item>@string/game_driver_app_preference_default</item>
|
||||||
<item>@string/game_driver_app_preference_game_driver</item>
|
<item>@string/game_driver_app_preference_game_driver</item>
|
||||||
<item>@string/game_driver_app_preference_prerelease_driver</item>
|
|
||||||
</string-array>
|
</string-array>
|
||||||
<!-- All the values for Game Driver app preference [CHAR LIMIT=50] -->
|
<!-- All the values for Game Driver app preference [CHAR LIMIT=50] -->
|
||||||
<string-array name="game_driver_app_preference_values">
|
<string-array name="game_driver_app_preference_values">
|
||||||
<item>@string/game_driver_app_preference_default</item>
|
<item>@string/game_driver_app_preference_default</item>
|
||||||
<item>@string/game_driver_app_preference_game_driver</item>
|
<item>@string/game_driver_app_preference_game_driver</item>
|
||||||
<item>@string/game_driver_app_preference_prerelease_driver</item>
|
|
||||||
<item>@string/game_driver_app_preference_system</item>
|
<item>@string/game_driver_app_preference_system</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@@ -182,8 +182,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
|||||||
void showFinalConfirmation() {
|
void showFinalConfirmation() {
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
||||||
args.putBoolean(ERASE_ESIMS_EXTRA,
|
args.putBoolean(ERASE_ESIMS_EXTRA, mEsimStorage.isChecked());
|
||||||
mEsimStorageContainer.getVisibility() == View.VISIBLE && mEsimStorage.isChecked());
|
|
||||||
new SubSettingLauncher(getContext())
|
new SubSettingLauncher(getContext())
|
||||||
.setDestination(MasterClearConfirm.class.getName())
|
.setDestination(MasterClearConfirm.class.getName())
|
||||||
.setArguments(args)
|
.setArguments(args)
|
||||||
|
@@ -119,7 +119,8 @@ public class RegulatoryInfoDisplayActivity extends Activity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getResourceId() {
|
@VisibleForTesting
|
||||||
|
int getResourceId() {
|
||||||
// Use regulatory_info by default.
|
// Use regulatory_info by default.
|
||||||
int resId = getResources().getIdentifier(
|
int resId = getResources().getIdentifier(
|
||||||
REGULATORY_INFO_RESOURCE, "drawable", getPackageName());
|
REGULATORY_INFO_RESOURCE, "drawable", getPackageName());
|
||||||
@@ -134,6 +135,18 @@ public class RegulatoryInfoDisplayActivity extends Activity implements
|
|||||||
resId = id;
|
resId = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When hardware coo property exists, use regulatory_info_<sku>_<coo> resource if valid.
|
||||||
|
final String coo = getCoo();
|
||||||
|
if (!TextUtils.isEmpty(coo) && !TextUtils.isEmpty(sku)) {
|
||||||
|
final String regulatory_info_coo_res =
|
||||||
|
REGULATORY_INFO_RESOURCE + "_" + sku.toLowerCase() + "_" + coo.toLowerCase();
|
||||||
|
final int id = getResources().getIdentifier(
|
||||||
|
regulatory_info_coo_res, "drawable", getPackageName());
|
||||||
|
if (id != 0) {
|
||||||
|
resId = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
return resId;
|
return resId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,13 +155,15 @@ public class RegulatoryInfoDisplayActivity extends Activity implements
|
|||||||
finish(); // close the activity
|
finish(); // close the activity
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private String getCoo() {
|
||||||
public static String getSku() {
|
return SystemProperties.get("ro.boot.hardware.coo", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSku() {
|
||||||
return SystemProperties.get("ro.boot.hardware.sku", "");
|
return SystemProperties.get("ro.boot.hardware.sku", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private String getRegulatoryInfoImageFileName() {
|
||||||
public static String getRegulatoryInfoImageFileName() {
|
|
||||||
final String sku = getSku();
|
final String sku = getSku();
|
||||||
if (TextUtils.isEmpty(sku)) {
|
if (TextUtils.isEmpty(sku)) {
|
||||||
return DEFAULT_REGULATORY_INFO_FILEPATH;
|
return DEFAULT_REGULATORY_INFO_FILEPATH;
|
||||||
|
@@ -20,10 +20,13 @@ import android.content.Context;
|
|||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
|
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
|
||||||
import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
|
import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
|
||||||
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
@@ -44,14 +47,22 @@ public class TopLevelStoragePreferenceController extends BasePreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
protected void refreshSummary(Preference preference) {
|
||||||
// TODO: Register listener.
|
if (preference == null) {
|
||||||
final NumberFormat percentageFormat = NumberFormat.getPercentInstance();
|
return;
|
||||||
final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(
|
}
|
||||||
mStorageManagerVolumeProvider);
|
|
||||||
double privateUsedBytes = info.totalBytes - info.freeBytes;
|
ThreadUtils.postOnBackgroundThread(() -> {
|
||||||
return mContext.getString(R.string.storage_summary,
|
final NumberFormat percentageFormat = NumberFormat.getPercentInstance();
|
||||||
percentageFormat.format(privateUsedBytes / info.totalBytes),
|
final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(
|
||||||
Formatter.formatFileSize(mContext, info.freeBytes));
|
mStorageManagerVolumeProvider);
|
||||||
|
final double privateUsedBytes = info.totalBytes - info.freeBytes;
|
||||||
|
|
||||||
|
ThreadUtils.postOnMainThread(() -> {
|
||||||
|
preference.setSummary(mContext.getString(R.string.storage_summary,
|
||||||
|
percentageFormat.format(privateUsedBytes / info.totalBytes),
|
||||||
|
Formatter.formatFileSize(mContext, info.freeBytes)));
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -58,11 +58,13 @@ public class BiometricFragment extends InstrumentedFragment {
|
|||||||
private Bundle mBundle;
|
private Bundle mBundle;
|
||||||
private BiometricPrompt mBiometricPrompt;
|
private BiometricPrompt mBiometricPrompt;
|
||||||
private CancellationSignal mCancellationSignal;
|
private CancellationSignal mCancellationSignal;
|
||||||
|
private boolean mAuthenticating;
|
||||||
|
|
||||||
private AuthenticationCallback mAuthenticationCallback =
|
private AuthenticationCallback mAuthenticationCallback =
|
||||||
new AuthenticationCallback() {
|
new AuthenticationCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationError(int error, @NonNull CharSequence message) {
|
public void onAuthenticationError(int error, @NonNull CharSequence message) {
|
||||||
|
mAuthenticating = false;
|
||||||
mClientExecutor.execute(() -> {
|
mClientExecutor.execute(() -> {
|
||||||
mClientCallback.onAuthenticationError(error, message);
|
mClientCallback.onAuthenticationError(error, message);
|
||||||
});
|
});
|
||||||
@@ -71,6 +73,7 @@ public class BiometricFragment extends InstrumentedFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSucceeded(AuthenticationResult result) {
|
public void onAuthenticationSucceeded(AuthenticationResult result) {
|
||||||
|
mAuthenticating = false;
|
||||||
mClientExecutor.execute(() -> {
|
mClientExecutor.execute(() -> {
|
||||||
mClientCallback.onAuthenticationSucceeded(result);
|
mClientCallback.onAuthenticationSucceeded(result);
|
||||||
});
|
});
|
||||||
@@ -134,6 +137,10 @@ public class BiometricFragment extends InstrumentedFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isAuthenticating() {
|
||||||
|
return mAuthenticating;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -180,6 +187,7 @@ public class BiometricFragment extends InstrumentedFragment {
|
|||||||
mCancellationSignal = new CancellationSignal();
|
mCancellationSignal = new CancellationSignal();
|
||||||
|
|
||||||
// TODO: CC doesn't use crypto for now
|
// TODO: CC doesn't use crypto for now
|
||||||
|
mAuthenticating = true;
|
||||||
mBiometricPrompt.authenticateUser(mCancellationSignal, mClientExecutor,
|
mBiometricPrompt.authenticateUser(mCancellationSignal, mClientExecutor,
|
||||||
mAuthenticationCallback, mUserId, mCancelCallback);
|
mAuthenticationCallback, mUserId, mCancelCallback);
|
||||||
}
|
}
|
||||||
|
@@ -251,7 +251,10 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
if (!isChangingConfigurations()) {
|
if (!isChangingConfigurations()) {
|
||||||
mGoingToBackground = true;
|
mGoingToBackground = true;
|
||||||
if (mBiometricFragment != null) {
|
if (mBiometricFragment != null) {
|
||||||
mBiometricFragment.cancel();
|
Log.d(TAG, "Authenticating: " + mBiometricFragment.isAuthenticating());
|
||||||
|
if (mBiometricFragment.isAuthenticating()) {
|
||||||
|
mBiometricFragment.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsFallback && !mCCLaunched) {
|
if (mIsFallback && !mCCLaunched) {
|
||||||
|
BIN
tests/robotests/res/drawable/regulatory_info.png
Normal file
BIN
tests/robotests/res/drawable/regulatory_info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 159 B |
BIN
tests/robotests/res/drawable/regulatory_info_sku.png
Normal file
BIN
tests/robotests/res/drawable/regulatory_info_sku.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 159 B |
BIN
tests/robotests/res/drawable/regulatory_info_sku1_coo.png
Normal file
BIN
tests/robotests/res/drawable/regulatory_info_sku1_coo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 159 B |
@@ -163,7 +163,7 @@ public class MasterClearTest {
|
|||||||
verify(context).startActivity(intent.capture());
|
verify(context).startActivity(intent.capture());
|
||||||
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
|
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
|
||||||
.isFalse();
|
.isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class RegulatoryInfoDisplayActivityTest {
|
||||||
|
|
||||||
|
private static final String SKU_PROP_KEY = "ro.boot.hardware.sku";
|
||||||
|
private static final String COO_PROP_KEY = "ro.boot.hardware.coo";
|
||||||
|
|
||||||
|
private RegulatoryInfoDisplayActivity mRegulatoryInfoDisplayActivity;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mRegulatoryInfoDisplayActivity = Robolectric.buildActivity(
|
||||||
|
RegulatoryInfoDisplayActivity.class).create().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getResourceId_noSkuProperty_shouldReturnDefaultLabel() {
|
||||||
|
SystemProperties.set(SKU_PROP_KEY, "");
|
||||||
|
|
||||||
|
final int expectedResId = getResourceId("regulatory_info");
|
||||||
|
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getResourceId_noCooProperty_shouldReturnSkuLabel() {
|
||||||
|
SystemProperties.set(SKU_PROP_KEY, "sku");
|
||||||
|
SystemProperties.set(COO_PROP_KEY, "");
|
||||||
|
|
||||||
|
final int expectedResId = getResourceId("regulatory_info_sku");
|
||||||
|
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getResourceId_hasSkuAndCooProperties_shouldReturnCooLabel() {
|
||||||
|
SystemProperties.set(SKU_PROP_KEY, "sku1");
|
||||||
|
SystemProperties.set(COO_PROP_KEY, "coo");
|
||||||
|
|
||||||
|
final int expectedResId = getResourceId("regulatory_info_sku1_coo");
|
||||||
|
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getResourceId_noCorrespondingCooLabel_shouldReturnSkuLabel() {
|
||||||
|
SystemProperties.set(SKU_PROP_KEY, "sku");
|
||||||
|
SystemProperties.set(COO_PROP_KEY, "unknown");
|
||||||
|
|
||||||
|
final int expectedResId = getResourceId("regulatory_info_sku");
|
||||||
|
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getResourceId(String resourceName) {
|
||||||
|
return mRegulatoryInfoDisplayActivity.getResources().getIdentifier(resourceName, "drawable",
|
||||||
|
mRegulatoryInfoDisplayActivity.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
@@ -56,8 +56,7 @@ public class GameDriverAppPreferenceControllerTest {
|
|||||||
|
|
||||||
private static final int DEFAULT = 0;
|
private static final int DEFAULT = 0;
|
||||||
private static final int GAME_DRIVER = 1;
|
private static final int GAME_DRIVER = 1;
|
||||||
private static final int PRERELEASE_DRIVER = 2;
|
private static final int SYSTEM = 2;
|
||||||
private static final int SYSTEM = 3;
|
|
||||||
private static final String TEST_APP_NAME = "testApp";
|
private static final String TEST_APP_NAME = "testApp";
|
||||||
private static final String TEST_PKG_NAME = "testPkg";
|
private static final String TEST_PKG_NAME = "testPkg";
|
||||||
|
|
||||||
@@ -80,6 +79,7 @@ public class GameDriverAppPreferenceControllerTest {
|
|||||||
private GameDriverAppPreferenceController mController;
|
private GameDriverAppPreferenceController mController;
|
||||||
private CharSequence[] mValueList;
|
private CharSequence[] mValueList;
|
||||||
private String mDialogTitle;
|
private String mDialogTitle;
|
||||||
|
private String mPreferencePrereleaseDriver;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -89,6 +89,8 @@ public class GameDriverAppPreferenceControllerTest {
|
|||||||
mValueList =
|
mValueList =
|
||||||
mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
|
mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
|
||||||
mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
|
mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
|
||||||
|
mPreferencePrereleaseDriver =
|
||||||
|
mContext.getResources().getString(R.string.game_driver_app_preference_prerelease_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -207,9 +209,7 @@ public class GameDriverAppPreferenceControllerTest {
|
|||||||
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
|
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
|
||||||
assertThat(preference.getEntries()).isEqualTo(mValueList);
|
assertThat(preference.getEntries()).isEqualTo(mValueList);
|
||||||
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
|
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
|
||||||
assertThat(preference.getEntry()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
|
assertThat(preference.getSummary()).isEqualTo(mPreferencePrereleaseDriver);
|
||||||
assertThat(preference.getValue()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
|
|
||||||
assertThat(preference.getSummary()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user