Loading core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -1710,6 +1710,15 @@ public final class Settings { /** @hide - Private call() method to reset to defaults the 'secure' table */ public static final String CALL_METHOD_RESET_SECURE = "RESET_secure"; /** @hide - Private call() method to query the 'system' table */ public static final String CALL_METHOD_LIST_SYSTEM = "LIST_system"; /** @hide - Private call() method to query the 'secure' table */ public static final String CALL_METHOD_LIST_SECURE = "LIST_secure"; /** @hide - Private call() method to query the 'global' table */ public static final String CALL_METHOD_LIST_GLOBAL = "LIST_global"; /** * Activity Extra: Limit available options in launched activity based on the given authority. * <p> Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +36 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ public class SettingsProvider extends ContentProvider { Settings.NameValueTable.VALUE, null); public static final String RESULT_ROWS_DELETED = "result_rows_deleted"; public static final String RESULT_SETTINGS_LIST = "result_settings_list"; // Overlay specified settings whitelisted for Instant Apps private static final Set<String> OVERLAY_ALLOWED_GLOBAL_INSTANT_APP_SETTINGS = new ArraySet<>(); Loading Loading @@ -483,6 +484,27 @@ public class SettingsProvider extends ContentProvider { return result; } case Settings.CALL_METHOD_LIST_SYSTEM: { Bundle result = new Bundle(); result.putStringArrayList(RESULT_SETTINGS_LIST, buildSettingsList(getAllSystemSettings(requestingUserId, null))); return result; } case Settings.CALL_METHOD_LIST_SECURE: { Bundle result = new Bundle(); result.putStringArrayList(RESULT_SETTINGS_LIST, buildSettingsList(getAllSecureSettings(requestingUserId, null))); return result; } case Settings.CALL_METHOD_LIST_GLOBAL: { Bundle result = new Bundle(); result.putStringArrayList(RESULT_SETTINGS_LIST, buildSettingsList(getAllGlobalSettings(null))); return result; } default: { Slog.w(LOG_TAG, "call() with invalid method: " + method); } break; Loading Loading @@ -552,6 +574,20 @@ public class SettingsProvider extends ContentProvider { } } private ArrayList<String> buildSettingsList(Cursor cursor) { final ArrayList<String> lines = new ArrayList<String>(); try { while (cursor != null && cursor.moveToNext()) { lines.add(cursor.getString(1) + "=" + cursor.getString(2)); } } finally { if (cursor != null) { cursor.close(); } } return lines; } @Override public Uri insert(Uri uri, ContentValues values) { if (DEBUG) { Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsService.java +15 −25 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ package com.android.providers.settings; import android.app.ActivityManager; import android.content.IContentProvider; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.Process; Loading Loading @@ -265,9 +263,6 @@ final public class SettingsService extends Binder { } if (mUser < 0) { mUser = UserHandle.USER_SYSTEM; } else if (mVerb == CommandVerb.LIST) { perr.println("--user not supported for list."); return -1; } UserManager userManager = UserManager.get(mProvider.getContext()); if (userManager.getUserInfo(mUser) == null) { Loading Loading @@ -304,27 +299,22 @@ final public class SettingsService extends Binder { return 0; } private List<String> listForUser(IContentProvider provider, int userHandle, String table) { final Uri uri = "system".equals(table) ? Settings.System.CONTENT_URI : "secure".equals(table) ? Settings.Secure.CONTENT_URI : "global".equals(table) ? Settings.Global.CONTENT_URI : null; final ArrayList<String> lines = new ArrayList<String>(); if (uri == null) { return lines; List<String> listForUser(IContentProvider provider, int userHandle, String table) { final String callListCommand; if ("system".equals(table)) callListCommand = Settings.CALL_METHOD_LIST_SYSTEM; else if ("secure".equals(table)) callListCommand = Settings.CALL_METHOD_LIST_SECURE; else if ("global".equals(table)) callListCommand = Settings.CALL_METHOD_LIST_GLOBAL; else { getErrPrintWriter().println("Invalid table; no list performed"); throw new IllegalArgumentException("Invalid table " + table); } final ArrayList<String> lines = new ArrayList<String>(); try { final Cursor cursor = provider.query(resolveCallingPackage(), uri, null, null, null); try { while (cursor != null && cursor.moveToNext()) { lines.add(cursor.getString(1) + "=" + cursor.getString(2)); } } finally { if (cursor != null) { cursor.close(); } } Bundle arg = new Bundle(); arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle); Bundle result = provider.call(resolveCallingPackage(), callListCommand, null, arg); lines.addAll(result.getStringArrayList(SettingsProvider.RESULT_SETTINGS_LIST)); Collections.sort(lines); } catch (RemoteException e) { throw new RuntimeException("Failed in IPC", e); Loading Loading @@ -483,7 +473,7 @@ final public class SettingsService extends Binder { pw.println(" reset [--user <USER_ID> | current] NAMESPACE {PACKAGE_NAME | RESET_MODE}"); pw.println(" Reset the global/secure table for a package with mode."); pw.println(" RESET_MODE is one of {untrusted_defaults, untrusted_clear, trusted_defaults}, case-insensitive"); pw.println(" list NAMESPACE"); pw.println(" list [--user <USER_ID> | current] NAMESPACE"); pw.println(" Print all defined keys."); pw.println(" NAMESPACE is one of {system, secure, global}, case-insensitive"); } Loading Loading
core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -1710,6 +1710,15 @@ public final class Settings { /** @hide - Private call() method to reset to defaults the 'secure' table */ public static final String CALL_METHOD_RESET_SECURE = "RESET_secure"; /** @hide - Private call() method to query the 'system' table */ public static final String CALL_METHOD_LIST_SYSTEM = "LIST_system"; /** @hide - Private call() method to query the 'secure' table */ public static final String CALL_METHOD_LIST_SECURE = "LIST_secure"; /** @hide - Private call() method to query the 'global' table */ public static final String CALL_METHOD_LIST_GLOBAL = "LIST_global"; /** * Activity Extra: Limit available options in launched activity based on the given authority. * <p> Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +36 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ public class SettingsProvider extends ContentProvider { Settings.NameValueTable.VALUE, null); public static final String RESULT_ROWS_DELETED = "result_rows_deleted"; public static final String RESULT_SETTINGS_LIST = "result_settings_list"; // Overlay specified settings whitelisted for Instant Apps private static final Set<String> OVERLAY_ALLOWED_GLOBAL_INSTANT_APP_SETTINGS = new ArraySet<>(); Loading Loading @@ -483,6 +484,27 @@ public class SettingsProvider extends ContentProvider { return result; } case Settings.CALL_METHOD_LIST_SYSTEM: { Bundle result = new Bundle(); result.putStringArrayList(RESULT_SETTINGS_LIST, buildSettingsList(getAllSystemSettings(requestingUserId, null))); return result; } case Settings.CALL_METHOD_LIST_SECURE: { Bundle result = new Bundle(); result.putStringArrayList(RESULT_SETTINGS_LIST, buildSettingsList(getAllSecureSettings(requestingUserId, null))); return result; } case Settings.CALL_METHOD_LIST_GLOBAL: { Bundle result = new Bundle(); result.putStringArrayList(RESULT_SETTINGS_LIST, buildSettingsList(getAllGlobalSettings(null))); return result; } default: { Slog.w(LOG_TAG, "call() with invalid method: " + method); } break; Loading Loading @@ -552,6 +574,20 @@ public class SettingsProvider extends ContentProvider { } } private ArrayList<String> buildSettingsList(Cursor cursor) { final ArrayList<String> lines = new ArrayList<String>(); try { while (cursor != null && cursor.moveToNext()) { lines.add(cursor.getString(1) + "=" + cursor.getString(2)); } } finally { if (cursor != null) { cursor.close(); } } return lines; } @Override public Uri insert(Uri uri, ContentValues values) { if (DEBUG) { Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsService.java +15 −25 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ package com.android.providers.settings; import android.app.ActivityManager; import android.content.IContentProvider; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.Process; Loading Loading @@ -265,9 +263,6 @@ final public class SettingsService extends Binder { } if (mUser < 0) { mUser = UserHandle.USER_SYSTEM; } else if (mVerb == CommandVerb.LIST) { perr.println("--user not supported for list."); return -1; } UserManager userManager = UserManager.get(mProvider.getContext()); if (userManager.getUserInfo(mUser) == null) { Loading Loading @@ -304,27 +299,22 @@ final public class SettingsService extends Binder { return 0; } private List<String> listForUser(IContentProvider provider, int userHandle, String table) { final Uri uri = "system".equals(table) ? Settings.System.CONTENT_URI : "secure".equals(table) ? Settings.Secure.CONTENT_URI : "global".equals(table) ? Settings.Global.CONTENT_URI : null; final ArrayList<String> lines = new ArrayList<String>(); if (uri == null) { return lines; List<String> listForUser(IContentProvider provider, int userHandle, String table) { final String callListCommand; if ("system".equals(table)) callListCommand = Settings.CALL_METHOD_LIST_SYSTEM; else if ("secure".equals(table)) callListCommand = Settings.CALL_METHOD_LIST_SECURE; else if ("global".equals(table)) callListCommand = Settings.CALL_METHOD_LIST_GLOBAL; else { getErrPrintWriter().println("Invalid table; no list performed"); throw new IllegalArgumentException("Invalid table " + table); } final ArrayList<String> lines = new ArrayList<String>(); try { final Cursor cursor = provider.query(resolveCallingPackage(), uri, null, null, null); try { while (cursor != null && cursor.moveToNext()) { lines.add(cursor.getString(1) + "=" + cursor.getString(2)); } } finally { if (cursor != null) { cursor.close(); } } Bundle arg = new Bundle(); arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle); Bundle result = provider.call(resolveCallingPackage(), callListCommand, null, arg); lines.addAll(result.getStringArrayList(SettingsProvider.RESULT_SETTINGS_LIST)); Collections.sort(lines); } catch (RemoteException e) { throw new RuntimeException("Failed in IPC", e); Loading Loading @@ -483,7 +473,7 @@ final public class SettingsService extends Binder { pw.println(" reset [--user <USER_ID> | current] NAMESPACE {PACKAGE_NAME | RESET_MODE}"); pw.println(" Reset the global/secure table for a package with mode."); pw.println(" RESET_MODE is one of {untrusted_defaults, untrusted_clear, trusted_defaults}, case-insensitive"); pw.println(" list NAMESPACE"); pw.println(" list [--user <USER_ID> | current] NAMESPACE"); pw.println(" Print all defined keys."); pw.println(" NAMESPACE is one of {system, secure, global}, case-insensitive"); } Loading