Merge "Propagate callingPackage explicitly within CDM" into rvc-qpr-dev
This commit is contained in:
@@ -46,6 +46,7 @@ public final class AssociationRequest implements Parcelable {
|
|||||||
|
|
||||||
private final boolean mSingleDevice;
|
private final boolean mSingleDevice;
|
||||||
private final List<DeviceFilter<?>> mDeviceFilters;
|
private final List<DeviceFilter<?>> mDeviceFilters;
|
||||||
|
private String mCallingPackage;
|
||||||
|
|
||||||
private AssociationRequest(
|
private AssociationRequest(
|
||||||
boolean singleDevice, @Nullable List<DeviceFilter<?>> deviceFilters) {
|
boolean singleDevice, @Nullable List<DeviceFilter<?>> deviceFilters) {
|
||||||
@@ -57,6 +58,7 @@ public final class AssociationRequest implements Parcelable {
|
|||||||
this(
|
this(
|
||||||
in.readByte() != 0,
|
in.readByte() != 0,
|
||||||
in.readParcelableList(new ArrayList<>(), AssociationRequest.class.getClassLoader()));
|
in.readParcelableList(new ArrayList<>(), AssociationRequest.class.getClassLoader()));
|
||||||
|
setCallingPackage(in.readString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -72,32 +74,45 @@ public final class AssociationRequest implements Parcelable {
|
|||||||
return mDeviceFilters;
|
return mDeviceFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public String getCallingPackage() {
|
||||||
|
return mCallingPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public void setCallingPackage(String pkg) {
|
||||||
|
mCallingPackage = pkg;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
AssociationRequest that = (AssociationRequest) o;
|
AssociationRequest that = (AssociationRequest) o;
|
||||||
return mSingleDevice == that.mSingleDevice &&
|
return mSingleDevice == that.mSingleDevice
|
||||||
Objects.equals(mDeviceFilters, that.mDeviceFilters);
|
&& Objects.equals(mDeviceFilters, that.mDeviceFilters)
|
||||||
|
&& Objects.equals(mCallingPackage, that.mCallingPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(mSingleDevice, mDeviceFilters);
|
return Objects.hash(mSingleDevice, mDeviceFilters, mCallingPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AssociationRequest{" +
|
return "AssociationRequest{"
|
||||||
"mSingleDevice=" + mSingleDevice +
|
+ "mSingleDevice=" + mSingleDevice
|
||||||
", mDeviceFilters=" + mDeviceFilters +
|
+ ", mDeviceFilters=" + mDeviceFilters
|
||||||
'}';
|
+ ", mCallingPackage=" + mCallingPackage
|
||||||
|
+ '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeByte((byte) (mSingleDevice ? 1 : 0));
|
dest.writeByte((byte) (mSingleDevice ? 1 : 0));
|
||||||
dest.writeParcelableList(mDeviceFilters, flags);
|
dest.writeParcelableList(mDeviceFilters, flags);
|
||||||
|
dest.writeString(mCallingPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.android.companiondevicemanager;
|
|||||||
|
|
||||||
import static android.companion.BluetoothDeviceFilterUtils.getDeviceMacAddress;
|
import static android.companion.BluetoothDeviceFilterUtils.getDeviceMacAddress;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.companion.CompanionDeviceManager;
|
import android.companion.CompanionDeviceManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -116,6 +118,11 @@ public class DeviceChooserActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCallingPackage() {
|
||||||
|
return requireNonNull(getService().mRequest.getCallingPackage());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(CharSequence title) {
|
public void setTitle(CharSequence title) {
|
||||||
final TextView titleView = findViewById(R.id.title);
|
final TextView titleView = findViewById(R.id.title);
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
mFindDeviceCallback = callback;
|
mFindDeviceCallback = callback;
|
||||||
mRequest = request;
|
mRequest = request;
|
||||||
mCallingPackage = callingPackage;
|
mCallingPackage = callingPackage;
|
||||||
|
request.setCallingPackage(callingPackage);
|
||||||
callback.asBinder().linkToDeath(CompanionDeviceManagerService.this /* recipient */, 0);
|
callback.asBinder().linkToDeath(CompanionDeviceManagerService.this /* recipient */, 0);
|
||||||
|
|
||||||
final long callingIdentity = Binder.clearCallingIdentity();
|
final long callingIdentity = Binder.clearCallingIdentity();
|
||||||
|
|||||||
Reference in New Issue
Block a user