summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-05-11 21:30:53 (GMT)
committercretin45 <cretin45@gmail.com>2016-05-11 21:34:31 (GMT)
commitfe7faac0dba67667ae671e6cf59c9706d45e579b (patch)
tree928127e76657943188750f53e5479885b45d485e
parenta5eada884d8aca0bb387fc898487e0978d7f0461 (diff)
downloadandroid_packages_apps_Trebuchet-fe7faac0dba67667ae671e6cf59c9706d45e579b.zip
android_packages_apps_Trebuchet-fe7faac0dba67667ae671e6cf59c9706d45e579b.tar.gz
android_packages_apps_Trebuchet-fe7faac0dba67667ae671e6cf59c9706d45e579b.tar.bz2
Trebuchet: Make workspace layout configurable by prebundled mcc
Ported patch: http://review.cyanogenmod.org/#/c/111725/ Issue-id: PAELLA-236 Change-Id: I1d02cfc4f1e7e7fc5b1aaf326072b0ffe8966c05
-rw-r--r--src/com/android/launcher3/LauncherProvider.java49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 0273cbb..84ebe54 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -30,7 +30,10 @@ import android.content.Context;
import android.content.Intent;
import android.content.OperationApplicationException;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.AssetManager;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.SQLException;
@@ -44,8 +47,10 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.StrictMode;
+import android.os.SystemProperties;
import android.os.UserManager;
import android.text.TextUtils;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
@@ -79,6 +84,8 @@ public class LauncherProvider extends ContentProvider {
private static final String RESTRICTION_PACKAGE_NAME = "workspace.configuration.package.name";
+ private static final String MCC_PROP_NAME = "ro.prebundled.mcc";
+
@Thunk LauncherProviderChangeListener mListener;
@Thunk DatabaseHelper mOpenHelper;
@@ -442,10 +449,50 @@ public class LauncherProvider extends ContentProvider {
}
private DefaultLayoutParser getDefaultLayoutParser() {
+ String mcc = SystemProperties.get(MCC_PROP_NAME);
+ Resources customResources = null;
+ if (!TextUtils.isEmpty(mcc)) {
+ if (LOGD) Log.d(TAG, "mcc: " + mcc);
+
+ Configuration tempConfiguration = new Configuration(getContext().getResources().
+ getConfiguration());
+ boolean shouldUseTempConfig = false;
+
+ try {
+ tempConfiguration.mcc = Integer.parseInt(mcc);
+ shouldUseTempConfig = true;
+ } catch (NumberFormatException e) {
+ // not able to parse mcc, catch exception and exit out of this logic
+ Log.e(TAG, "Unable to parse mcc", e);
+ }
+
+ if (shouldUseTempConfig) {
+ String publicSrcDir = null;
+ try {
+ String packageName = getContext().getPackageName();
+ publicSrcDir = getContext().getPackageManager().
+ getApplicationInfo(packageName, 0).publicSourceDir;
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Failed getting source dir", e);
+ }
+
+ AssetManager assetManager = new AssetManager();
+ if (!TextUtils.isEmpty(publicSrcDir)) {
+ assetManager.addAssetPath(publicSrcDir);
+ }
+ customResources = new Resources(assetManager, new DisplayMetrics(),
+ tempConfiguration);
+ }
+ }
+
int defaultLayout = LauncherAppState.getInstance()
.getInvariantDeviceProfile().defaultLayoutId;
+
return new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
- mOpenHelper, getContext().getResources(), defaultLayout);
+ mOpenHelper, customResources != null ?
+ customResources :
+ getContext().getResources(),
+ defaultLayout);
}
public void migrateLauncher2Shortcuts() {