Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit ba45429

Browse files
committed
updated system actions
* Updated system actions * Refactored table code
1 parent f56b972 commit ba45429

File tree

6 files changed

+84
-60
lines changed

6 files changed

+84
-60
lines changed

ClassySharkAndroid/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.0'
8+
classpath 'com.android.tools.build:gradle:2.3.1'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

ClassySharkWS/src/com/google/classyshark/silverghost/translator/apk/dashboard/ApkDashboard.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.classyshark.silverghost.translator.apk.dashboard;
1818

1919
import com.google.classyshark.silverghost.contentreader.dex.DexlibLoader;
20-
import com.google.classyshark.silverghost.translator.apk.dashboard.asciitable.Table;
2120
import com.google.classyshark.silverghost.translator.apk.dashboard.manifest.ManifestInspector;
2221
import com.google.classyshark.silverghost.translator.java.dex.MultidexReader;
2322
import java.io.File;
Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
package com.google.classyshark.silverghost.translator.apk.dashboard.asciitable;
1+
/**
2+
* Copyright (C) 2014 [email protected]
3+
* Copyright (C) 2011 K Venkata Sudhakar <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.google.classyshark.silverghost.translator.apk.dashboard;
219

320
import java.util.ArrayList;
421
import java.util.Arrays;
@@ -124,11 +141,11 @@ private static String getRowDataBuf(int colCount, List<Integer> colMaxLenList,
124141

125142
StringBuilder rowBuilder = new StringBuilder();
126143
String formattedData = null;
127-
Align align;
144+
Column.Align align;
128145

129146
for (int i = 0 ; i < colCount ; i ++) {
130147

131-
align = isHeader ? Align.HEADER_DEFAULT : Align.DATA_DEFAULT;
148+
align = isHeader ? Column.Align.HEADER_DEFAULT : Column.Align.DATA_DEFAULT;
132149

133150
if (headerObjs != null && i < headerObjs.length) {
134151
if (isHeader) {
@@ -154,19 +171,19 @@ private static String getRowDataBuf(int colCount, List<Integer> colMaxLenList,
154171
return rowBuilder.append("\n").toString();
155172
}
156173

157-
private static String getFormattedData(int maxLength, String data, Align align) {
174+
private static String getFormattedData(int maxLength, String data, Column.Align align) {
158175
if (data.length() > maxLength) {
159176
return data;
160177
}
161178

162179
boolean toggle = true;
163180

164181
while (data.length() < maxLength) {
165-
if (align == Align.LEFT) {
182+
if (align == Column.Align.LEFT) {
166183
data = data + " ";
167-
} else if (align == Align.RIGHT) {
184+
} else if (align == Column.Align.RIGHT) {
168185
data = " " + data;
169-
} else if (align == Align.CENTER) {
186+
} else if (align == Column.Align.CENTER) {
170187
if (toggle) {
171188
data = " " + data;
172189
toggle = false;
@@ -270,4 +287,49 @@ private static String[] getHeaders(Column[] headerObjs) {
270287

271288
return header;
272289
}
290+
291+
/** Represents a column's title and alignment. */
292+
public static class Column {
293+
294+
/** Represents a horizontal alignment. */
295+
public enum Align {
296+
LEFT, CENTER, RIGHT;
297+
298+
public static final Align HEADER_DEFAULT = LEFT;
299+
public static final Align DATA_DEFAULT = LEFT;
300+
}
301+
302+
303+
public final String header;
304+
public final Align headerAlign;
305+
public final Align dataAlign;
306+
307+
/** A Column with a name. */
308+
public Column(String headerName) {
309+
this(headerName, Align.HEADER_DEFAULT, Align.DATA_DEFAULT);
310+
}
311+
312+
/** A Column with a name and alignment. */
313+
public Column(String header, Align headerAlign, Align dataAlign) {
314+
this.header = header;
315+
this.headerAlign = headerAlign;
316+
this.dataAlign = dataAlign;
317+
}
318+
319+
/** An object which can extract data with which to populate its column. */
320+
public <T> Data<T> with(Function<T, String> getter) {
321+
return new Data<T>(this, getter);
322+
}
323+
324+
/** Represents a Data-driven column. */
325+
public static class Data<T> {
326+
public final Column column;
327+
public final Function<T, String> getter;
328+
329+
private Data(Column column, Function<T, String> getter) {
330+
this.column = column;
331+
this.getter = getter;
332+
}
333+
}
334+
}
273335
}

ClassySharkWS/src/com/google/classyshark/silverghost/translator/apk/dashboard/asciitable/Align.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

ClassySharkWS/src/com/google/classyshark/silverghost/translator/apk/dashboard/asciitable/Column.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

ClassySharkWS/src/com/google/classyshark/silverghost/translator/apk/dashboard/manifest/ReceiverActionsBL.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class ReceiverActionsBL {
2626

2727

28-
// TODO follow up with https://developer.android.com/preview/features/background.html
28+
// https://developer.android.com/preview/features/background-broadcasts.html
2929

3030
static List<String> approvedActions = Arrays.asList(
3131
"android.intent.action.LOCKED_BOOT_COMPLETED",
@@ -34,17 +34,27 @@ public class ReceiverActionsBL {
3434
"android.intent.action.USER_ADDED",
3535
"android.intent.action.USER_REMOVED",
3636
"android.intent.action.TIMEZONE_CHANGED",
37+
"android.intent.action.TIME_SET",
3738
"android.intent.action.LOCALE_CHANGED",
3839
"android.hardware.usb.action.USB_ACCESSORY_ATTACHED",
3940
"android.hardware.usb.action.USB_ACCESSORY_DETACHED",
4041
"android.hardware.usb.action.USB_DEVICE_ATTACHED",
4142
"android.hardware.usb.action.USB_DEVICE_DETACHED",
42-
"android.hardware.usb.action.USB_PORT_CHANGED",
43-
"android.intent.action.DEVICE_STORAGE_LOW",
4443
"android.accounts.LOGIN_ACCOUNTS_CHANGED",
44+
"android.intent.action.DEVICE_STORAGE_LOW",
45+
"android.intent.action.DEVICE_STORAGE_OK",
4546
"android.intent.action.PACKAGE_DATA_CLEARED",
4647
"android.intent.action.PACKAGE_FULLY_REMOVED",
47-
"android.intent.action.NEW_OUTGOING_CALL"
48+
"android.intent.action.NEW_OUTGOING_CALL",
49+
"android.intent.action.HEADSET_PLUG",
50+
"android.intent.action.EVENT_REMINDER",
51+
"android.hardware.usb.action.USB_ACCESSORY_ATTACHED",
52+
"android.hardware.usb.action.USB_ACCESSORY_DETACHED",
53+
"android.hardware.usb.action.USB_DEVICE_ATTACHED",
54+
"android.hardware.usb.action.USB_DEVICE_DETACHED",
55+
"android.app.action.DEVICE_OWNER_CHANGED",
56+
"android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED",
57+
"android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED"
4858
);
4959

5060
private final Map<String, String> bgActionsToReceivers;

0 commit comments

Comments
 (0)