From 8b2dd6573880036b4f2a91ec46e6950bd888d111 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Tue, 5 Oct 2021 20:20:40 +0800 Subject: [PATCH 1/4] Improve scalability of Settings deep link API Avoid using 'two pane' and 'large screen' because they are implementation details exposure. Bug: 201662312 Test: build pass Change-Id: Id3555f734ff11e31d2f4db0479331c4f27e9e715 --- AndroidManifest.xml | 8 ++++---- src/com/android/settings/SettingsActivity.java | 6 +++--- .../homepage/SettingsHomepageActivity.java | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 674ab61eb27..94cd1190393 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -107,8 +107,8 @@ - - + + - + diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index c105238548b..d00bb7a57a3 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -364,13 +364,13 @@ public class SettingsActivity extends SettingsBaseActivity // It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it. final Intent trampolineIntent = - new Intent(android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK); + new Intent(android.provider.Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY); trampolineIntent.replaceExtras(intent); trampolineIntent.putExtra( - android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI, + android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI, intent.toUri(Intent.URI_INTENT_SCHEME)); trampolineIntent.putExtra( - android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_HIGHLIGHT_MENU_KEY, + android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY, mHighlightMenuKey); trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); startActivity(trampolineIntent); diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java index 471b1a4d1e2..ec3589c77c3 100644 --- a/src/com/android/settings/homepage/SettingsHomepageActivity.java +++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java @@ -16,9 +16,9 @@ package com.android.settings.homepage; -import static android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK; -import static android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI; -import static android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_HIGHLIGHT_MENU_KEY; +import static android.provider.Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY; +import static android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY; +import static android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI; import android.animation.LayoutTransition; import android.app.ActivityManager; @@ -191,14 +191,14 @@ public class SettingsHomepageActivity extends FragmentActivity implements final Intent intent = getIntent(); if (intent == null || !TextUtils.equals(intent.getAction(), - ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK)) { + ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)) { return; } final String intentUriString = intent.getStringExtra( - EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI); + EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI); if (TextUtils.isEmpty(intentUriString)) { - Log.e(TAG, "No EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI to deep link"); + Log.e(TAG, "No EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI to deep link"); finish(); return; } @@ -250,9 +250,9 @@ public class SettingsHomepageActivity extends FragmentActivity implements private String getHighlightMenuKey() { final Intent intent = getIntent(); if (intent != null && TextUtils.equals(intent.getAction(), - ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK)) { + ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)) { final String menuKey = intent.getStringExtra( - EXTRA_SETTINGS_LARGE_SCREEN_HIGHLIGHT_MENU_KEY); + EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY); if (!TextUtils.isEmpty(menuKey)) { return menuKey; } From 4c1702cf2a13b607c6493a42326b17f59352fd9f Mon Sep 17 00:00:00 2001 From: ykhung Date: Mon, 18 Oct 2021 21:43:17 +0800 Subject: [PATCH 2/4] Add missed "optional_uses_libs" to avoid testing failed After adding the missed "optional_uses_libs" I can run the SettingsRoboTests test locally (screenshot: https://screenshot.googleplex.com/3nLrCwX4bLHGxvP) Bug: 203408618 Test: make SettingsRoboTests Change-Id: I1bfdb2204fe89c8d0dbcfb347d10fa74853051e9 --- tests/robotests/Android.bp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp index 43bcec7659a..bc25377ed7d 100644 --- a/tests/robotests/Android.bp +++ b/tests/robotests/Android.bp @@ -60,6 +60,10 @@ android_app { "ims-common", ], uses_libs: ["org.apache.http.legacy"], + optional_uses_libs: [ + "androidx.window.extensions", + "androidx.window.sidecar", + ], } //############################################################ From 78267b2f2ffeb84f1aa8407fbb26e1a8643752fd Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Mon, 18 Oct 2021 22:01:27 +0800 Subject: [PATCH 3/4] Catch a resource not found exception Test: not see a crash Bug: 198296421 Change-Id: I469a726a32d7bb2f6f81fc0dae27d5b1d1ac0933 --- src/com/android/settings/SettingsActivity.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index 634a6463601..02aad2924db 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -29,6 +29,7 @@ import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Resources; import android.content.res.Resources.Theme; import android.graphics.drawable.Icon; import android.os.AsyncTask; @@ -467,6 +468,9 @@ public class SettingsActivity extends SettingsBaseActivity return; } catch (NameNotFoundException e) { Log.w(LOG_TAG, "Could not find package" + initialTitleResPackageName); + } catch (Resources.NotFoundException resourceNotFound) { + Log.w(LOG_TAG, + "Could not find title resource in " + initialTitleResPackageName); } } else { setTitle(mInitialTitleResId); From d67e9702901abcf0b31756e9f9e763a4980f281b Mon Sep 17 00:00:00 2001 From: Chloris Kuo Date: Mon, 18 Oct 2021 12:37:55 -0700 Subject: [PATCH 4/4] Rename Ranking.visuallyInterruptive to isTextChanged Bug: 201087764 Test: manually tested on device Change-Id: I28b416a4ab9cc74f985c7c7c5c72ca6f7e1b6065 --- .../settings/notification/history/NotificationStation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/notification/history/NotificationStation.java b/src/com/android/settings/notification/history/NotificationStation.java index fe8b1683a97..fa3a7b2d0e9 100644 --- a/src/com/android/settings/notification/history/NotificationStation.java +++ b/src/com/android/settings/notification/history/NotificationStation.java @@ -436,7 +436,7 @@ public class NotificationStation extends SettingsPreferenceFragment { } mRanking.getRanking(info.key, rank); info.alerted = rank.getLastAudiblyAlertedMillis() > 0; - info.visuallyInterruptive = rank.visuallyInterruptive(); + info.visuallyInterruptive = rank.isTextChanged(); info.channel = rank.getChannel(); info.rankingExtra = generateRankingExtraText(info); }