Merge "Removing Launcher broadcast support from Launcher3" into ub-launcher3-calgary
This commit is contained in:
@@ -40,10 +40,6 @@
|
||||
android:protectionLevel="signatureOrSystem"
|
||||
android:label="@string/permlab_write_settings"
|
||||
android:description="@string/permdesc_write_settings"/>
|
||||
<permission
|
||||
android:name="com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS"
|
||||
android:protectionLevel="signature"
|
||||
/>
|
||||
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||
@@ -55,7 +51,6 @@
|
||||
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS" />
|
||||
<uses-permission android:name="com.android.launcher3.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS" />
|
||||
|
||||
<application
|
||||
android:allowBackup="@bool/enable_backup"
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
<!-- URI used to import old favorites. [DO NOT TRANSLATE] -->
|
||||
<string name="old_launcher_provider_uri" translatable="false">content://com.android.launcher2.settings/favorites?notify=true</string>
|
||||
|
||||
<!-- Permission to receive the com.android.launcher3.action.LAUNCH intent. [DO NOT TRANSLATE] -->
|
||||
<string name="receive_launch_broadcasts_permission" translatable="false">com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS</string>
|
||||
|
||||
<!-- Application name -->
|
||||
<string name="app_name">Launcher3</string>
|
||||
<!-- Default folder name -->
|
||||
|
||||
@@ -113,7 +113,6 @@ import com.android.launcher3.logging.UserEventLogger;
|
||||
import com.android.launcher3.model.WidgetsModel;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.LongArrayMap;
|
||||
import com.android.launcher3.util.TestingUtils;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.util.ViewOnDrawExecutor;
|
||||
@@ -642,7 +641,7 @@ public class Launcher extends Activity
|
||||
mUserEventLogger = mLauncherCallbacks.getLogger();
|
||||
}
|
||||
if (mUserEventLogger == null) {
|
||||
mUserEventLogger = new UserEventLogger(this) {
|
||||
mUserEventLogger = new UserEventLogger() {
|
||||
@Override
|
||||
public void processEvent(LauncherLogProto.LauncherEvent ev) {
|
||||
if (!DEBUG_LOGGING) {
|
||||
|
||||
@@ -16,25 +16,17 @@
|
||||
|
||||
package com.android.launcher3.logging;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
|
||||
import com.google.protobuf.nano.MessageNano;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class UserEventLogger {
|
||||
@@ -79,14 +71,6 @@ public abstract class UserEventLogger {
|
||||
}
|
||||
|
||||
private String TAG = "UserEventLogger";
|
||||
private static final boolean DEBUG_BROADCASTS = true;
|
||||
|
||||
public static final String ACTION_LAUNCH = "com.android.launcher3.action.LAUNCH";
|
||||
public static final String EXTRA_INTENT = "intent";;
|
||||
public static final String EXTRA_SOURCE = "source";
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final String mLaunchBroadcastPermission;
|
||||
|
||||
private long mElapsedContainerMillis;
|
||||
private long mElapsedSessionMillis;
|
||||
@@ -95,27 +79,6 @@ public abstract class UserEventLogger {
|
||||
// Used for filling in predictedRank on {@link Target}s.
|
||||
private List<ComponentKey> mPredictedApps;
|
||||
|
||||
public UserEventLogger(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
mLaunchBroadcastPermission =
|
||||
launcher.getResources().getString(R.string.receive_launch_broadcasts_permission);
|
||||
|
||||
if (DEBUG_BROADCASTS) {
|
||||
launcher.registerReceiver(
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.v(TAG, "got broadcast: " + intent + " for launched intent: "
|
||||
+ intent.getStringExtra(EXTRA_INTENT));
|
||||
}
|
||||
},
|
||||
new IntentFilter(ACTION_LAUNCH),
|
||||
mLaunchBroadcastPermission,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// APP_ICON SHORTCUT WIDGET
|
||||
// --------------------------------------------------------------
|
||||
// packageNameHash required optional required
|
||||
@@ -123,26 +86,7 @@ public abstract class UserEventLogger {
|
||||
// intentHash required
|
||||
// --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prepare {@link LauncherEvent} and {@link Intent} and then attach the event
|
||||
* to the intent and then broadcast.
|
||||
*/
|
||||
public final void broadcastEvent(LauncherEvent ev, Intent intent) {
|
||||
intent = new Intent(intent);
|
||||
intent.setSourceBounds(null);
|
||||
|
||||
final String flat = intent.toUri(0);
|
||||
Intent broadcastIntent = new Intent(ACTION_LAUNCH).putExtra(EXTRA_INTENT, flat);
|
||||
|
||||
broadcastIntent.putExtra(EXTRA_SOURCE, MessageNano.toByteArray(ev));
|
||||
String[] packages = ((Context)mLauncher).getResources().getStringArray(R.array.launch_broadcast_targets);
|
||||
for(String p: packages) {
|
||||
broadcastIntent.setPackage(p);
|
||||
mLauncher.sendBroadcast(broadcastIntent, mLaunchBroadcastPermission);
|
||||
}
|
||||
}
|
||||
|
||||
public final void logLaunch(View v, Intent intent) {
|
||||
protected LauncherEvent createLogEvent(View v) {
|
||||
LauncherEvent event = LoggerUtils.initLauncherEvent(
|
||||
Action.TOUCH, Target.ITEM, Target.CONTAINER);
|
||||
event.action.touch = Action.TAP;
|
||||
@@ -158,9 +102,11 @@ public abstract class UserEventLogger {
|
||||
// Fill in the duration of time spent navigating in Launcher and the container.
|
||||
event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
|
||||
event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
|
||||
processEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
broadcastEvent(event, intent);
|
||||
public void logLaunch(View v, Intent intent) {
|
||||
processEvent(createLogEvent(v));
|
||||
}
|
||||
|
||||
public void logTap(View v) {
|
||||
|
||||
Reference in New Issue
Block a user