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

Commit e8b5a86e authored by Eugene Susla's avatar Eugene Susla
Browse files

Improve the error message when IntentSender started not for result

This makes sure that if the association request callback IntentResult is
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: I689e5af45f1178ddda17ec14aae932c51d940db1
parent cf0341ec
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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);
        }