[Settings] Set different ringtones at work profile
Updated the Settings app to allow setting different default system
ringtones for work profile apps
Bug: 30658854
Change-Id: I7461be070bd4e8d86bf1fd724039e53d500094ad
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 0725386..bbf9823 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1160,4 +1160,17 @@
}
return false;
}
+
+ /**
+ * Returns a context created from the given context for the given user, or null if it fails
+ */
+ public static Context createPackageContextAsUser(Context context, int userId) {
+ try {
+ return context.createPackageContextAsUser(
+ context.getPackageName(), 0 /* flags */, UserHandle.of(userId));
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Failed to create user context", e);
+ }
+ return null;
+ }
}