Merge "Use old API only if no share targets are published"

This commit is contained in:
Mehdi Alizadeh
2019-01-25 00:37:26 +00:00
committed by Android (Google) Code Review
5 changed files with 42 additions and 0 deletions

View File

@@ -76,4 +76,6 @@ interface IShortcutService {
// System API used by framework's ShareSheet (ChooserActivity)
ParceledListSlice getShareTargets(String packageName, in IntentFilter filter, int userId);
boolean hasShareTargets(String packageName, String packageToCheck, int userId);
}

View File

@@ -635,4 +635,21 @@ public class ShortcutManager {
}
};
}
/**
* Used by framework's ShareSheet (ChooserActivity.java) to check if a given package has share
* target definitions in it's resources.
*
* @param packageName Package to check for share targets.
* @return True if the package has any share target definitions, False otherwise.
* @hide
*/
public boolean hasShareTargets(@NonNull String packageName) {
try {
return mService.hasShareTargets(mContext.getPackageName(), packageName,
injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}