Merge "Extending the grid migration logic to handle density changes" into ub-launcher3-master
diff --git a/Android.mk b/Android.mk
index cb6e5f0..1dde46b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -50,42 +50,21 @@
include $(BUILD_PACKAGE)
#
-# Protocol Buffer Debug Utility in Java
+# Launcher proto buffer jar used for development
#
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-java-files-under, util) \
- $(call all-proto-files-under, protos)
+LOCAL_SRC_FILES := $(call all-proto-files-under, protos)
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := launcher_protoutil_lib
+LOCAL_MODULE := launcher_proto_lib
LOCAL_IS_HOST_MODULE := true
-LOCAL_JAR_MANIFEST := util/etc/manifest.txt
-LOCAL_STATIC_JAVA_LIBRARIES := host-libprotobuf-java-2.3.0-nano
+LOCAL_STATIC_JAVA_LIBRARIES := host-libprotobuf-java-nano
include $(BUILD_HOST_JAVA_LIBRARY)
-#
-# Protocol Buffer Debug Utility Wrapper Script
-#
-include $(CLEAR_VARS)
-LOCAL_IS_HOST_MODULE := true
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := launcher_protoutil
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): launcher_protoutil_lib
-$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/util/etc/launcher_protoutil | $(ACP)
- @echo "Copy: $(PRIVATE_MODULE) ($@)"
- $(copy-file-to-new-target)
- $(hide) chmod 755 $@
-
-INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE)
-
# ==================================================
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/protos/backup.proto b/protos/backup.proto
index 6704e08..c3f27e1 100644
--- a/protos/backup.proto
+++ b/protos/backup.proto
@@ -18,7 +18,7 @@
package launcher_backup;
-option java_package = "com.android.launcher3.backup";
+option java_package = "com.android.launcher3.backup.nano";
option java_outer_classname = "BackupProtos";
message Key {
diff --git a/res/xml/default_workspace_3x3.xml b/res/xml/default_workspace_3x3.xml
new file mode 100644
index 0000000..8d99404
--- /dev/null
+++ b/res/xml/default_workspace_3x3.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+
+<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3">
+
+ <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
+ <!-- Messaging, [All Apps], Dialer -->
+
+ <resolve
+ launcher:container="-101"
+ launcher:screen="0"
+ launcher:x="0"
+ launcher:y="0" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MESSAGING;end" />
+ <favorite launcher:uri="sms:" />
+ <favorite launcher:uri="smsto:" />
+ <favorite launcher:uri="mms:" />
+ <favorite launcher:uri="mmsto:" />
+ </resolve>
+
+ <!-- All Apps -->
+
+ <resolve
+ launcher:container="-101"
+ launcher:screen="2"
+ launcher:x="2"
+ launcher:y="0" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.DIAL;end" />
+ <favorite launcher:uri="tel:123" />
+ <favorite launcher:uri="#Intent;action=android.intent.action.CALL_BUTTON;end" />
+ </resolve>
+
+ <!-- Bottom row -->
+ <resolve
+ launcher:screen="0"
+ launcher:x="0"
+ launcher:y="-1" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" />
+ <favorite launcher:uri="mailto:" />
+ </resolve>
+
+ <resolve
+ launcher:screen="0"
+ launcher:x="1"
+ launcher:y="-1" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />
+ <favorite launcher:uri="#Intent;type=images/*;end" />
+ </resolve>
+
+ <resolve
+ launcher:screen="0"
+ launcher:x="2"
+ launcher:y="-1" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />
+ <favorite launcher:uri="market://details?id=com.android.launcher" />
+ </resolve>
+
+ <!-- Second last row -->
+ <resolve
+ launcher:screen="0"
+ launcher:x="0"
+ launcher:y="-2" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_BROWSER;end" />
+ <favorite launcher:uri="http://www.example.com/" />
+ </resolve>
+
+ <resolve
+ launcher:screen="0"
+ launcher:x="2"
+ launcher:y="-2" >
+ <favorite launcher:uri="#Intent;action=android.media.action.STILL_IMAGE_CAMERA;end" />
+ <favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" />
+ </resolve>
+
+</favorites>
diff --git a/res/xml/default_workspace_4x4.xml b/res/xml/default_workspace_4x4.xml
index 060a1f8..979a1b4 100644
--- a/res/xml/default_workspace_4x4.xml
+++ b/res/xml/default_workspace_4x4.xml
@@ -23,7 +23,7 @@
<resolve
launcher:screen="0"
launcher:x="0"
- launcher:y="3" >
+ launcher:y="-1" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" />
<favorite launcher:uri="mailto:" />
</resolve>
@@ -31,7 +31,7 @@
<resolve
launcher:screen="0"
launcher:x="1"
- launcher:y="3" >
+ launcher:y="-1" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />
<favorite launcher:uri="#Intent;type=images/*;end" />
</resolve>
@@ -39,7 +39,7 @@
<resolve
launcher:screen="0"
launcher:x="3"
- launcher:y="3" >
+ launcher:y="-1" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />
<favorite launcher:uri="market://details?id=com.android.launcher" />
</resolve>
diff --git a/res/xml/default_workspace_5x5.xml b/res/xml/default_workspace_5x5.xml
index 3226617..f9cc0e7 100644
--- a/res/xml/default_workspace_5x5.xml
+++ b/res/xml/default_workspace_5x5.xml
@@ -23,7 +23,7 @@
<resolve
launcher:screen="0"
launcher:x="0"
- launcher:y="4" >
+ launcher:y="-1" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" />
<favorite launcher:uri="mailto:" />
@@ -32,7 +32,7 @@
<resolve
launcher:screen="0"
launcher:x="1"
- launcher:y="4" >
+ launcher:y="-1" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />
<favorite launcher:uri="#Intent;type=images/*;end" />
@@ -41,7 +41,7 @@
<resolve
launcher:screen="0"
launcher:x="4"
- launcher:y="4" >
+ launcher:y="-1" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />
<favorite launcher:uri="market://details?id=com.android.launcher" />
</resolve>
diff --git a/res/xml/default_workspace_5x6.xml b/res/xml/default_workspace_5x6.xml
index bc236fb..8493c26 100644
--- a/res/xml/default_workspace_5x6.xml
+++ b/res/xml/default_workspace_5x6.xml
@@ -23,13 +23,13 @@
<favorite
launcher:screen="0"
launcher:x="0"
- launcher:y="4"
+ launcher:y="-1"
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_CONTACTS;end" />
<resolve
launcher:screen="0"
- launcher:x="5"
- launcher:y="4" >
+ launcher:x="-1"
+ launcher:y="-1" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />
<favorite launcher:uri="market://details?id=com.android.launcher" />
</resolve>
diff --git a/src/com/android/launcher3/AutoInstallsLayout.java b/src/com/android/launcher3/AutoInstallsLayout.java
index 440e4e7..0d71a0c 100644
--- a/src/com/android/launcher3/AutoInstallsLayout.java
+++ b/src/com/android/launcher3/AutoInstallsLayout.java
@@ -125,8 +125,12 @@
private static final String ATTR_CLASS_NAME = "className";
private static final String ATTR_TITLE = "title";
private static final String ATTR_SCREEN = "screen";
+
+ // x and y can be specified as negative integers, in which case -1 represents the
+ // last row / column, -2 represents the second last, and so on.
private static final String ATTR_X = "x";
private static final String ATTR_Y = "y";
+
private static final String ATTR_SPAN_X = "spanX";
private static final String ATTR_SPAN_Y = "spanY";
private static final String ATTR_ICON = "icon";
@@ -154,6 +158,8 @@
protected final int mLayoutId;
private final int mHotseatAllAppsRank;
+ private final int mRowCount;
+ private final int mColumnCount;
private final long[] mTemp = new long[2];
@Thunk final ContentValues mValues;
@@ -164,13 +170,6 @@
public AutoInstallsLayout(Context context, AppWidgetHost appWidgetHost,
LayoutParserCallback callback, Resources res,
int layoutId, String rootTag) {
- this(context, appWidgetHost, callback, res, layoutId, rootTag,
- LauncherAppState.getInstance().getInvariantDeviceProfile().hotseatAllAppsRank);
- }
-
- public AutoInstallsLayout(Context context, AppWidgetHost appWidgetHost,
- LayoutParserCallback callback, Resources res,
- int layoutId, String rootTag, int hotseatAllAppsRank) {
mContext = context;
mAppWidgetHost = appWidgetHost;
mCallback = callback;
@@ -181,7 +180,11 @@
mSourceRes = res;
mLayoutId = layoutId;
- mHotseatAllAppsRank = hotseatAllAppsRank;
+
+ InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile();
+ mHotseatAllAppsRank = idp.hotseatAllAppsRank;
+ mRowCount = idp.numRows;
+ mColumnCount = idp.numColumns;
}
/**
@@ -261,8 +264,11 @@
mValues.put(Favorites.CONTAINER, container);
mValues.put(Favorites.SCREEN, screenId);
- mValues.put(Favorites.CELLX, getAttributeValue(parser, ATTR_X));
- mValues.put(Favorites.CELLY, getAttributeValue(parser, ATTR_Y));
+
+ mValues.put(Favorites.CELLX,
+ convertToDistanceFromEnd(getAttributeValue(parser, ATTR_X), mColumnCount));
+ mValues.put(Favorites.CELLY,
+ convertToDistanceFromEnd(getAttributeValue(parser, ATTR_Y), mRowCount));
TagParser tagParser = tagParserMap.get(parser.getName());
if (tagParser == null) {
@@ -648,6 +654,16 @@
}
}
+ private static String convertToDistanceFromEnd(String value, int endValue) {
+ if (!TextUtils.isEmpty(value)) {
+ int x = Integer.parseInt(value);
+ if (x < 0) {
+ return Integer.toString(endValue + x);
+ }
+ }
+ return value;
+ }
+
/**
* Return attribute value, attempting launcher-specific namespace first
* before falling back to anonymous attribute.
diff --git a/src/com/android/launcher3/CommonAppTypeParser.java b/src/com/android/launcher3/CommonAppTypeParser.java
index 5314ecf..001e044 100644
--- a/src/com/android/launcher3/CommonAppTypeParser.java
+++ b/src/com/android/launcher3/CommonAppTypeParser.java
@@ -25,7 +25,7 @@
import com.android.launcher3.AutoInstallsLayout.LayoutParserCallback;
import com.android.launcher3.LauncherSettings.Favorites;
-import com.android.launcher3.backup.BackupProtos.Favorite;
+import com.android.launcher3.backup.nano.BackupProtos.Favorite;
import com.android.launcher3.util.Thunk;
import org.xmlpull.v1.XmlPullParserException;
@@ -93,7 +93,7 @@
public MyLayoutParser() {
super(CommonAppTypeParser.this.mContext, null, CommonAppTypeParser.this,
- CommonAppTypeParser.this.mContext.getResources(), mResId, TAG_RESOLVE, 0);
+ CommonAppTypeParser.this.mContext.getResources(), mResId, TAG_RESOLVE);
}
@Override
diff --git a/src/com/android/launcher3/DefaultLayoutParser.java b/src/com/android/launcher3/DefaultLayoutParser.java
index 7b91c67..2bba380 100644
--- a/src/com/android/launcher3/DefaultLayoutParser.java
+++ b/src/com/android/launcher3/DefaultLayoutParser.java
@@ -48,9 +48,8 @@
}
public DefaultLayoutParser(Context context, AppWidgetHost appWidgetHost,
- LayoutParserCallback callback, Resources sourceRes, int layoutId, String rootTag,
- int hotseatAllAppsRank) {
- super(context, appWidgetHost, callback, sourceRes, layoutId, rootTag, hotseatAllAppsRank);
+ LayoutParserCallback callback, Resources sourceRes, int layoutId, String rootTag) {
+ super(context, appWidgetHost, callback, sourceRes, layoutId, rootTag);
}
@Override
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 56c0192..dce1ab8 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -173,9 +173,9 @@
// width, height, #rows, #columns, #folder rows, #folder columns,
// iconSize, iconTextSize, #hotseat, #hotseatIconSize, defaultLayoutId.
predefinedDeviceProfiles.add(new InvariantDeviceProfile("Super Short Stubby",
- 255, 300, 2, 3, 2, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4));
+ 255, 300, 2, 3, 2, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_3x3));
predefinedDeviceProfiles.add(new InvariantDeviceProfile("Shorter Stubby",
- 255, 400, 3, 3, 3, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4));
+ 255, 400, 3, 3, 3, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_3x3));
predefinedDeviceProfiles.add(new InvariantDeviceProfile("Short Stubby",
275, 420, 3, 4, 3, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4));
predefinedDeviceProfiles.add(new InvariantDeviceProfile("Stubby",
@@ -196,7 +196,7 @@
predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 10",
727, 1207, 5, 6, 4, 5, 4, 76, 14.4f, 7, 76, R.xml.default_workspace_5x6));
predefinedDeviceProfiles.add(new InvariantDeviceProfile("20-inch Tablet",
- 1527, 2527, 7, 7, 6, 6, 4, 100, 20, 7, 72, R.xml.default_workspace_4x4));
+ 1527, 2527, 7, 7, 6, 6, 4, 100, 20, 7, 72, R.xml.default_workspace_5x6));
return predefinedDeviceProfiles;
}
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index 4ebead5..5f58e28 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -41,15 +41,15 @@
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherSettings.WorkspaceScreens;
-import com.android.launcher3.backup.BackupProtos;
-import com.android.launcher3.backup.BackupProtos.CheckedMessage;
-import com.android.launcher3.backup.BackupProtos.DeviceProfieData;
-import com.android.launcher3.backup.BackupProtos.Favorite;
-import com.android.launcher3.backup.BackupProtos.Journal;
-import com.android.launcher3.backup.BackupProtos.Key;
-import com.android.launcher3.backup.BackupProtos.Resource;
-import com.android.launcher3.backup.BackupProtos.Screen;
-import com.android.launcher3.backup.BackupProtos.Widget;
+import com.android.launcher3.backup.nano.BackupProtos;
+import com.android.launcher3.backup.nano.BackupProtos.CheckedMessage;
+import com.android.launcher3.backup.nano.BackupProtos.DeviceProfieData;
+import com.android.launcher3.backup.nano.BackupProtos.Favorite;
+import com.android.launcher3.backup.nano.BackupProtos.Journal;
+import com.android.launcher3.backup.nano.BackupProtos.Key;
+import com.android.launcher3.backup.nano.BackupProtos.Resource;
+import com.android.launcher3.backup.nano.BackupProtos.Screen;
+import com.android.launcher3.backup.nano.BackupProtos.Widget;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.model.GridSizeMigrationTask;
diff --git a/util/com/android/launcher3/DecoderRing.java b/util/com/android/launcher3/DecoderRing.java
deleted file mode 100644
index 0732fe8..0000000
--- a/util/com/android/launcher3/DecoderRing.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (C) 2013 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.launcher3;
-
-import com.android.launcher3.backup.BackupProtos.CheckedMessage;
-import com.android.launcher3.backup.BackupProtos.Favorite;
-import com.android.launcher3.backup.BackupProtos.Key;
-import com.android.launcher3.backup.BackupProtos.Journal;
-import com.android.launcher3.backup.BackupProtos.Resource;
-import com.android.launcher3.backup.BackupProtos.Screen;
-import com.android.launcher3.backup.BackupProtos.Widget;
-
-import com.google.protobuf.nano.InvalidProtocolBufferNanoException;
-import com.google.protobuf.nano.MessageNano;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.System;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.zip.CRC32;
-
-import javax.xml.bind.DatatypeConverter;
-
-
-/**
- * Commandline utility for decoding Launcher3 backup protocol buffers.
- *
- * <P>When using com.android.internal.backup.LocalTransport, the file names are base64-encoded Key
- * protocol buffers with a prefix, that have been base64-encoded again by the transport:
- * <pre>
- * echo "TDpDQUlnL0pxVTVnOD0=" | launcher_protoutil -k
- * </pre>
- *
- * <P>This tool understands these file names and will use the embedded Key to detect the type and
- * extract the payload automatically:
- * <pre>
- * launcher_protoutil /tmp/TDpDQUlnL0pxVTVnOD0=
- * </pre>
- *
- * <P>With payload debugging enabled, base64-encoded protocol buffers will be written to the logs.
- * Copy the encoded snippet from the log, and specify the type explicitly, with the Logs flags:
- * <pre>
- * echo "CAEYLiCJ9JKsDw==" | launcher_protoutil -L -k
- * </pre>
- * For backup payloads it is more convenient to copy the log snippet to a file:
- * <pre>
- * launcher_protoutil -L -f favorite.log
- * </pre>
- */
-class DecoderRing {
-
- public static final String STANDARD_IN = "**stdin**";
-
- private static Class[] TYPES = {
- Key.class,
- Favorite.class,
- Screen.class,
- Resource.class,
- Widget.class
- };
- static final int ICON_TYPE_BITMAP = 1;
-
- public static void main(String[ ] args)
- throws Exception {
- Class defaultType = null;
- boolean extractImages = false;
- boolean fromLogs = false;
- int skip = 0;
- List<File> files = new LinkedList<File>();
- boolean verbose = false;
-
- for (int i = 0; i < args.length; i++) {
- if ("-k".equals(args[i])) {
- defaultType = Key.class;
- } else if ("-f".equals(args[i])) {
- defaultType = Favorite.class;
- } else if ("-j".equals(args[i])) {
- defaultType = Journal.class;
- } else if ("-i".equals(args[i])) {
- defaultType = Resource.class;
- } else if ("-s".equals(args[i])) {
- defaultType = Screen.class;
- } else if ("-w".equals(args[i])) {
- defaultType = Widget.class;
- } else if ("-S".equals(args[i])) {
- if ((i + 1) < args.length) {
- skip = Integer.valueOf(args[++i]);
- } else {
- usage(args);
- }
- } else if ("-x".equals(args[i])) {
- extractImages = true;
- } else if ("-v".equals(args[i])) {
- verbose = true;
- } else if ("-L".equals(args[i])) {
- fromLogs = true;
- } else if (args[i] != null && !args[i].startsWith("-")) {
- files.add(new File(args[i]));
- } else {
- System.err.println("Unsupported flag: " + args[i]);
- usage(args);
- }
- }
-
- if (defaultType == null && files.isEmpty()) {
- // can't infer file type without the key
- usage(args);
- }
-
- if (files.size() > 1 && defaultType != null) {
- System.err.println("Explicit type ignored for multiple files.");
- defaultType = null;
- }
-
- if (files.isEmpty()) {
- files.add(new File(STANDARD_IN));
- }
-
- for (File source : files) {
- Class type = null;
- if (defaultType == null) {
- Key key = decodeKey(source.getName().getBytes(), fromLogs);
- if (key != null) {
- type = TYPES[key.type];
- if (verbose) {
- System.err.println(source.getName() + " is a " + type.getSimpleName());
- System.out.println(key.toString());
- }
- }
- } else {
- type = defaultType;
- }
-
- // read in the bytes
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- BufferedInputStream input = null;
- if (source.getName() == STANDARD_IN) {
- input = new BufferedInputStream(System.in);
- } else {
- try {
- input = new BufferedInputStream(new FileInputStream(source));
- } catch (FileNotFoundException e) {
- System.err.println("failed to open file: " + source + ", " + e);
- System.exit(1);
- }
- }
- byte[] buffer = new byte[1024];
- try {
- while (input.available() > 0) {
- int n = input.read(buffer);
- int offset = 0;
- if (skip > 0) {
- offset = Math.min(skip, n);
- n -= offset;
- skip -= offset;
- }
- if (n > 0) {
- byteStream.write(buffer, offset, n);
- }
- }
- } catch (IOException e) {
- System.err.println("failed to read input: " + e);
- System.exit(1);
- }
-
- MessageNano proto = null;
- byte[] payload = byteStream.toByteArray();
- if (type == Key.class) {
- proto = decodeKey(payload, fromLogs);
- } else if (type != null) {
- proto = decodeBackupData(payload, type, fromLogs);
- }
-
- // Generic string output
- if (proto != null) {
- System.out.println(proto.toString());
- }
-
- if (extractImages) {
- String prefix = "stdin";
- if (source != null) {
- prefix = source.getName();
- }
- // save off the icon bits in a file for inspection
- if (proto instanceof Resource) {
- Resource icon = (Resource) proto;
- writeImageData(icon.data, prefix + ".png");
- }
-
- // save off the icon bits in a file for inspection
- if (proto instanceof Favorite) {
- Favorite favorite = (Favorite) proto;
- if (favorite.iconType == ICON_TYPE_BITMAP) {
- writeImageData(favorite.icon, prefix + ".png");
- }
- }
-
- // save off the widget icon and preview bits in files for inspection
- if (proto instanceof Widget) {
- Widget widget = (Widget) proto;
- if (widget.icon != null) {
- writeImageData(widget.icon.data, prefix + "_icon.png");
- }
- }
- }
- }
- System.exit(0);
- }
-
- // In logcat, backup data is base64 encoded, but in localtransport files it is raw
- private static MessageNano decodeBackupData(byte[] payload, Class type, boolean fromLogs)
- throws InstantiationException, IllegalAccessException {
- MessageNano proto;// other types are wrapped in a checksum message
- CheckedMessage wrapper = new CheckedMessage();
- try {
- if (fromLogs) {
- payload = DatatypeConverter.parseBase64Binary(new String(payload));
- }
- MessageNano.mergeFrom(wrapper, payload);
- } catch (InvalidProtocolBufferNanoException e) {
- System.err.println("failed to parse wrapper: " + e);
- System.exit(1);
- }
-
- CRC32 checksum = new CRC32();
- checksum.update(wrapper.payload);
- if (wrapper.checksum != checksum.getValue()) {
- System.err.println("wrapper checksum failed");
- System.exit(1);
- }
-
- // decode the actual message
- proto = (MessageNano) type.newInstance();
- try {
- MessageNano.mergeFrom(proto, wrapper.payload);
- } catch (InvalidProtocolBufferNanoException e) {
- System.err.println("failed to parse proto: " + e);
- System.exit(1);
- }
- return proto;
- }
-
- // In logcat, keys are base64 encoded with no prefix.
- // The localtransport adds a prefix and the base64 encodes the whole thing again.
- private static Key decodeKey(byte[] payload, boolean fromLogs) {
- Key key = new Key();
- try {
- String encodedKey = new String(payload);
- if (!fromLogs) {
- byte[] rawKey = DatatypeConverter.parseBase64Binary(encodedKey);
- if (rawKey[0] != 'L' || rawKey[1] != ':') {
- System.err.println(encodedKey + " is not a launcher backup key.");
- return null;
- }
- encodedKey = new String(rawKey, 2, rawKey.length - 2);
- }
- byte[] keyProtoData = DatatypeConverter.parseBase64Binary(encodedKey);
- key = Key.parseFrom(keyProtoData);
- } catch (InvalidProtocolBufferNanoException protoException) {
- System.err.println("failed to extract key from filename: " + protoException);
- return null;
- } catch (IllegalArgumentException base64Exception) {
- System.err.println("failed to extract key from filename: " + base64Exception);
- return null;
- }
-
- // keys are self-checked
- if (key.checksum != checkKey(key)) {
- System.err.println("key ckecksum failed");
- return null;
- }
- return key;
- }
-
- private static void writeImageData(byte[] data, String path) {
- FileOutputStream iconFile = null;
- try {
- iconFile = new FileOutputStream(path);
- iconFile.write(data);
- System.err.println("wrote " + path);
- } catch (IOException e) {
- System.err.println("failed to write image file: " + e);
- } finally {
- if (iconFile != null) {
- try {
- iconFile.close();
- } catch (IOException e) {
- System.err.println("failed to close the image file: " + e);
- }
- }
- }
- }
-
- private static long checkKey(Key key) {
- CRC32 checksum = new CRC32();
- checksum.update(key.type);
- checksum.update((int) (key.id & 0xffff));
- checksum.update((int) ((key.id >> 32) & 0xffff));
- if (key.name != null && key.name.length() > 0) {
- checksum.update(key.name.getBytes());
- }
- return checksum.getValue();
- }
-
- private static void usage(String[] args) {
- System.err.println("launcher_protoutil [-x] [-S b] [-k|-f|-i|-s|-w] [filename]");
- System.err.println("\t-k\tdecode a key");
- System.err.println("\t-f\tdecode a favorite");
- System.err.println("\t-i\tdecode a icon");
- System.err.println("\t-s\tdecode a screen");
- System.err.println("\t-w\tdecode a widget");
- System.err.println("\t-S b\tskip b bytes");
- System.err.println("\t-x\textract image data to files");
- System.err.println("\t-v\tprint key type data, as well as payload");
- System.err.println("\t-l\texpect data from logcat, instead of the local transport");
- System.err.println("\tfilename\tread from filename, not stdin");
- System.exit(1);
- }
-}
\ No newline at end of file
diff --git a/util/etc/launcher_protoutil b/util/etc/launcher_protoutil
deleted file mode 100644
index 833b583..0000000
--- a/util/etc/launcher_protoutil
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2013 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.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=launcher_protoutil_lib.jar
-libdir="$progdir"
-
-if [ ! -r "$libdir/$jarfile" ]; then
- # set jar location for the Android tree case
- libdir=`dirname "$progdir"`/framework
-fi
-
-if [ ! -r "$libdir/$jarfile" ]; then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-# By default, give decoder a max heap size of 1 gig. This can be overridden
-# by using a "-J" option (see below).
-defaultMx="-Xmx1024M"
-
-# The following will extract any initial parameters of the form
-# "-J<stuff>" from the command line and pass them to the Java
-# invocation (instead of to the decoder). This makes it possible for
-# you to add a command-line parameter such as "-JXmx256M" in your
-# scripts, for example. "java" (with no args) and "java -X" give a
-# summary of available options.
-
-javaOpts=""
-
-while expr "x$1" : 'x-J' >/dev/null; do
- opt=`expr "x$1" : 'x-J\(.*\)'`
- javaOpts="${javaOpts} -${opt}"
- if expr "x${opt}" : "xXmx[0-9]" >/dev/null; then
- defaultMx="no"
- fi
- shift
-done
-
-if [ "${defaultMx}" != "no" ]; then
- javaOpts="${javaOpts} ${defaultMx}"
-fi
-
-if [ "$OSTYPE" = "cygwin" ]; then
- # For Cygwin, convert the jarfile path into native Windows style.
- jarpath=`cygpath -w "$libdir/$jarfile"`
-else
- jarpath="$libdir/$jarfile"
-fi
-
-exec java $javaOpts -jar "$jarpath" "$@"
diff --git a/util/etc/manifest.txt b/util/etc/manifest.txt
deleted file mode 100644
index 84842ed..0000000
--- a/util/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.launcher3.DecoderRing