Adding code to invoke feedback for the device.
Please also see http://ag/457938 Change-Id: I842e7211b339ece7066523c503db6e7b0eb12f40
This commit is contained in:
@@ -5206,4 +5206,10 @@
|
|||||||
|
|
||||||
<!-- [CHAR LIMIT=20] Zen mode settings: End time option: Summary text value format -->
|
<!-- [CHAR LIMIT=20] Zen mode settings: End time option: Summary text value format -->
|
||||||
<string name="zen_mode_end_time_summary_format"><xliff:g id="formatted_time">%s</xliff:g> next day</string>
|
<string name="zen_mode_end_time_summary_format"><xliff:g id="formatted_time">%s</xliff:g> next day</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=35] Feedback on the device -->
|
||||||
|
<string name="device_feedback">Send feedback about this device</string>
|
||||||
|
|
||||||
|
<!-- Full package name of OEM preferred device feedback reporter [DO NOT TRANSLATE] -->
|
||||||
|
<string name="oem_preferred_feedback_reporter" translatable="false"></string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -95,6 +95,11 @@
|
|||||||
<intent android:action="android.settings.SHOW_REGULATORY_INFO" />
|
<intent android:action="android.settings.SHOW_REGULATORY_INFO" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
<!-- Feedback on the device -->
|
||||||
|
<PreferenceScreen android:key="device_feedback"
|
||||||
|
android:title="@string/device_feedback">
|
||||||
|
</PreferenceScreen>
|
||||||
|
|
||||||
<!-- Device hardware model -->
|
<!-- Device hardware model -->
|
||||||
<Preference android:key="device_model"
|
<Preference android:key="device_model"
|
||||||
style="?android:preferenceInformationStyle"
|
style="?android:preferenceInformationStyle"
|
||||||
|
@@ -19,8 +19,14 @@ package com.android.settings;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
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.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.SELinux;
|
import android.os.SELinux;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
@@ -29,19 +35,20 @@ import android.preference.Preference;
|
|||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class DeviceInfoSettings extends RestrictedSettingsFragment {
|
public class DeviceInfoSettings extends RestrictedSettingsFragment {
|
||||||
|
|
||||||
private static final String LOG_TAG = "DeviceInfoSettings";
|
private static final String LOG_TAG = "DeviceInfoSettings";
|
||||||
|
|
||||||
private static final String FILENAME_PROC_VERSION = "/proc/version";
|
private static final String FILENAME_PROC_VERSION = "/proc/version";
|
||||||
private static final String FILENAME_MSV = "/sys/board_properties/soc/msv";
|
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_UPDATE_SETTING = "additional_system_update_settings";
|
||||||
private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id";
|
private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id";
|
||||||
private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
|
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;
|
static final int TAPS_TO_BE_A_DEVELOPER = 7;
|
||||||
|
|
||||||
@@ -120,6 +128,11 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment {
|
|||||||
getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION));
|
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
|
* Settings is a generic app and should not contain any device-specific
|
||||||
* info.
|
* info.
|
||||||
@@ -226,6 +239,8 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment {
|
|||||||
Toast.LENGTH_LONG);
|
Toast.LENGTH_LONG);
|
||||||
mDevHitToast.show();
|
mDevHitToast.show();
|
||||||
}
|
}
|
||||||
|
} else if (preference.getKey().equals(KEY_DEVICE_FEEDBACK)) {
|
||||||
|
sendFeedback();
|
||||||
}
|
}
|
||||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
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.
|
* Reads a line from the specified file.
|
||||||
* @param filename the file to read from
|
* @param filename the file to read from
|
||||||
@@ -347,4 +372,40 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment {
|
|||||||
}
|
}
|
||||||
return "";
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user