Skip to content

Instantly share code, notes, and snippets.

void WebApkInstaller::OnHaveSufficientSpaceForInstall() {
if (install_from_webapk_service_) {
DCHECK(!serialized_webapk_.get()->empty());
// We already have a serialized WebAPK request, so we can skip fetching the
// icons and building the proto.
const net::NetworkTrafficAnnotationTag
traffic_annotation_install_from_service =
net::DefineNetworkTrafficAnnotation("webapk_create_for_service", R"(
semantics {
void WebApkInstaller::InstallAsync(content::WebContents* web_contents,
const webapps::ShortcutInfo& shortcut_info,
const SkBitmap& primary_icon,
FinishCallback finish_callback) {
DCHECK(!install_from_webapk_service_);
install_duration_timer_ = std::make_unique<base::ElapsedTimer>();
web_contents_ = web_contents->GetWeakPtr();
install_shortcut_info_ =
std::make_unique<webapps::ShortcutInfo>(shortcut_info);
void WebApkInstallService::InstallAsync(
content::WebContents* web_contents,
const webapps::ShortcutInfo& shortcut_info,
const SkBitmap& primary_icon,
webapps::WebappInstallSource install_source) {
if (IsInstallInProgress(shortcut_info.manifest_id)) {
webapps::WebappsUtils::ShowWebApkInstallResultToast(
webapps::WebApkInstallResult::INSTALL_ALREADY_IN_PROGRESS);
return;
}
void ChromeWebappsClient::InstallWebApk(content::WebContents* web_contents,
const AddToHomescreenParams& params) {
WebApkInstallService::Get(web_contents->GetBrowserContext())
->InstallAsync(web_contents, *(params.shortcut_info), params.primary_icon,
params.install_source);
}
void AddToHomescreenInstaller::Install(
content::WebContents* web_contents,
const AddToHomescreenParams& params,
const base::RepeatingCallback<void(Event, const AddToHomescreenParams&)>&
event_callback) {
if (!web_contents) {
event_callback.Run(Event::INSTALL_FAILED, params);
return;
}
void AddToHomescreenMediator::AddToHomescreen(
JNIEnv* env,
const JavaParamRef<jstring>& j_user_title) {
if (!params_ || GetWebContents() == nullptr)
return;
if (params_->app_type == AddToHomescreenParams::AppType::SHORTCUT) {
params_->shortcut_info->user_title =
base::android::ConvertJavaStringToUTF16(env, j_user_title);
} else if (params_->app_type == AddToHomescreenParams::AppType::WEBAPK) {
public void onAddToHomescreen(String title) {
if (mNativeAddToHomescreenMediator == 0) return;
AddToHomescreenMediatorJni.get().addToHomescreen(mNativeAddToHomescreenMediator, title);
destroyNative();
}
@Override
public void onClick(PropertyModel model, int buttonType) {
int dismissalCause = DialogDismissalCause.NEGATIVE_BUTTON_CLICKED;
if (buttonType == ModalDialogProperties.ButtonType.POSITIVE) {
mDelegate.onAddToHomescreen(mShortcutTitleInput.getText().toString());
dismissalCause = DialogDismissalCause.POSITIVE_BUTTON_CLICKED;
}
mModalDialogManager.dismissDialog(mDialogModel, dismissalCause);
}
<html>
<body>
<script src='remote-server/jsBridge-mix.js'> //host the jsBridge-mix.js from resources directory
JsBridge.invoke("get_session_data", {}, function(a) { //the a variable will contain the response JSON object from the Java code
var i = {};
i = a;
window.alert(JSON.stringify(i);
})
</script>
</body>
Java.perform(function() {
console.log("Starting hook");
var Activity = Java.use("com.xiaomi.music.hybrid.internal.PermissionManager");
Activity.isValid.implementation = function () {
return true;
};
Java.choose("com.xiaomi.music.hybrid.internal.Config", {
onMatch: function(inst) {