From 4ed8cc1e58effe94ff14cb5e89629e36ba228927 Mon Sep 17 00:00:00 2001 From: merothh Date: Sun, 8 Aug 2021 23:49:04 +0530 Subject: [PATCH 1/3] Settings: Hide Backup options on non test builds * Both search result and preference --- .../settings/backup/BackupSettingsActivity.java | 7 ++++--- .../settings/system/SystemDashboardFragment.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/backup/BackupSettingsActivity.java b/src/com/android/settings/backup/BackupSettingsActivity.java index d78af32d36b..9a8f07dfda5 100644 --- a/src/com/android/settings/backup/BackupSettingsActivity.java +++ b/src/com/android/settings/backup/BackupSettingsActivity.java @@ -21,6 +21,7 @@ import android.app.FragmentManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.os.UserHandle; import android.support.annotation.VisibleForTesting; @@ -120,9 +121,9 @@ public class BackupSettingsActivity extends Activity implements Indexable { // For non-primary user, no backup is available, so don't show it in search // TODO: http://b/22388012 - if (UserHandle.myUserId() != UserHandle.USER_SYSTEM) { + if (!Build.TAGS.equalsIgnoreCase("test-keys,test-release") || UserHandle.myUserId() != UserHandle.USER_SYSTEM) { if (Log.isLoggable(TAG, Log.DEBUG)) { - Log.d(TAG, "Not a system user, not indexing the screen"); + Log.d(TAG, "Build type is non test or Not a system user, not indexing the screen"); } keys.add(BACKUP_SEARCH_INDEX_KEY); } @@ -135,4 +136,4 @@ public class BackupSettingsActivity extends Activity implements Indexable { void setFragmentManager(FragmentManager fragmentManager) { mFragmentManager = fragmentManager; } -} \ No newline at end of file +} diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java index 1556659fa8e..929730cae13 100644 --- a/src/com/android/settings/system/SystemDashboardFragment.java +++ b/src/com/android/settings/system/SystemDashboardFragment.java @@ -16,6 +16,7 @@ package com.android.settings.system; import android.content.Context; +import android.os.Build; import android.os.Bundle; import android.provider.SearchIndexableResource; import android.support.v7.preference.Preference; @@ -36,6 +37,7 @@ public class SystemDashboardFragment extends DashboardFragment { private static final String TAG = "SystemDashboardFrag"; + private static final String KEY_BACKUP = "backup_settings"; private static final String KEY_RESET = "reset_dashboard"; @Override @@ -43,6 +45,13 @@ public class SystemDashboardFragment extends DashboardFragment { super.onCreate(icicle); final PreferenceScreen screen = getPreferenceScreen(); + + // Remove backup options if we are on a test build + if (!Build.TAGS.equalsIgnoreCase("test-keys,test-release")) { + Preference backup = findPreference(KEY_BACKUP); + screen.removePreference(backup); + } + // We do not want to display an advanced button if only one setting is hidden if (getVisiblePreferenceCount(screen) == screen.getInitialExpandedChildrenCount() + 1) { screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE); @@ -104,4 +113,4 @@ public class SystemDashboardFragment extends DashboardFragment { return keys; } }; -} \ No newline at end of file +} -- GitLab From 6053036f5fa7ac0e26a67366629a87b6dabaa19a Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 21 Sep 2021 05:26:31 +0000 Subject: [PATCH 2/3] Apply 1 suggestion(s) to 1 file(s) --- src/com/android/settings/system/SystemDashboardFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java index 929730cae13..4e1aef2979e 100644 --- a/src/com/android/settings/system/SystemDashboardFragment.java +++ b/src/com/android/settings/system/SystemDashboardFragment.java @@ -46,7 +46,7 @@ public class SystemDashboardFragment extends DashboardFragment { final PreferenceScreen screen = getPreferenceScreen(); - // Remove backup options if we are on a test build + // Remove backup options if we are not on a test build if (!Build.TAGS.equalsIgnoreCase("test-keys,test-release")) { Preference backup = findPreference(KEY_BACKUP); screen.removePreference(backup); -- GitLab From bf0a4e77a8505aa97a8c13d36a55c44db4d78f00 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 21 Sep 2021 05:27:02 +0000 Subject: [PATCH 3/3] Apply 1 suggestion(s) to 1 file(s) --- src/com/android/settings/backup/BackupSettingsActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/backup/BackupSettingsActivity.java b/src/com/android/settings/backup/BackupSettingsActivity.java index 9a8f07dfda5..0293afe5253 100644 --- a/src/com/android/settings/backup/BackupSettingsActivity.java +++ b/src/com/android/settings/backup/BackupSettingsActivity.java @@ -123,7 +123,7 @@ public class BackupSettingsActivity extends Activity implements Indexable { // TODO: http://b/22388012 if (!Build.TAGS.equalsIgnoreCase("test-keys,test-release") || UserHandle.myUserId() != UserHandle.USER_SYSTEM) { if (Log.isLoggable(TAG, Log.DEBUG)) { - Log.d(TAG, "Build type is non test or Not a system user, not indexing the screen"); + Log.d(TAG, "Build type is non-test or the UserID is not of a system user, not indexing the screen"); } keys.add(BACKUP_SEARCH_INDEX_KEY); } -- GitLab