Improved UX when no debuggable apps are available.

In AppPicker, add an extra to exclude the "Nothing" sentinel. This is
used when selecting a debug app, and makes sense in that context.
However it does not makes sense when choosing an app to modify
compatibilty options for, so exclude it.

Also update the AppPicker to return a new result code in the case that
there are no apps available which match the criteria given. This result
code can only be used when the new extra is defined which keep this
change low risk.

In PlatformCompatDashboard, use the new extra and handle the new result
code, showing a dialog to explain that only debuggable apps are shown in
user builds. This also results in the "Nothing" item being shown at the
top of the app list.

Bug: 157633308
Test: Manual
Change-Id: Ifb055dd7c030cda42556bca8a9d7e87606f0ff72
This commit is contained in:
Mathew Inwood
2020-06-01 10:31:46 +01:00
parent 8224a5ad3d
commit 43f9adea62
3 changed files with 26 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ import static com.android.internal.compat.OverrideAllowedState.ALLOWED;
import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_COMPAT_CHANGE_APP;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.settings.SettingsEnums;
import android.compat.Compatibility.ChangeConfig;
import android.content.Context;
@@ -124,6 +125,14 @@ public class PlatformCompatDashboard extends DashboardFragment {
} catch (PackageManager.NameNotFoundException e) {
startAppPicker();
}
} else if (resultCode == AppPicker.RESULT_NO_MATCHING_APPS) {
new AlertDialog.Builder(getContext())
.setTitle(R.string.platform_compat_dialog_title_no_apps)
.setMessage(R.string.platform_compat_dialog_text_no_apps)
.setPositiveButton(R.string.okay, (dialog, which) -> finish())
.setOnDismissListener(dialog -> finish())
.setCancelable(false)
.show();
}
return;
}
@@ -254,7 +263,8 @@ public class PlatformCompatDashboard extends DashboardFragment {
}
private void startAppPicker() {
final Intent intent = new Intent(getContext(), AppPicker.class);
final Intent intent = new Intent(getContext(), AppPicker.class)
.putExtra(AppPicker.EXTRA_INCLUDE_NOTHING, false);
// If build is neither userdebug nor eng, only include debuggable apps
final boolean debuggableBuild = mAndroidBuildClassifier.isDebuggableBuild();
if (!debuggableBuild) {