summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Susla <eugenesusla@google.com>2017-03-27 16:57:40 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2017-04-14 23:15:12 +0000
commit5423b4e0a85c6dfd6ffeb04c72b5e050058a7150 (patch)
treec4d917169b4fd22c1d5bb5c9acb769c00bc9b24e
parent728ce604653853af047c30b78f2385a375f46b4f (diff)
[DO NOT MERGE] Improve the error msg when started not for result
This makes sure that if the association request callback IntentResult s accidentally started not for result, the resulting exception is metioning it explicitly. Test: Ensure the error message when calling the IntentSender not for result explicitly mentions the requirement for the activity to be called for result. Bug: 30932767 Change-Id: I950f262af43c555fb20dd5e49e935e476f24bba8
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java
index 76a64e51b9e1..466d6bb969a0 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java
@@ -34,6 +34,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.companiondevicemanager.DeviceDiscoveryService.DeviceFilterPair;
+import com.android.internal.util.Preconditions;
public class DeviceChooserActivity extends Activity {
@@ -92,8 +93,11 @@ public class DeviceChooserActivity extends Activity {
private CharSequence getCallingAppName() {
try {
final PackageManager packageManager = getPackageManager();
+ String callingPackage = Preconditions.checkStringNotEmpty(
+ getCallingPackage(),
+ "This activity must be called for result");
return packageManager.getApplicationLabel(
- packageManager.getApplicationInfo(getCallingPackage(), 0));
+ packageManager.getApplicationInfo(callingPackage, 0));
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}