Loading Android.mk +13 −3 Original line number Diff line number Diff line LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(call all-logtags-files-under, src) LOCAL_MODULE := settings-logtags include $(BUILD_STATIC_JAVA_LIBRARY) # Build the Settings APK include $(CLEAR_VARS) LOCAL_JAVA_LIBRARIES := bouncycastle core-oj telephony-common ims-common LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-v4 \ Loading @@ -9,13 +19,13 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-v7-preference \ android-support-v7-appcompat \ android-support-v14-preference \ jsr305 jsr305 \ settings-logtags LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := \ $(call all-java-files-under, src) \ src/com/android/settings/EventLogTags.logtags $(call all-java-files-under, src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \ frameworks/support/v7/preference/res \ Loading proguard.flags +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ -keep class com.android.settings.users.* -keep class com.android.settings.nfc.* -keep class com.android.settings.notification.* -keep class com.android.settings.overlay.FeatureFactoryImpl -keep class com.android.settings.accessibility.*FragmentForSetupWizard -keep class com.android.settings.display.*FragmentForSetupWizard Loading res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,6 @@ <!-- When true enable color temperature setting. --> <bool name="config_enableColorTemperature">false</bool> <!-- Fully-qualified class name for the implementation of the FeatureFactory to be instantiated. --> <string name="config_featureFactory" translatable="false">com.android.settings.overlay.FeatureFactoryImpl</string> </resources> src/com/android/settings/SettingsActivity.java +4 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import com.android.settings.notification.ZenModePrioritySettings; import com.android.settings.notification.ZenModeScheduleRuleSettings; import com.android.settings.notification.ZenModeSettings; import com.android.settings.notification.ZenModeVisualInterruptionSettings; import com.android.settings.overlay.FeatureFactory; import com.android.settings.print.PrintJobSettingsFragment; import com.android.settings.print.PrintSettingsFragment; import com.android.settings.search.DynamicIndexableContentMonitor; Loading Loading @@ -687,6 +688,9 @@ public class SettingsActivity extends SettingsDrawerActivity } } // Will remove this line before submitting. FeatureFactory.getFactory(this).createToastController().makeToast(this); if (DEBUG_TIMING) Log.d(LOG_TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms"); } Loading src/com/android/settings/overlay/FeatureFactory.java 0 → 100644 +73 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.overlay; import android.content.Context; import android.text.TextUtils; import android.util.Log; import com.android.settings.R; /** * Abstract class for creating feature controllers. Allows OEM implementations to define their own * factories with their own controllers containing whatever code is needed to implement * the features. To provide a factory implementation, implementors should override * {@link R.string#config_featureFactory} in their override. */ public abstract class FeatureFactory { private static final String LOG_TAG = "FeatureFactory"; private static final boolean DEBUG = false; private static FeatureFactory sFactory; /** * Returns a factory for creating feature controllers. Creates the factory if it does not * already exist. Uses the value of {@link R.string#config_featureFactory} to instantiate * a factory implementation. */ public static FeatureFactory getFactory(Context context) { if (sFactory != null) { return sFactory; } if (DEBUG) Log.d(LOG_TAG, "getFactory"); final String clsName = context.getString(R.string.config_featureFactory); if (TextUtils.isEmpty(clsName)) { throw new UnsupportedOperationException("No feature factory configured"); } try { sFactory = (FeatureFactory) context.getClassLoader().loadClass(clsName).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new FactoryNotFoundException(e); } if (DEBUG) Log.d(LOG_TAG, "started " + sFactory.getClass().getSimpleName()); return sFactory; } /** * Creates stub controller that makes {@link android.widget.Toast}s. * Will be removed before submitting. */ public abstract ToastController createToastController(); public static class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); } } } Loading
Android.mk +13 −3 Original line number Diff line number Diff line LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(call all-logtags-files-under, src) LOCAL_MODULE := settings-logtags include $(BUILD_STATIC_JAVA_LIBRARY) # Build the Settings APK include $(CLEAR_VARS) LOCAL_JAVA_LIBRARIES := bouncycastle core-oj telephony-common ims-common LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-v4 \ Loading @@ -9,13 +19,13 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-v7-preference \ android-support-v7-appcompat \ android-support-v14-preference \ jsr305 jsr305 \ settings-logtags LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := \ $(call all-java-files-under, src) \ src/com/android/settings/EventLogTags.logtags $(call all-java-files-under, src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \ frameworks/support/v7/preference/res \ Loading
proguard.flags +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ -keep class com.android.settings.users.* -keep class com.android.settings.nfc.* -keep class com.android.settings.notification.* -keep class com.android.settings.overlay.FeatureFactoryImpl -keep class com.android.settings.accessibility.*FragmentForSetupWizard -keep class com.android.settings.display.*FragmentForSetupWizard Loading
res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,6 @@ <!-- When true enable color temperature setting. --> <bool name="config_enableColorTemperature">false</bool> <!-- Fully-qualified class name for the implementation of the FeatureFactory to be instantiated. --> <string name="config_featureFactory" translatable="false">com.android.settings.overlay.FeatureFactoryImpl</string> </resources>
src/com/android/settings/SettingsActivity.java +4 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import com.android.settings.notification.ZenModePrioritySettings; import com.android.settings.notification.ZenModeScheduleRuleSettings; import com.android.settings.notification.ZenModeSettings; import com.android.settings.notification.ZenModeVisualInterruptionSettings; import com.android.settings.overlay.FeatureFactory; import com.android.settings.print.PrintJobSettingsFragment; import com.android.settings.print.PrintSettingsFragment; import com.android.settings.search.DynamicIndexableContentMonitor; Loading Loading @@ -687,6 +688,9 @@ public class SettingsActivity extends SettingsDrawerActivity } } // Will remove this line before submitting. FeatureFactory.getFactory(this).createToastController().makeToast(this); if (DEBUG_TIMING) Log.d(LOG_TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms"); } Loading
src/com/android/settings/overlay/FeatureFactory.java 0 → 100644 +73 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.overlay; import android.content.Context; import android.text.TextUtils; import android.util.Log; import com.android.settings.R; /** * Abstract class for creating feature controllers. Allows OEM implementations to define their own * factories with their own controllers containing whatever code is needed to implement * the features. To provide a factory implementation, implementors should override * {@link R.string#config_featureFactory} in their override. */ public abstract class FeatureFactory { private static final String LOG_TAG = "FeatureFactory"; private static final boolean DEBUG = false; private static FeatureFactory sFactory; /** * Returns a factory for creating feature controllers. Creates the factory if it does not * already exist. Uses the value of {@link R.string#config_featureFactory} to instantiate * a factory implementation. */ public static FeatureFactory getFactory(Context context) { if (sFactory != null) { return sFactory; } if (DEBUG) Log.d(LOG_TAG, "getFactory"); final String clsName = context.getString(R.string.config_featureFactory); if (TextUtils.isEmpty(clsName)) { throw new UnsupportedOperationException("No feature factory configured"); } try { sFactory = (FeatureFactory) context.getClassLoader().loadClass(clsName).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new FactoryNotFoundException(e); } if (DEBUG) Log.d(LOG_TAG, "started " + sFactory.getClass().getSimpleName()); return sFactory; } /** * Creates stub controller that makes {@link android.widget.Toast}s. * Will be removed before submitting. */ public abstract ToastController createToastController(); public static class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); } } }