From 6d996e01383383e42498c31ef1e0e33c990c8212 Mon Sep 17 00:00:00 2001 From: Hugh Chen Date: Thu, 7 Jan 2021 00:58:58 +0000 Subject: [PATCH 1/5] DO NOT MERGE: resolve merge conflicts of c17ec818af7159f4fd678dab3bbad7ef308a7be4 to rvc-qpr-dev Bug: 167403112 Test: send intent to test right prompts message is pop up. make -j42 RunSettingsRoboTests Change-Id: Iec4d1963e626829b696c2047c5979a684119acf7 Merged-In: Iec4d1963e626829b696c2047c5979a684119acf7 (cherry picked from commit dc2b694a5478660ce51814838fb348f9dba71ba2) --- res/values/strings.xml | 13 +++++++++++++ .../bluetooth/BluetoothPermissionActivity.java | 12 ++++++------ .../bluetooth/BluetoothPermissionRequest.java | 9 +++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 8bc30d8c0d6..f02d11f656a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12196,4 +12196,17 @@ Unavailable because bedtime mode is on + + + Untrusted device wants to access your messages. Tap for details. + + Allow access to messages? + + An untrusted Bluetooth device, [%1$s], wants to access your messages.\n\nYou haven\u2019t connected to [%2$s] before. + + Untrusted device wants to access your contacts and call log. Tap for details. + + Allow access to contacts and call log? + + An untrusted Bluetooth device, [%1$s], wants to access your contacts and call log. This includes data about incoming and outgoing calls.\n\nYou haven\u2019t connected to [%2$s] before. diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java index be383dc02ba..e40e30dd0a0 100644 --- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java @@ -99,9 +99,9 @@ public class BluetoothPermissionActivity extends AlertActivity implements if (mRequestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) { showDialog(getString(R.string.bluetooth_connection_permission_request), mRequestType); } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) { - showDialog(getString(R.string.bluetooth_phonebook_request), mRequestType); + showDialog(getString(R.string.bluetooth_phonebook_access_dialog_title), mRequestType); } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) { - showDialog(getString(R.string.bluetooth_map_request), mRequestType); + showDialog(getString(R.string.bluetooth_message_access_dialog_title), mRequestType); } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) { showDialog(getString(R.string.bluetooth_sap_request), mRequestType); } @@ -136,9 +136,9 @@ public class BluetoothPermissionActivity extends AlertActivity implements p.mView = createSapDialogView(); break; } - p.mPositiveButtonText = getString(R.string.yes); + p.mPositiveButtonText = getString(R.string.allow); p.mPositiveButtonListener = this; - p.mNegativeButtonText = getString(R.string.no); + p.mNegativeButtonText = getString(R.string.deny); p.mNegativeButtonListener = this; mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); setupAlert(); @@ -168,7 +168,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements String mRemoteName = Utils.createRemoteName(this, mDevice); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); - messageView.setText(getString(R.string.bluetooth_pb_acceptance_dialog_text, + messageView.setText(getString(R.string.bluetooth_phonebook_access_dialog_content, mRemoteName, mRemoteName)); return mView; } @@ -177,7 +177,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements String mRemoteName = Utils.createRemoteName(this, mDevice); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); - messageView.setText(getString(R.string.bluetooth_map_acceptance_dialog_text, + messageView.setText(getString(R.string.bluetooth_message_access_dialog_content, mRemoteName, mRemoteName)); return mView; } diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java index 5fffa3a2356..177bd893558 100644 --- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java @@ -140,13 +140,13 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { switch (mRequestType) { case BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS: title = context.getString(R.string.bluetooth_phonebook_request); - message = context.getString(R.string.bluetooth_pb_acceptance_dialog_text, - deviceAlias, deviceAlias); + message = context.getString( + R.string.bluetooth_phonebook_access_notification_content); break; case BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS: title = context.getString(R.string.bluetooth_map_request); - message = context.getString(R.string.bluetooth_map_acceptance_dialog_text, - deviceAlias, deviceAlias); + message = context.getString( + R.string.bluetooth_message_access_notification_content); break; case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS: title = context.getString(R.string.bluetooth_sap_request); @@ -172,6 +172,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { .setContentTitle(title) .setTicker(message) .setContentText(message) + .setStyle(new Notification.BigTextStyle().bigText(message)) .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth) .setAutoCancel(true) .setPriority(Notification.PRIORITY_MAX) From a1669905f1617e41e1c95733bef90c45272f9376 Mon Sep 17 00:00:00 2001 From: Hugh Chen Date: Tue, 22 Dec 2020 14:26:44 +0800 Subject: [PATCH 2/5] RESTRICT AUTOMERGE Update String Remove brackets. Bug: 176106404 Bug: 167403112 Test: build pass Change-Id: Ib9a3c4fa3c6ea1ca54244d672bdc3e12d51a719f (cherry picked from commit 085f70d48d50da1b689f8343505e844655e5b1f1) --- res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index f02d11f656a..226398ea5eb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12202,11 +12202,11 @@ Allow access to messages? - An untrusted Bluetooth device, [%1$s], wants to access your messages.\n\nYou haven\u2019t connected to [%2$s] before. + An untrusted Bluetooth device, %1$s, wants to access your messages.\n\nYou haven\u2019t connected to %2$s before. Untrusted device wants to access your contacts and call log. Tap for details. Allow access to contacts and call log? - An untrusted Bluetooth device, [%1$s], wants to access your contacts and call log. This includes data about incoming and outgoing calls.\n\nYou haven\u2019t connected to [%2$s] before. + An untrusted Bluetooth device, %1$s, wants to access your contacts and call log. This includes data about incoming and outgoing calls.\n\nYou haven\u2019t connected to %2$s before. From d4f04398c71f67bc13f85e098e1dc71d840c1a4a Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Tue, 9 Mar 2021 20:38:56 +0000 Subject: [PATCH 3/5] Prevent using invalid result uri during multi user image change Test: manual Bug: 172939189 Change-Id: I3e6f6200e82e86d6a2085652906ad2d0d44814f5 Merged-In: Id2e598878b3250e8b3590905c6def561e2437d55 Merged-In: I15e15ad88b768a5b679de32c5429d921d850a3cb (cherry picked from commit 07e414017c0d1f0c82006a8b59dc404baf696844) --- .../android/settings/users/EditUserPhotoController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/com/android/settings/users/EditUserPhotoController.java b/src/com/android/settings/users/EditUserPhotoController.java index a20513a3664..60f720eacf7 100644 --- a/src/com/android/settings/users/EditUserPhotoController.java +++ b/src/com/android/settings/users/EditUserPhotoController.java @@ -36,6 +36,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.provider.ContactsContract.DisplayPhoto; import android.provider.MediaStore; +import android.util.EventLog; import android.util.Log; import android.view.Gravity; import android.view.View; @@ -116,6 +117,14 @@ public class EditUserPhotoController { } final Uri pictureUri = data != null && data.getData() != null ? data.getData() : mTakePictureUri; + + // Check if the result is a content uri + if (!ContentResolver.SCHEME_CONTENT.equals(pictureUri.getScheme())) { + Log.e(TAG, "Invalid pictureUri scheme: " + pictureUri.getScheme()); + EventLog.writeEvent(0x534e4554, "172939189", -1, pictureUri.getPath()); + return false; + } + switch (requestCode) { case REQUEST_CODE_CROP_PHOTO: onPhotoCropped(pictureUri, true); From 5b27fd923acd67d15787cd1a70ab873900f677e0 Mon Sep 17 00:00:00 2001 From: ykhung Date: Sat, 8 May 2021 15:19:19 +0800 Subject: [PATCH 4/5] Fix UI flashes issue when entering to the app in the cold start 1. fix the chart % info will flash issue by deferring the showing time until the chart content is ready to show (set default as invisible) 2. fix the category title will flash issue by set the default value as empty to avoid refresh the title twice in the start time Bug: 177406865 Test: make SettingsRoboTests Change-Id: If8f247cf5b01c529bc5e4d18fcf409ba296cc2f4 --- res/layout/battery_chart_graph.xml | 1 + res/xml/power_usage_advanced.xml | 3 +-- .../fuelgauge/BatteryAppListPreferenceController.java | 1 + src/com/android/settings/fuelgauge/BatteryChartView.java | 1 + src/com/android/settings/fuelgauge/ConvertUtils.java | 6 +++--- .../com/android/settings/fuelgauge/ConvertUtilsTest.java | 9 +++++++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/res/layout/battery_chart_graph.xml b/res/layout/battery_chart_graph.xml index 18e650ce1d4..1896b78d016 100644 --- a/res/layout/battery_chart_graph.xml +++ b/res/layout/battery_chart_graph.xml @@ -36,6 +36,7 @@ android:layout_width="match_parent" android:layout_height="165dp" android:layout_marginBottom="16dp" + android:visibility="invisible" android:textAppearance="?android:attr/textAppearanceSmall" settings:textColor="?android:attr/textColorSecondary" /> + android:key="app_list"/> entryList = purgedResultMap.get(0); assertThat(entryList).hasSize(1); // Verifies the clipped usage time. + final float ratio = (float) (7200) / (float) (3600 + 7200); final BatteryDiffEntry resultEntry = entryList.get(0); - assertThat(resultEntry.mForegroundUsageTimeInMs).isEqualTo(2400000); - assertThat(resultEntry.mBackgroundUsageTimeInMs).isEqualTo(4800000); + assertThat(resultEntry.mForegroundUsageTimeInMs) + .isEqualTo(Math.round(entry.mForegroundUsageTimeInMs * ratio)); + assertThat(resultEntry.mBackgroundUsageTimeInMs) + .isEqualTo(Math.round(entry.mBackgroundUsageTimeInMs * ratio)); + assertThat(resultEntry.mConsumePower) + .isEqualTo(entry.mConsumePower * ratio); } @Test From d8d5335096889e699903d80448045ccc1c213c8f Mon Sep 17 00:00:00 2001 From: ykhung Date: Sat, 8 May 2021 22:36:51 +0800 Subject: [PATCH 5/5] Build a bridge to control whether the graph is clickable or not Create a bridge to read phenotype flag from GoogleSettings to control whether each time slot in the graph is clickable or not. Bug: 185308803 Test: make SettingsRoboTests Change-Id: If8b58dcaa50ad5fb6b447ca5b7146639ee31a9df --- .../settings/fuelgauge/BatteryChartView.java | 23 +++++++++++++++++-- .../settings/fuelgauge/ConvertUtils.java | 2 +- .../fuelgauge/PowerUsageFeatureProvider.java | 5 ++++ .../PowerUsageFeatureProviderImpl.java | 5 ++++ .../settings/fuelgauge/ConvertUtilsTest.java | 4 +--- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/fuelgauge/BatteryChartView.java b/src/com/android/settings/fuelgauge/BatteryChartView.java index 37c298496ed..ac71812fbd2 100644 --- a/src/com/android/settings/fuelgauge/BatteryChartView.java +++ b/src/com/android/settings/fuelgauge/BatteryChartView.java @@ -33,6 +33,7 @@ import android.widget.TextView; import androidx.appcompat.widget.AppCompatImageView; import com.android.settings.R; +import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.Utils; import java.util.Locale; @@ -59,6 +60,8 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick private int mSelectedIndex; private float mTrapezoidVOffset; private float mTrapezoidHOffset; + private boolean mIsSlotsClickable; + // Colors for drawing the trapezoid shape and dividers. private int mTrapezoidColor; private int mTrapezoidSolidColor; @@ -73,7 +76,6 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick private final Rect[] mTimestampsBounds = new Rect[] {new Rect(), new Rect(), new Rect(), new Rect()}; - private int[] mLevels; private Paint mTextPaint; private Paint mDividerPaint; @@ -92,9 +94,9 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick initializeColors(context); // Registers the click event listener. setOnClickListener(this); - setClickable(false); setSelectedIndex(SELECTED_INDEX_ALL); setTrapezoidCount(DEFAULT_TRAPEZOID_COUNT); + setClickable(false); } /** Sets the total trapezoid count for drawing. */ @@ -241,6 +243,23 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick view.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); } + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + final Context context = mContext; + mIsSlotsClickable = + FeatureFactory.getFactory(context) + .getPowerUsageFeatureProvider(context) + .isChartGraphSlotsEnabled(context); + Log.d(TAG, "isChartGraphSlotsEnabled:" + mIsSlotsClickable); + setClickable(isClickable()); + } + + @Override + public void setClickable(boolean clickable) { + super.setClickable(mIsSlotsClickable && clickable); + } + private void initializeColors(Context context) { setBackgroundColor(Color.TRANSPARENT); mTrapezoidSolidColor = Utils.getColorAccentDefaultColor(context); diff --git a/src/com/android/settings/fuelgauge/ConvertUtils.java b/src/com/android/settings/fuelgauge/ConvertUtils.java index d2f3ab5c71d..37f9e1212b4 100644 --- a/src/com/android/settings/fuelgauge/ConvertUtils.java +++ b/src/com/android/settings/fuelgauge/ConvertUtils.java @@ -260,10 +260,10 @@ public final class ConvertUtils { diffEntry.setTotalConsumePower(totalConsumePower); } } + insert24HoursData(BatteryChartView.SELECTED_INDEX_ALL, resultMap); if (purgeLowPercentageAndFakeData) { purgeLowPercentageAndFakeData(resultMap); } - insert24HoursData(BatteryChartView.SELECTED_INDEX_ALL, resultMap); return resultMap; } diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java index 7b97bdf6f76..61abe6b1fbf 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java +++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java @@ -132,6 +132,11 @@ public interface PowerUsageFeatureProvider { */ boolean isChartGraphEnabled(Context context); + /** + * Checks whether we should show usage information by slots or not. + */ + boolean isChartGraphSlotsEnabled(Context context); + /** * Returns battery history data with corresponding timestamp key. */ diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java index b9f225b92f4..1dcdab08be5 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java +++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java @@ -158,6 +158,11 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider return false; } + @Override + public boolean isChartGraphSlotsEnabled(Context context) { + return false; + } + @Override public Map> getBatteryHistory(Context context) { return null; diff --git a/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java index 4d8d6ce9078..216b118a029 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java @@ -246,12 +246,10 @@ public final class ConvertUtilsTest { assertBatteryDiffEntry(entryList.get(0), 75, 40L, 50L); // Verifies the last 24 hours aggregate result. entryList = purgedResultMap.get(Integer.valueOf(-1)); - assertThat(entryList).hasSize(2); + assertThat(entryList).hasSize(1); // Verifies the fake data is cleared out. assertThat(entryList.get(0).getPackageName()) .isNotEqualTo(ConvertUtils.FAKE_PACKAGE_NAME); - assertThat(entryList.get(1).getPackageName()) - .isNotEqualTo(ConvertUtils.FAKE_PACKAGE_NAME); } @Test