From 49b1bc15450d823e86ee4b2b77d77dc9eeca388e Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Fri, 19 Jul 2019 01:46:36 +0800 Subject: [PATCH] Support new regulatory label for location Fixes: 137348817 Test: visual, robotests Change-Id: I165b1e859891c7897e837d82702582458cecbb0d --- .../settings/RegulatoryInfoDisplayActivity.java | 25 +++++-- tests/robotests/res/drawable/regulatory_info.png | Bin 0 -> 159 bytes .../robotests/res/drawable/regulatory_info_sku.png | Bin 0 -> 159 bytes .../res/drawable/regulatory_info_sku1_coo.png | Bin 0 -> 159 bytes .../RegulatoryInfoDisplayActivityTest.java | 83 +++++++++++++++++++++ 5 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 tests/robotests/res/drawable/regulatory_info.png create mode 100644 tests/robotests/res/drawable/regulatory_info_sku.png create mode 100644 tests/robotests/res/drawable/regulatory_info_sku1_coo.png create mode 100644 tests/robotests/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java diff --git a/src/com/android/settings/RegulatoryInfoDisplayActivity.java b/src/com/android/settings/RegulatoryInfoDisplayActivity.java index 8bc1cefec5..4c7515d10f 100644 --- a/src/com/android/settings/RegulatoryInfoDisplayActivity.java +++ b/src/com/android/settings/RegulatoryInfoDisplayActivity.java @@ -119,7 +119,8 @@ public class RegulatoryInfoDisplayActivity extends Activity implements } } - private int getResourceId() { + @VisibleForTesting + int getResourceId() { // Use regulatory_info by default. int resId = getResources().getIdentifier( REGULATORY_INFO_RESOURCE, "drawable", getPackageName()); @@ -134,6 +135,18 @@ public class RegulatoryInfoDisplayActivity extends Activity implements resId = id; } } + + // When hardware coo property exists, use regulatory_info__ 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; } @@ -142,13 +155,15 @@ public class RegulatoryInfoDisplayActivity extends Activity implements finish(); // close the activity } - @VisibleForTesting - public static String getSku() { + private String getCoo() { + return SystemProperties.get("ro.boot.hardware.coo", ""); + } + + private String getSku() { return SystemProperties.get("ro.boot.hardware.sku", ""); } - @VisibleForTesting - public static String getRegulatoryInfoImageFileName() { + private String getRegulatoryInfoImageFileName() { final String sku = getSku(); if (TextUtils.isEmpty(sku)) { return DEFAULT_REGULATORY_INFO_FILEPATH; diff --git a/tests/robotests/res/drawable/regulatory_info.png b/tests/robotests/res/drawable/regulatory_info.png new file mode 100644 index 0000000000000000000000000000000000000000..65de26c0eb28b05d6d0d6903288e1bbbce409d18 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1SBVv2j2s6ii6yp7}lMWc?slj7I;J!Gca%q zgD@k*tT_@uLG}_)Usv`!oI*kxYUgfUzX24IEOCt}an8@pP0cG|a4t$sEJ;mKD9