Skip to content

introduce pocket judge/lock #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 51 commits into
base: eleven
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
01d8705
pocket: introduce pocket judge/lock
kaluoshi Oct 23, 2016
10ee40d
Pocket lock: Improve on fod devices
jhenrique09 Sep 12, 2020
e0e6d21
PocketJudge: allow register vendor pocket sensor
DennySPB May 28, 2020
e2136a6
PocketLock: Add config_pocketModeSupported overlay
jhenrique09 May 3, 2019
0284693
PocketLock: Make using light sensor optional
Laker87 Feb 5, 2021
a8401da
PocketJudge: Allow to register vendor proximity sensor
Hikari-no-Tenshi Jul 10, 2021
a96e828
Revert "Pocket lock: Improve on fod devices"
darknius09 Sep 30, 2022
76ec3e3
base: Remove PixelPropsUtils
palaych Sep 1, 2022
e26f2a3
base: Spoof build fingerprint for Google Play Services [1/2]
kdrag0n Oct 12, 2021
9479f0d
base: Alter model name to avoid SafetyNet HW attestation enforcement
kdrag0n Oct 12, 2021
0987076
base: Limit SafetyNet workarounds to unstable GMS process
kdrag0n Nov 2, 2021
5537264
core: pm: Wipe package cache on upgrade
krasCGQ Aug 27, 2022
25d6e8d
Fix duplicate permission privilege escalation
Apr 28, 2022
7499947
Parcel: recycle recycles
smore-lore Mar 30, 2022
bc142d8
Remove package name from SafetyNet logs
Jun 30, 2022
a79deb9
base: AttestationHooks: Spoof device as Pixel XL for Google Photos
adithya2306 Sep 8, 2022
869be13
Network Traffic [1/2]
Haus1 Jan 4, 2017
0c51001
Statusbar net monitor: stop the handler if screen is off
ezio84 Apr 9, 2018
a07bf6d
Move net monitor to expanded statusbar header
ezio84 Dec 9, 2018
73ed204
Net monitor: fix text color on light theme
ezio84 Dec 12, 2018
ffda1d6
Network traffic: fix indicator not hiding on lost connection
SpiritCroc Dec 24, 2018
e0440bc
Make sure that Network Traffic is disabled by default
nychitman1 Dec 19, 2019
1c21612
Network Traffic: Bring back traffic indicator for all
Jan 13, 2019
f8cc58f
Network Traffic: Move network indicator to the right
Miccia94 Dec 18, 2018
10c0d85
Network Traffic: OOS style network traffic indicator
ganeshi4u Mar 12, 2019
e421276
Network Traffic: Refactor text formatting
ganeshi4u Feb 6, 2020
c8ac0cf
Network Traffic: Adjust size/text style for extended statusbar
Feb 6, 2020
feb67f1
Traffic indicators: code cleanup and improvements
ezio84 Feb 9, 2020
32b4cae
Traffic indicators: use smaller and bold fonts in expanded statusbar
ezio84 Feb 9, 2020
535291b
Traffic indicators: add properly to statusbar icons
SpiritCroc Feb 11, 2020
6d629f9
Traffic indicators: hide in the keyguard
Feb 12, 2020
f243241
Traffic indicators: don't show two instances in expanded statusbar
ezio84 Feb 12, 2020
87b16a4
Traffic indicators: Prevent logspam caused by improperly calling requ…
ezio84 Feb 14, 2020
4ac7aa1
NetworkTraffic: Fix speed format for 10*KB
neobuddy89 Jun 14, 2020
ad323e3
Traffic indicators: Switch quick statusbar header to LinearLayout
ganeshi4u Oct 24, 2020
c52b0bf
SystemUI: NetworkTraffic: Add notch check and allow devices to override
adithya2306 Feb 13, 2021
f7f0f86
SystemUI: NetworkTraffic: Minor refinements
adithya2306 Feb 13, 2021
50b778b
SystemUI: Reduce statusbar network speed margins
adithya2306 Feb 24, 2021
12c4dbd
SystemUI: NetworkTrafficSB: Reduce font size a bit
adithya2306 Apr 10, 2021
1388e80
base: add MAC address firewall [1/2]
cjybyjk Jan 22, 2021
53e4d66
base: Add support for application downgrade
libxzr Mar 17, 2022
147cffa
base: Add support for window ignore secure
libxzr Mar 18, 2022
9b0c793
ResolveActivity scroll not Smooth
binhongwang Aug 2, 2022
685b9d8
SystemUI: Fix QS expand lag when VoLTE/VoWiFi icons are enabled
timjosten Jul 28, 2022
914450f
InputMethodUtils: Fix system bootloop when no IME found
neobuddy89 Dec 31, 2021
0827e7c
[1/2] Statusbar Clock background chip
StarkDroid Apr 9, 2023
390f116
ThemeOverlayManager: Apply wifi and signal icon styles last
neobuddy89 Jan 18, 2022
464804b
base: import ThemeUtils
darknius09 May 27, 2023
fcd92e7
base: Custom Statusbar Signal & Wi-Fi icons
darknius09 May 28, 2023
9ca83ee
Revert "ThemeOverlayManager: Apply wifi and signal icon styles last"
darknius09 May 28, 2023
fcf8867
Network Traffic: Fix up padding
darknius09 May 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CleanSpec.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/libhwui.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libhwui.so)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/os/storage/*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/content/IClipboard.P)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/pocket/*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/telephony/java/com/android/internal/telephony/ITelephonyRegistry.P)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/docs/api-stubs*)
Expand Down
4 changes: 3 additions & 1 deletion core/java/android/app/ApplicationPackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.Immutable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.gmscompat.AttestationHooks;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.UserIcons;

Expand Down Expand Up @@ -668,7 +669,8 @@ protected Boolean recompute(HasSystemFeatureQuery query) {

@Override
public boolean hasSystemFeature(String name, int version) {
return mHasSystemFeatureCache.query(new HasSystemFeatureQuery(name, version));
return AttestationHooks.hasSystemFeature(name,
mHasSystemFeatureCache.query(new HasSystemFeatureQuery(name, version)));
}

/** @hide */
Expand Down
3 changes: 3 additions & 0 deletions core/java/android/app/Instrumentation.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import android.view.WindowManagerGlobal;

import com.android.internal.content.ReferrerIntent;
import com.android.internal.gmscompat.AttestationHooks;

import java.io.File;
import java.lang.annotation.Retention;
Expand Down Expand Up @@ -1157,6 +1158,7 @@ public Application newApplication(ClassLoader cl, String className, Context cont
Application app = getFactory(context.getPackageName())
.instantiateApplication(cl, className);
app.attach(context);
AttestationHooks.initApplicationBeforeOnCreate(app);
return app;
}

Expand All @@ -1174,6 +1176,7 @@ static public Application newApplication(Class<?> clazz, Context context)
ClassNotFoundException {
Application app = (Application)clazz.newInstance();
app.attach(context);
AttestationHooks.initApplicationBeforeOnCreate(app);
return app;
}

Expand Down
11 changes: 11 additions & 0 deletions core/java/android/app/SystemServiceRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@
import android.os.storage.StorageManager;
import android.permission.PermissionControllerManager;
import android.permission.PermissionManager;
import android.pocket.IPocketService;
import android.pocket.PocketManager;
import android.print.IPrintManager;
import android.print.PrintManager;
import android.security.FileIntegrityManager;
Expand Down Expand Up @@ -943,6 +945,15 @@ public DcDimmingManager createService(ContextImpl ctx) throws ServiceNotFoundExc
return new DcDimmingManager(service);
}});

registerService(Context.POCKET_SERVICE, PocketManager.class,
new CachedServiceFetcher<PocketManager>() {
@Override
public PocketManager createService(ContextImpl ctx) {
IBinder binder = ServiceManager.getService(Context.POCKET_SERVICE);
IPocketService service = IPocketService.Stub.asInterface(binder);
return new PocketManager(ctx.getOuterContext(), service);
}});

registerService(Context.TV_INPUT_SERVICE, TvInputManager.class,
new CachedServiceFetcher<TvInputManager>() {
@Override
Expand Down
10 changes: 10 additions & 0 deletions core/java/android/content/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -5086,6 +5086,16 @@ public abstract boolean startInstrumentation(@NonNull ComponentName className,
*/
public static final String DYNAMIC_SYSTEM_SERVICE = "dynamic_system";

/**
* Use with {@link #getSystemService} to retrieve a
* {@link android.os.PocketManager} for accessing and listening to device pocket state.
*
* @hide
* @see #getSystemService
* @see android.os.PocketManager
*/
public static final String POCKET_SERVICE = "pocket";

/**
* Use with {@link #getSystemService(String)} to retrieve a {@link
* android.app.blob.BlobStoreManager} for contributing and accessing data blobs
Expand Down
8 changes: 8 additions & 0 deletions core/java/android/content/pm/parsing/ParsingPackageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static android.content.pm.PackageManager.FEATURE_WATCH;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_BAD_MANIFEST;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_ONLY_COREAPP_ALLOWED;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSED;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION;
Expand Down Expand Up @@ -777,6 +778,13 @@ private ParseResult<ParsingPackage> parseBaseApkTags(ParseInput input, ParsingPa
);
}

if (ParsedPermissionUtils.declareDuplicatePermission(pkg)) {
return input.error(
INSTALL_PARSE_FAILED_MANIFEST_MALFORMED,
"Found duplicate permission with a different attribute value."
);
}

convertNewPermissions(pkg);

convertSplitPermissions(pkg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.ArrayMap;
import android.util.EventLog;
import android.util.Slog;

import com.android.internal.R;
Expand All @@ -32,6 +34,8 @@
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.List;
import java.util.Objects;

/** @hide */
public class ParsedPermissionUtils {
Expand Down Expand Up @@ -207,4 +211,48 @@ public static ParseResult<ParsedPermissionGroup> parsePermissionGroup(ParsingPac
return ComponentParseUtils.parseAllMetaData(pkg, res, parser, tag, permissionGroup,
input);
}

/**
* Determines if a duplicate permission is malformed .i.e. defines different protection level
* or group.
*/
private static boolean isMalformedDuplicate(ParsedPermission p1, ParsedPermission p2) {
// Since a permission tree is also added as a permission with normal protection
// level, we need to skip if the parsedPermission is a permission tree.
if (p1 == null || p2 == null || p1.isTree() || p2.isTree()) {
return false;
}

if (p1.getProtectionLevel() != p2.getProtectionLevel()) {
return true;
}
if (!Objects.equals(p1.getGroup(), p2.getGroup())) {
return true;
}

return false;
}

/**
* @return {@code true} if the package declares malformed duplicate permissions.
*/
public static boolean declareDuplicatePermission(@NonNull ParsingPackage pkg) {
final List<ParsedPermission> permissions = pkg.getPermissions();
final int size = permissions.size();
if (size > 0) {
final ArrayMap<String, ParsedPermission> checkDuplicatePerm = new ArrayMap<>(size);
for (int i = 0; i < size; i++) {
final ParsedPermission parsedPermission = permissions.get(i);
final String name = parsedPermission.getName();
final ParsedPermission perm = checkDuplicatePerm.get(name);
if (isMalformedDuplicate(parsedPermission, perm)) {
// Fix for b/213323615
EventLog.writeEvent(0x534e4554, "213323615");
return true;
}
checkDuplicatePerm.put(name, parsedPermission);
}
}
return false;
}
}
1 change: 1 addition & 0 deletions core/java/android/os/INetworkManagementService.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ interface INetworkManagementService
void setFirewallInterfaceRule(String iface, boolean allow);
void setFirewallUidRule(int chain, int uid, int rule);
void setFirewallUidRules(int chain, in int[] uids, in int[] rules);
void setFirewallMACAddressRule(String macAddr, boolean allow);
void setFirewallChainEnabled(int chain, boolean enable);

/**
Expand Down
1 change: 1 addition & 0 deletions core/java/android/os/Parcel.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ public static Parcel obtain() {
*/
public final void recycle() {
if (DEBUG_RECYCLE) mStack = null;
mClassCookies = null;
freeBuffer();

final Parcel[] pool;
Expand Down
24 changes: 24 additions & 0 deletions core/java/android/pocket/IPocketCallback.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (C) 2016 The ParanoidAndroid 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 android.pocket;

/** @hide */
interface IPocketCallback {

// notify when pocket state changes.
void onStateChanged(boolean isDeviceInPocket, int reason);

}
43 changes: 43 additions & 0 deletions core/java/android/pocket/IPocketService.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (C) 2016 The ParanoidAndroid 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 android.pocket;

import android.pocket.IPocketCallback;

/** @hide */
interface IPocketService {

// add callback to get notified about pocket state.
void addCallback(IPocketCallback callback);

// remove callback and stop getting notified about pocket state.
void removeCallback(IPocketCallback callback);

// notify pocket service about intercative state changed.
// @see com.android.policy.PhoneWindowManager
void onInteractiveChanged(boolean interactive);

// external processes can request changing listening state.
void setListeningExternal(boolean listen);

// check if device is in pocket.
boolean isDeviceInPocket();

// Custom methods
void setPocketLockVisible(boolean visible);
boolean isPocketLockVisible();

}
19 changes: 19 additions & 0 deletions core/java/android/pocket/PocketConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package android.pocket;

/**
* This class contains global pocket setup constants.
* @author Carlo Savignano
* @hide
*/

public class PocketConstants {

public static final boolean DEBUG = false;
public static final boolean DEBUG_SPEW = false;

/**
* Whether to use proximity sensor to evaluate pocket state.
*/
public static final boolean ENABLE_PROXIMITY_JUDGE = true;

}
Loading