Show RingtonePickerActivity in work user instead

Test: make RunSettingsRoboTests
Test: Try to import custom ringtone in work profile, no crash observed
Test: Set the custom ringtone as default. Tested both work gmail and
      calendar can play that ringtone.
Test: Try to import the peresonal ringtone, it is still working.

Bug: 37197930
Change-Id: I2b662247d7e70b59bae08e082e9682d74d797484
This commit is contained in:
Tony Mak
2017-04-11 20:07:39 +01:00
parent 44cfdcc9a7
commit 007dc1abe6
4 changed files with 42 additions and 29 deletions

View File

@@ -22,6 +22,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.UserHandle;
import android.preference.SeekBarVolumizer;
import android.provider.SearchIndexableResource;
import android.support.v7.preference.Preference;
@@ -85,7 +86,11 @@ public class SoundSettings extends DashboardFragment {
if (preference instanceof RingtonePreference) {
mRequestPreference = (RingtonePreference) preference;
mRequestPreference.onPrepareRingtonePickerIntent(mRequestPreference.getIntent());
startActivityForResult(preference.getIntent(), REQUEST_CODE);
startActivityForResultAsUser(
mRequestPreference.getIntent(),
REQUEST_CODE,
null,
UserHandle.of(mRequestPreference.getUserId()));
return true;
}
return super.onPreferenceTreeClick(preference);