diff options
author | Rajat Dewan <rajatdewan@google.com> | 2014-04-29 20:32:37 -0700 |
---|---|---|
committer | Rajat Dewan <rajatdewan@google.com> | 2014-04-30 17:40:01 -0700 |
commit | b42573d0e6870b026110ece22f13dc15452d507c (patch) | |
tree | 0ac0d04aae7df14a976defd2a704b44a24259411 /src/com/android/settings/DeviceInfoSettings.java | |
parent | a0ceb908bfe6d030f588455db3f3b42c9931fdea (diff) | |
download | packages_apps_Settings-b42573d0e6870b026110ece22f13dc15452d507c.zip packages_apps_Settings-b42573d0e6870b026110ece22f13dc15452d507c.tar.gz packages_apps_Settings-b42573d0e6870b026110ece22f13dc15452d507c.tar.bz2 |
Adding code to invoke feedback for the device.
Please also see http://ag/457938
Change-Id: I842e7211b339ece7066523c503db6e7b0eb12f40
Diffstat (limited to 'src/com/android/settings/DeviceInfoSettings.java')
-rw-r--r-- | src/com/android/settings/DeviceInfoSettings.java | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 1e3b9a8..bf303df 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -19,8 +19,14 @@ package com.android.settings; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.os.Binder; import android.os.Build; import android.os.Bundle; +import android.os.Parcel; +import android.os.RemoteException; import android.os.SELinux; import android.os.SystemClock; import android.os.SystemProperties; @@ -29,19 +35,20 @@ import android.preference.Preference; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; import android.provider.Settings; +import android.text.TextUtils; import android.util.Log; import android.widget.Toast; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class DeviceInfoSettings extends RestrictedSettingsFragment { private static final String LOG_TAG = "DeviceInfoSettings"; - private static final String FILENAME_PROC_VERSION = "/proc/version"; private static final String FILENAME_MSV = "/sys/board_properties/soc/msv"; @@ -64,6 +71,7 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment { private static final String KEY_UPDATE_SETTING = "additional_system_update_settings"; private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id"; private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid"; + private static final String KEY_DEVICE_FEEDBACK = "device_feedback"; static final int TAPS_TO_BE_A_DEVELOPER = 7; @@ -120,6 +128,11 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment { getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION)); } + // Dont show feedback option if there is no reporter. + if (TextUtils.isEmpty(getFeedbackReporterPackage(getActivity()))) { + getPreferenceScreen().removePreference(findPreference(KEY_DEVICE_FEEDBACK)); + } + /* * Settings is a generic app and should not contain any device-specific * info. @@ -226,6 +239,8 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment { Toast.LENGTH_LONG); mDevHitToast.show(); } + } else if (preference.getKey().equals(KEY_DEVICE_FEEDBACK)) { + sendFeedback(); } return super.onPreferenceTreeClick(preferenceScreen, preference); } @@ -271,6 +286,16 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment { } } + private void sendFeedback() { + String reporterPackage = getFeedbackReporterPackage(getActivity()); + if (TextUtils.isEmpty(reporterPackage)) { + return; + } + Intent intent = new Intent(Intent.ACTION_BUG_REPORT); + intent.setPackage(reporterPackage); + startActivityForResult(intent, 0); + } + /** * Reads a line from the specified file. * @param filename the file to read from @@ -347,4 +372,40 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment { } return ""; } + + private static String getFeedbackReporterPackage(Context context) { + String feedbackReporter = + context.getResources().getString(R.string.oem_preferred_feedback_reporter); + if (TextUtils.isEmpty(feedbackReporter)) { + // Reporter not configured. Return. + return feedbackReporter; + } + // Additional checks to ensure the reporter is on system image, and reporter is + // configured to listen to the intent. Otherwise, dont show the "send feedback" option. + Intent intent = new Intent(Intent.ACTION_BUG_REPORT); + + PackageManager pm = context.getPackageManager(); + List<ResolveInfo> resolvedPackages = + pm.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); + for (ResolveInfo info : resolvedPackages) { + if (info.activityInfo != null) { + if (!TextUtils.isEmpty(info.activityInfo.packageName)) { + try { + ApplicationInfo ai = pm.getApplicationInfo(info.activityInfo.packageName, 0); + if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { + // Package is on the system image + if (TextUtils.equals( + info.activityInfo.packageName, feedbackReporter)) { + return feedbackReporter; + } + } + } catch (PackageManager.NameNotFoundException e) { + // No need to do anything here. + } + } + } + } + return null; + } } + |