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

Commit 02ffba94 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Handle finished bugreports, share from private.

Show notification when a bugreport is finished, letting the user
launch a SEND_MULTIPLE intent to share them.  Add dialog that warns
user about contents before sharing.  Since bugreports are now stored
in private app data of the Shell app, use FileProvider to build Uris
that we can grant others access to.

Define BUGREPORT_FINISHED as being a protected broadcast.  Delete
older bugreports automatically to reclaim disk space.  Migrate any
Intent extras to ClipData when building PendingIntents.

Add --receiver-permission support to am shell command.

Bug: 7005318
Change-Id: If6c607dbcf137362d5887eac482ff7391563890f
parent 998b692d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class Am {

    private int mRepeat = 0;
    private int mUserId;
    private String mReceiverPermission;

    private String mProfileFile;

@@ -332,6 +333,8 @@ public class Am {
                mStartFlags |= ActivityManager.START_FLAG_OPENGL_TRACES;
            } else if (opt.equals("--user")) {
                mUserId = parseUserArg(nextArgRequired());
            } else if (opt.equals("--receiver-permission")) {
                mReceiverPermission = nextArgRequired();
            } else {
                System.err.println("Error: Unknown option: " + opt);
                return null;
@@ -608,7 +611,7 @@ public class Am {
        Intent intent = makeIntent(UserHandle.USER_ALL);
        IntentReceiver receiver = new IntentReceiver();
        System.out.println("Broadcasting: " + intent);
        mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, null,
        mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, mReceiverPermission,
                android.app.AppOpsManager.OP_NONE, true, false, mUserId);
        receiver.waitForFinish();
    }
@@ -1408,6 +1411,7 @@ public class Am {
                "am broadcast: send a broadcast Intent.  Options are:\n" +
                "    --user <USER_ID> | all | current: Specify which user to send to; if not\n" +
                "        specified then send to all users.\n" +
                "    --receiver-permission <PERMISSION>: Require receiver to hold permission.\n" +
                "\n" +
                "am instrument: start an Instrumentation.  Typically this target <COMPONENT>\n" +
                "  is the form <TEST_PACKAGE>/<RUNNER_CLASS>.  Options are:\n" +
+2 −0
Original line number Diff line number Diff line
@@ -261,6 +261,7 @@ public final class PendingIntent implements Parcelable {
                context.getContentResolver()) : null;
        try {
            intent.setAllowFds(false);
            intent.migrateExtraStreamToClipData();
            IIntentSender target =
                ActivityManagerNative.getDefault().getIntentSender(
                    ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
@@ -285,6 +286,7 @@ public final class PendingIntent implements Parcelable {
                context.getContentResolver()) : null;
        try {
            intent.setAllowFds(false);
            intent.migrateExtraStreamToClipData();
            IIntentSender target =
                ActivityManagerNative.getDefault().getIntentSender(
                    ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+1 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@
    <protected-broadcast android:name="android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE" />
    <protected-broadcast android:name="android.intent.action.AIRPLANE_MODE" />
    <protected-broadcast android:name="android.intent.action.ADVANCED_SETTINGS" />
    <protected-broadcast android:name="android.intent.action.BUGREPORT_FINISHED" />

    <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_START" />
    <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_END" />
+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4

LOCAL_PACKAGE_NAME := Shell
LOCAL_CERTIFICATE := platform

+27 −2
Original line number Diff line number Diff line
@@ -68,7 +68,32 @@
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
    <uses-permission android:name="android.permission.MANAGE_USERS" />
    <uses-permission android:name="android.permission.BLUETOOTH_STACK" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <application android:hasCode="false" android:label="@string/app_label">
    <application android:label="@string/app_label">
        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.android.shell"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_provider_paths" />
        </provider>

        <activity
            android:name=".BugreportWarningActivity"
            android:theme="@*android:style/Theme.Holo.Dialog.Alert"
            android:finishOnCloseSystemDialogs="true"
            android:excludeFromRecents="true"
            android:exported="false" />

        <receiver
            android:name=".BugreportReceiver"
            android:permission="android.permission.DUMP">
            <intent-filter>
                <action android:name="android.intent.action.BUGREPORT_FINISHED" />
            </intent-filter>
        </receiver>
    </application>
</manifest>
Loading