Skip to content

Commit

Permalink
Use the system component for the nearby sharing action if available.
Browse files Browse the repository at this point in the history
Bug: 308014458
Fixes: 308014458
Flag: NA
Test: atest com.android.launcher3.AppSharingTest
Change-Id: I41ff4efd7153e4ec7591b7d34695766e5bc9f436
  • Loading branch information
rajekumar committed Dec 19, 2023
1 parent 34aa1c5 commit b3c7d2e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions go/quickstep/src/com/android/launcher3/AppSharing.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -64,14 +65,17 @@ public final class AppSharing {

private static final String TAG = "AppSharing";
private static final String FILE_PROVIDER_SUFFIX = ".overview.fileprovider";
private static final String APP_EXSTENSION = ".apk";
private static final String APP_EXTENSION = ".apk";
private static final String APP_MIME_TYPE = "application/application";

private final String mSharingComponent;
private AppShareabilityManager mShareabilityMgr;

private AppSharing(Launcher launcher) {
mSharingComponent = launcher.getText(R.string.app_sharing_component).toString();
String sharingComponent = Settings.Secure.getString(launcher.getContentResolver(),
Settings.Secure.NEARBY_SHARING_COMPONENT);
mSharingComponent = TextUtils.isEmpty(sharingComponent) ? launcher.getText(
R.string.app_sharing_component).toString() : sharingComponent;
}

private Uri getShareableUri(Context context, String path, String displayName) {
Expand Down Expand Up @@ -147,7 +151,7 @@ public void onClick(View view) {
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
sourceDir = packageInfo.applicationInfo.sourceDir;
appLabel = packageManager.getApplicationLabel(packageInfo.applicationInfo)
.toString() + APP_EXSTENSION;
+ APP_EXTENSION;
} catch (Exception e) {
Log.e(TAG, "Could not find info for package \"" + packageName + "\"");
return;
Expand Down Expand Up @@ -175,9 +179,7 @@ private void onStatusUpdated(boolean success) {
return;
}
checkShareability(/* requestUpdateIfUnknown */ false);
mTarget.runOnUiThread(() -> {
mPopupDataProvider.redrawSystemShortcuts();
});
mTarget.runOnUiThread(mPopupDataProvider::redrawSystemShortcuts);
}

private void checkShareability(boolean requestUpdateIfUnknown) {
Expand Down

0 comments on commit b3c7d2e

Please sign in to comment.