From 9da385fc3d4f06d24b58d8748cdf2ac2c13d0180 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Mon, 3 Sep 2018 17:42:22 +0100 Subject: [PATCH] LocationSettingsActivity: Send broadcast as user * Specify the user the broadcast will be sent to, in order to avoid the warnings as seen in the logs: W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1531 android.content.ContextWrapper.startService:664 org.lineageos.setupwizard.SetupWizardExitActivity.onCreate:53 android.app.Activity.performCreate:7136 android.app.Activity.performCreate:7127 Change-Id: I26a0b4ab2dc94bbe6eff065875901bf347aec85b --- src/org/lineageos/setupwizard/LocationSettingsActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/lineageos/setupwizard/LocationSettingsActivity.java b/src/org/lineageos/setupwizard/LocationSettingsActivity.java index 27bc08cb..b90f11bb 100644 --- a/src/org/lineageos/setupwizard/LocationSettingsActivity.java +++ b/src/org/lineageos/setupwizard/LocationSettingsActivity.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 The CyanogenMod Project - * Copyright (C) 2017 The LineageOS Project + * Copyright (C) 2017-2018 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package org.lineageos.setupwizard; import android.content.ContentResolver; import android.content.Intent; import android.os.Bundle; +import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import android.view.View; @@ -128,7 +129,8 @@ public class LocationSettingsActivity extends BaseSetupWizardActivity { Intent intent = new Intent(MODE_CHANGING_ACTION); intent.putExtra(CURRENT_MODE_KEY, mCurrentMode); intent.putExtra(NEW_MODE_KEY, mode); - sendBroadcast(intent, android.Manifest.permission.WRITE_SECURE_SETTINGS); + sendBroadcastAsUser(intent, new UserHandle(UserHandle.USER_CURRENT), + android.Manifest.permission.WRITE_SECURE_SETTINGS); Settings.Secure.putInt(mContentResolver, Settings.Secure.LOCATION_MODE, mode); refreshLocationMode(); }