diff --git a/packages/CompanionDeviceManager/res/layout/buttons.xml b/packages/CompanionDeviceManager/res/layout/buttons.xml
index b190a7f675cad..a80720c40737a 100644
--- a/packages/CompanionDeviceManager/res/layout/buttons.xml
+++ b/packages/CompanionDeviceManager/res/layout/buttons.xml
@@ -29,14 +29,15 @@
android:id="@+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@android:string/cancel"
+ android:text="@string/consent_no"
+ android:textColor="?android:attr/textColorSecondary"
style="@android:style/Widget.Material.Button.Borderless.Colored"
/>
\ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/layout/device_chooser.xml b/packages/CompanionDeviceManager/res/layout/device_chooser.xml
index db014aef6e8b3..273347af6119b 100644
--- a/packages/CompanionDeviceManager/res/layout/device_chooser.xml
+++ b/packages/CompanionDeviceManager/res/layout/device_chooser.xml
@@ -23,11 +23,13 @@
+
+
diff --git a/packages/CompanionDeviceManager/res/layout/device_confirmation.xml b/packages/CompanionDeviceManager/res/layout/device_confirmation.xml
index 7cde41ac28943..1336e79a855bc 100644
--- a/packages/CompanionDeviceManager/res/layout/device_confirmation.xml
+++ b/packages/CompanionDeviceManager/res/layout/device_confirmation.xml
@@ -23,6 +23,8 @@
+
+
\ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/layout/profile_summary.xml b/packages/CompanionDeviceManager/res/layout/profile_summary.xml
new file mode 100644
index 0000000000000..80fec59fbc452
--- /dev/null
+++ b/packages/CompanionDeviceManager/res/layout/profile_summary.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/layout/title.xml b/packages/CompanionDeviceManager/res/layout/title.xml
index 0a44fbb34a9c5..9a50366224687 100644
--- a/packages/CompanionDeviceManager/res/layout/title.xml
+++ b/packages/CompanionDeviceManager/res/layout/title.xml
@@ -20,5 +20,6 @@
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:gravity="center"
style="@*android:style/TextAppearance.Widget.Toolbar.Title"
/>
\ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/values/strings.xml b/packages/CompanionDeviceManager/res/values/strings.xml
index c4372ebef6630..1b96b0045ef0b 100644
--- a/packages/CompanionDeviceManager/res/values/strings.xml
+++ b/packages/CompanionDeviceManager/res/values/strings.xml
@@ -20,9 +20,21 @@
Companion Device Manager
- Link with <strong>%1$s</strong>
+ Choose a %1$s to be managed by <strong>%2$s</strong>
-
- Link <strong>%1$s</strong> with <strong>%2$s</strong>
+
+ device
+
+
+ Set <strong>%1$s</strong> to manage your %2$s - <strong>%3$s</strong>
+
+
+ %1$s is needed to manage your %2$s. %3$s will get access to %4$s while the %5$s is connected.
+
+
+ Yes
+
+
+ No thanks
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java
index bdfbf82145c7a..f42a51d6593a5 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java
@@ -17,11 +17,13 @@
package com.android.companiondevicemanager;
import static android.companion.BluetoothDeviceFilterUtils.getDeviceMacAddress;
+import static android.text.TextUtils.withoutPrefix;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import static java.util.Objects.requireNonNull;
import android.app.Activity;
+import android.companion.AssociationRequest;
import android.companion.CompanionDeviceManager;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -62,12 +64,19 @@ public class DeviceChooserActivity extends Activity {
getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- if (getService().mRequest.isSingleDevice()) {
+ String deviceProfile = getRequest().getDeviceProfile();
+ String profileName = deviceProfile == null
+ ? getString(R.string.profile_name_generic)
+ //TODO introduce PermissionController APIs to resolve UI values
+ : withoutPrefix("android.app.role.COMPANION_DEVICE_", deviceProfile).toLowerCase();
+
+ if (getRequest().isSingleDevice()) {
setContentView(R.layout.device_confirmation);
final DeviceFilterPair selectedDevice = getService().mDevicesFound.get(0);
setTitle(Html.fromHtml(getString(
R.string.confirmation_title,
getCallingAppName(),
+ profileName,
selectedDevice.getDisplayName()), 0));
mPairButton = findViewById(R.id.button_pair);
mPairButton.setOnClickListener(v -> onDeviceConfirmed(getService().mSelectedDevice));
@@ -77,7 +86,9 @@ public class DeviceChooserActivity extends Activity {
setContentView(R.layout.device_chooser);
mPairButton = findViewById(R.id.button_pair);
mPairButton.setVisibility(View.GONE);
- setTitle(Html.fromHtml(getString(R.string.chooser_title, getCallingAppName()), 0));
+ setTitle(Html.fromHtml(getString(R.string.chooser_title,
+ profileName,
+ getCallingAppName()), 0));
mDeviceListView = findViewById(R.id.device_list);
final DeviceDiscoveryService.DevicesAdapter adapter = getService().mDevicesAdapter;
mDeviceListView.setAdapter(adapter);
@@ -97,12 +108,33 @@ public class DeviceChooserActivity extends Activity {
});
mDeviceListView.addFooterView(mLoadingIndicator = getProgressBar(), null, false);
}
+
+ TextView profileSummary = findViewById(R.id.profile_summary);
+
+ if (deviceProfile != null) {
+ //TODO introduce PermissionController APIs to resolve UI values
+ String privileges = "Notifications, Phone, Contacts and Calendar";
+ profileSummary.setVisibility(View.VISIBLE);
+ profileSummary.setText(getString(R.string.profile_summary,
+ getCallingAppName(),
+ profileName,
+ getCallingAppName(),
+ privileges,
+ profileName));
+ } else {
+ profileSummary.setVisibility(View.GONE);
+ }
+
getService().mActivity = this;
mCancelButton = findViewById(R.id.button_cancel);
mCancelButton.setOnClickListener(v -> cancel());
}
+ private AssociationRequest getRequest() {
+ return getService().mRequest;
+ }
+
private void cancel() {
getService().onCancel();
setResult(RESULT_CANCELED);
@@ -132,7 +164,7 @@ public class DeviceChooserActivity extends Activity {
@Override
public String getCallingPackage() {
- return requireNonNull(getService().mRequest.getCallingPackage());
+ return requireNonNull(getRequest().getCallingPackage());
}
@Override
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java
index a7e397e9563ce..2fe351edb080b 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java
@@ -64,7 +64,7 @@ import android.util.SparseArray;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
+import android.widget.BaseAdapter;
import android.widget.TextView;
import com.android.internal.infra.AndroidFuture;
@@ -329,7 +329,7 @@ public class DeviceDiscoveryService extends Service {
mServiceCallback.cancel(true);
}
- class DevicesAdapter extends ArrayAdapter {
+ class DevicesAdapter extends BaseAdapter {
private Drawable BLUETOOTH_ICON = icon(android.R.drawable.stat_sys_data_bluetooth);
private Drawable WIFI_ICON = icon(com.android.internal.R.drawable.ic_wifi_signal_3);
@@ -341,10 +341,6 @@ public class DeviceDiscoveryService extends Service {
return icon;
}
- public DevicesAdapter() {
- super(DeviceDiscoveryService.this, 0, mDevicesFound);
- }
-
@Override
public View getView(
int position,
@@ -391,6 +387,21 @@ public class DeviceDiscoveryService extends Service {
mColors.put(colorAttr, result);
return result;
}
+
+ @Override
+ public int getCount() {
+ return mDevicesFound.size();
+ }
+
+ @Override
+ public DeviceFilterPair getItem(int position) {
+ return mDevicesFound.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
}
/**