Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2db15cdf authored by Matthew Fritze's avatar Matthew Fritze Committed by Android (Google) Code Review
Browse files

Merge "Adding flags to allow package names to be sent to support." into nyc-dr1-dev

parents 5526f9c7 e1398ea4
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -22,4 +22,19 @@

    <!-- Default data warning level in mb -->
    <integer name="default_data_warning_level_mb">2048</integer>

    <!-- Whether to send a custom package name with the PSD. translatable="false"-->
    <bool name="config_sendPackageName">true</bool>

    <!-- Name for the set of keys associating package names -->
    <string name="config_helpPackageNameKey" translatable="false"></string>

    <!-- Name for the set of values of package names -->
    <string name="config_helpPackageNameValue" translatable="false"></string>

    <!-- Intent key for the package name keys -->
    <string name="config_helpIntentExtraKey" translatable="false"></string>

    <!-- Intent key for package name values -->
    <string name="config_helpIntentNameKey" translatable="false"></string>
</resources>
+20 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.net.Uri;
@@ -140,7 +141,7 @@ public class HelpUtils {
        try {
            Intent intent = Intent.parseUri(helpUriString,
                    Intent.URI_ANDROID_APP_SCHEME | Intent.URI_INTENT_SCHEME);
            addIntentParameters(context, intent, backupContext);
            addIntentParameters(context, intent, backupContext, true /* sendPackageName */);
            ComponentName component = intent.resolveActivity(context.getPackageManager());
            if (component != null) {
                return intent;
@@ -164,11 +165,28 @@ public class HelpUtils {
        return intent;
    }

    public static void addIntentParameters(Context context, Intent intent, String backupContext) {
    public static void addIntentParameters(Context context, Intent intent, String backupContext,
            boolean sendPackageName) {
        if (!intent.hasExtra(EXTRA_CONTEXT)) {
            // Insert some context if none exists.
            intent.putExtra(EXTRA_CONTEXT, backupContext);
        }

        Resources resources = context.getResources();
        boolean includePackageName = resources.getBoolean(R.bool.config_sendPackageName);

        if (sendPackageName && includePackageName) {
            String[] packageNameKey =
                    {resources.getString(R.string.config_helpPackageNameKey)};
            String[] packageNameValue =
                    {resources.getString(R.string.config_helpPackageNameValue)};
            String intentExtraKey =
                    resources.getString(R.string.config_helpIntentExtraKey);
            String intentNameKey =
                    resources.getString(R.string.config_helpIntentNameKey);
            intent.putExtra(intentExtraKey, packageNameKey);
            intent.putExtra(intentNameKey, packageNameValue);
        }
        intent.putExtra(EXTRA_THEME, 1 /* Light, dark action bar */);
        TypedArray array = context.obtainStyledAttributes(new int[]{android.R.attr.colorPrimary});
        intent.putExtra(EXTRA_PRIMARY_COLOR, array.getColor(0, 0));