Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2da0c582 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Add system wide management of core settings"

parents f99c91c9 54d068ec
Loading
Loading
Loading
Loading
+34 −2
Original line number Original line Diff line number Diff line
@@ -98,7 +98,6 @@ import java.util.TimeZone;
import java.util.regex.Pattern;
import java.util.regex.Pattern;


import dalvik.system.CloseGuard;
import dalvik.system.CloseGuard;
import dalvik.system.SamplingProfiler;


final class SuperNotCalledException extends AndroidRuntimeException {
final class SuperNotCalledException extends AndroidRuntimeException {
    public SuperNotCalledException(String msg) {
    public SuperNotCalledException(String msg) {
@@ -355,6 +354,7 @@ public final class ActivityThread {
        boolean restrictedBackupMode;
        boolean restrictedBackupMode;
        Configuration config;
        Configuration config;
        boolean handlingProfiling;
        boolean handlingProfiling;
        Bundle coreSettings;
        public String toString() {
        public String toString() {
            return "AppBindData{appInfo=" + appInfo + "}";
            return "AppBindData{appInfo=" + appInfo + "}";
        }
        }
@@ -552,7 +552,7 @@ public final class ActivityThread {
                ComponentName instrumentationName, String profileFile,
                ComponentName instrumentationName, String profileFile,
                Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
                Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
                int debugMode, boolean isRestrictedBackupMode, Configuration config,
                int debugMode, boolean isRestrictedBackupMode, Configuration config,
                Map<String, IBinder> services) {
                Map<String, IBinder> services, Bundle coreSettings) {


            if (services != null) {
            if (services != null) {
                // Setup the service cache in the ServiceManager
                // Setup the service cache in the ServiceManager
@@ -570,6 +570,7 @@ public final class ActivityThread {
            data.debugMode = debugMode;
            data.debugMode = debugMode;
            data.restrictedBackupMode = isRestrictedBackupMode;
            data.restrictedBackupMode = isRestrictedBackupMode;
            data.config = config;
            data.config = config;
            data.coreSettings = coreSettings;
            queueOrSendMessage(H.BIND_APPLICATION, data);
            queueOrSendMessage(H.BIND_APPLICATION, data);
        }
        }


@@ -896,6 +897,10 @@ public final class ActivityThread {
        private void printRow(PrintWriter pw, String format, Object...objs) {
        private void printRow(PrintWriter pw, String format, Object...objs) {
            pw.println(String.format(format, objs));
            pw.println(String.format(format, objs));
        }
        }

        public void setCoreSettings(Bundle settings) {
            queueOrSendMessage(H.SET_CORE_SETTINGS, settings);
        }
    }
    }


    private final class H extends Handler {
    private final class H extends Handler {
@@ -937,6 +942,7 @@ public final class ActivityThread {
        public static final int DUMP_HEAP               = 135;
        public static final int DUMP_HEAP               = 135;
        public static final int DUMP_ACTIVITY           = 136;
        public static final int DUMP_ACTIVITY           = 136;
        public static final int SLEEPING                = 137;
        public static final int SLEEPING                = 137;
        public static final int SET_CORE_SETTINGS       = 138;
        String codeToString(int code) {
        String codeToString(int code) {
            if (DEBUG_MESSAGES) {
            if (DEBUG_MESSAGES) {
                switch (code) {
                switch (code) {
@@ -978,6 +984,7 @@ public final class ActivityThread {
                    case DUMP_HEAP: return "DUMP_HEAP";
                    case DUMP_HEAP: return "DUMP_HEAP";
                    case DUMP_ACTIVITY: return "DUMP_ACTIVITY";
                    case DUMP_ACTIVITY: return "DUMP_ACTIVITY";
                    case SLEEPING: return "SLEEPING";
                    case SLEEPING: return "SLEEPING";
                    case SET_CORE_SETTINGS: return "SET_CORE_SETTINGS";
                }
                }
            }
            }
            return "(unknown)";
            return "(unknown)";
@@ -1113,6 +1120,9 @@ public final class ActivityThread {
                case SLEEPING:
                case SLEEPING:
                    handleSleeping((IBinder)msg.obj, msg.arg1 != 0);
                    handleSleeping((IBinder)msg.obj, msg.arg1 != 0);
                    break;
                    break;
                case SET_CORE_SETTINGS:
                    handleSetCoreSettings((Bundle) msg.obj);
                    break;
            }
            }
            if (DEBUG_MESSAGES) Slog.v(TAG, "<<< done: " + msg.what);
            if (DEBUG_MESSAGES) Slog.v(TAG, "<<< done: " + msg.what);
        }
        }
@@ -2709,6 +2719,14 @@ public final class ActivityThread {
        }
        }
    }
    }


    private void handleSetCoreSettings(Bundle coreSettings) {
        if (mBoundApplication != null) {
            synchronized (mBoundApplication) {
                mBoundApplication.coreSettings = coreSettings;
            }
        }
    }

    private final void deliverResults(ActivityClientRecord r, List<ResultInfo> results) {
    private final void deliverResults(ActivityClientRecord r, List<ResultInfo> results) {
        final int N = results.size();
        final int N = results.size();
        for (int i=0; i<N; i++) {
        for (int i=0; i<N; i++) {
@@ -3971,6 +3989,20 @@ public final class ActivityThread {
        }
        }
    }
    }


    public int getIntCoreSetting(String key, int defaultValue) {
        if (mBoundApplication == null) {
            return defaultValue;
        }
        synchronized (mBoundApplication) {
            Bundle coreSettings = mBoundApplication.coreSettings;
            if (coreSettings != null) {
                return coreSettings.getInt(key, defaultValue);
            } else {
                return defaultValue;
            }
        }
    }

    public static final void main(String[] args) {
    public static final void main(String[] args) {
        SamplingProfilerIntegration.start();
        SamplingProfilerIntegration.start();


+13 −2
Original line number Original line Diff line number Diff line
@@ -41,9 +41,20 @@ public class AppGlobals {


    /**
    /**
     * Return the raw interface to the package manager.
     * Return the raw interface to the package manager.
     * @return
     * @return The package manager.
     */
     */
    public static IPackageManager getPackageManager() {
    public static IPackageManager getPackageManager() {
        return ActivityThread.getPackageManager();
        return ActivityThread.getPackageManager();
    }
    }

    /**
     * Gets the value of an integer core setting.
     *
     * @param key The setting key.
     * @param defaultValue The setting default value.
     * @return The core settings.
     */
    public static int getIntCoreSetting(String key, int defaultValue) {
        return ActivityThread.currentActivityThread().getIntCoreSetting(key, defaultValue);
    }
}
}
+18 −2
Original line number Original line Diff line number Diff line
@@ -257,10 +257,11 @@ public abstract class ApplicationThreadNative extends Binder
            boolean restrictedBackupMode = (data.readInt() != 0);
            boolean restrictedBackupMode = (data.readInt() != 0);
            Configuration config = Configuration.CREATOR.createFromParcel(data);
            Configuration config = Configuration.CREATOR.createFromParcel(data);
            HashMap<String, IBinder> services = data.readHashMap(null);
            HashMap<String, IBinder> services = data.readHashMap(null);
            Bundle coreSettings = data.readBundle();
            bindApplication(packageName, info,
            bindApplication(packageName, info,
                            providers, testName, profileName,
                            providers, testName, profileName,
                            testArgs, testWatcher, testMode, restrictedBackupMode,
                            testArgs, testWatcher, testMode, restrictedBackupMode,
                            config, services);
                            config, services, coreSettings);
            return true;
            return true;
        }
        }
        
        
@@ -454,6 +455,13 @@ public abstract class ApplicationThreadNative extends Binder
            }
            }
            return true;
            return true;
        }
        }

        case SET_CORE_SETTINGS: {
            data.enforceInterface(IApplicationThread.descriptor);
            Bundle settings = data.readBundle();
            setCoreSettings(settings);
            return true;
        }
        }
        }


        return super.onTransact(code, data, reply, flags);
        return super.onTransact(code, data, reply, flags);
@@ -712,7 +720,7 @@ class ApplicationThreadProxy implements IApplicationThread {
            List<ProviderInfo> providers, ComponentName testName,
            List<ProviderInfo> providers, ComponentName testName,
            String profileName, Bundle testArgs, IInstrumentationWatcher testWatcher, int debugMode,
            String profileName, Bundle testArgs, IInstrumentationWatcher testWatcher, int debugMode,
            boolean restrictedBackupMode, Configuration config,
            boolean restrictedBackupMode, Configuration config,
            Map<String, IBinder> services) throws RemoteException {
            Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeString(packageName);
        data.writeString(packageName);
@@ -731,6 +739,7 @@ class ApplicationThreadProxy implements IApplicationThread {
        data.writeInt(restrictedBackupMode ? 1 : 0);
        data.writeInt(restrictedBackupMode ? 1 : 0);
        config.writeToParcel(data, 0);
        config.writeToParcel(data, 0);
        data.writeMap(services);
        data.writeMap(services);
        data.writeBundle(coreSettings);
        mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null,
        mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null,
                IBinder.FLAG_ONEWAY);
                IBinder.FLAG_ONEWAY);
        data.recycle();
        data.recycle();
@@ -938,4 +947,11 @@ class ApplicationThreadProxy implements IApplicationThread {
        mRemote.transact(DUMP_ACTIVITY_TRANSACTION, data, null, 0);
        mRemote.transact(DUMP_ACTIVITY_TRANSACTION, data, null, 0);
        data.recycle();
        data.recycle();
    }
    }

    public void setCoreSettings(Bundle coreSettings) throws RemoteException {
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeBundle(coreSettings);
        mRemote.transact(SET_CORE_SETTINGS, data, null, IBinder.FLAG_ONEWAY);
    }
}
}
+4 −1
Original line number Original line Diff line number Diff line
@@ -82,7 +82,8 @@ public interface IApplicationThread extends IInterface {
    void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers,
    void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers,
            ComponentName testName, String profileName, Bundle testArguments, 
            ComponentName testName, String profileName, Bundle testArguments, 
            IInstrumentationWatcher testWatcher, int debugMode, boolean restrictedBackupMode,
            IInstrumentationWatcher testWatcher, int debugMode, boolean restrictedBackupMode,
            Configuration config, Map<String, IBinder> services) throws RemoteException;
            Configuration config, Map<String, IBinder> services,
            Bundle coreSettings) throws RemoteException;
    void scheduleExit() throws RemoteException;
    void scheduleExit() throws RemoteException;
    void scheduleSuicide() throws RemoteException;
    void scheduleSuicide() throws RemoteException;
    void requestThumbnail(IBinder token) throws RemoteException;
    void requestThumbnail(IBinder token) throws RemoteException;
@@ -110,6 +111,7 @@ public interface IApplicationThread extends IInterface {
    void scheduleCrash(String msg) throws RemoteException;
    void scheduleCrash(String msg) throws RemoteException;
    void dumpActivity(FileDescriptor fd, IBinder servicetoken, String prefix, String[] args)
    void dumpActivity(FileDescriptor fd, IBinder servicetoken, String prefix, String[] args)
            throws RemoteException;
            throws RemoteException;
    void setCoreSettings(Bundle coreSettings) throws RemoteException;


    String descriptor = "android.app.IApplicationThread";
    String descriptor = "android.app.IApplicationThread";


@@ -151,4 +153,5 @@ public interface IApplicationThread extends IInterface {
    int DUMP_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+36;
    int DUMP_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+36;
    int CLEAR_DNS_CACHE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+37;
    int CLEAR_DNS_CACHE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+37;
    int SET_HTTP_PROXY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+38;
    int SET_HTTP_PROXY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+38;
    int SET_CORE_SETTINGS = IBinder.FIRST_CALL_TRANSACTION+39;
}
}
+6 −0
Original line number Original line Diff line number Diff line
@@ -2697,6 +2697,12 @@ public final class Settings {
        public static final String ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS =
        public static final String ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS =
            "accessibility_web_content_key_bindings";
            "accessibility_web_content_key_bindings";


        /**
         * The timout for considering a press to be a long press in milliseconds.
         * @hide
         */
        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";

        /**
        /**
         * Setting to always use the default text-to-speech settings regardless
         * Setting to always use the default text-to-speech settings regardless
         * of the application settings.
         * of the application settings.
Loading