Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions core/java/android/app/INotificationManager.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ interface INotificationManager
boolean areNotificationsEnabled(String pkg);
int getPackageImportance(String pkg);

void setPackagePriority(String pkg, int uid, int importance);
int getPackagePriority(String pkg, int uid);

void createNotificationChannelGroups(String pkg, in ParceledListSlice channelGroupList);
void createNotificationChannels(String pkg, in ParceledListSlice channelsList);
void createNotificationChannelsForPackage(String pkg, int uid, in ParceledListSlice channelsList);
Expand Down
2 changes: 1 addition & 1 deletion core/res/res/values/cerberusos_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<!-- Whether to cleanup fingerprints upon connection to the daemon and when user switches -->
<bool name="config_cleanupUnusedFingerprints">false</bool>
<bool name="config_cleanupUnusedFingerprints">true</bool>

<!-- Any package that has one of the package names defined below will be prevented
from using specific sensors in order to stop battery drain -->
Expand Down
3 changes: 3 additions & 0 deletions core/res/res/values/cerberusos_symbols.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<java-symbol type="bool" name="config_deviceHasVariableButtonBrightness" />
<java-symbol type="bool" name="config_supportCameraHAL1" />

<!-- Whether to cleanup fingerprints upon connection to the daemon and when user switches -->
<java-symbol type="bool" name="config_cleanupUnusedFingerprints" />

<!-- display for radio tech -->
<java-symbol type="bool" name="config_display_rat" />
<!-- config 2G/3G/4G RAT strings for carriers -->
Expand Down
4 changes: 2 additions & 2 deletions services/core/java/com/android/server/IntentResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ private void buildResolveList(Intent intent, FastImmutableArraySet<String> categ
final Uri data = intent.getData();
final String packageName = intent.getPackage();

final boolean excludingStopped = intent.isExcludingStopped();
final boolean excludingStopped = com.android.server.am.PreventRunningUtils.isExcludingStopped(intent);

final Printer logPrinter;
final PrintWriter logPrintWriter;
Expand Down Expand Up @@ -781,7 +781,7 @@ private void buildResolveList(Intent intent, FastImmutableArraySet<String> categ
continue;
}

match = filter.match(action, resolvedType, scheme, data, categories, TAG);
match = com.android.server.am.PreventRunningUtils.match(filter, action, resolvedType, scheme, data, categories, TAG);
if (match >= 0) {
if (debug) Slog.v(TAG, " Filter matched! match=0x" +
Integer.toHexString(match) + " hasDefault="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4093,6 +4093,20 @@ final ProcessRecord startProcessLocked(String processName, ApplicationInfo info,
boolean knownToBeDead, int intentFlags, String hostingType, ComponentName hostingName,
boolean allowWhileBooting, boolean isolated, int isolatedUid, boolean keepIfLarge,
String abiOverride, String entryPoint, String[] entryPointArgs, Runnable crashHandler) {
if (PreventRunningUtils.hookStartProcessLocked(processName, info, knownToBeDead, intentFlags, hostingType, hostingName)) {
return startProcessLocked$Pr(processName, info,
knownToBeDead, intentFlags, hostingType, hostingName,
allowWhileBooting, isolated, isolatedUid, keepIfLarge,
abiOverride, entryPoint, entryPointArgs, crashHandler);
} else {
return null;
}
}

final ProcessRecord startProcessLocked$Pr(String processName, ApplicationInfo info,
boolean knownToBeDead, int intentFlags, String hostingType, ComponentName hostingName,
boolean allowWhileBooting, boolean isolated, int isolatedUid, boolean keepIfLarge,
String abiOverride, String entryPoint, String[] entryPointArgs, Runnable crashHandler) {
long startTime = SystemClock.elapsedRealtime();
ProcessRecord app;
if (!isolated) {
Expand Down Expand Up @@ -5100,6 +5114,14 @@ void reportUidInfoMessageLocked(String tag, String msg, int uid) {
public final int startActivity(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle bOptions) {
return PreventRunningUtils.onStartActivity(startActivity$Pr(caller, callingPackage,
intent, resolvedType, resultTo, resultWho, requestCode,
startFlags, profilerInfo, bOptions), caller, callingPackage, intent);
}

public final int startActivity$Pr(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle bOptions) {
return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
resultWho, requestCode, startFlags, profilerInfo, bOptions,
UserHandle.getCallingUserId());
Expand Down Expand Up @@ -5906,6 +5928,14 @@ public void overridePendingTransition(IBinder token, String packageName,
@GuardedBy("this")
private final void handleAppDiedLocked(ProcessRecord app,
boolean restarting, boolean allowRestart) {
handleAppDiedLocked$Pr(app, restarting, allowRestart);
if (!restarting && allowRestart && !app.killedByAm) {
PreventRunningUtils.onAppDied(app);
}
}

private final void handleAppDiedLocked$Pr(ProcessRecord app,
boolean restarting, boolean allowRestart) {
int pid = app.pid;
boolean kept = cleanUpApplicationRecordLocked(app, restarting, allowRestart, -1,
false /*replacingPid*/);
Expand Down Expand Up @@ -7133,8 +7163,9 @@ private final boolean killPackageProcessesLocked(String packageName, int appId,
// that match it. We need to qualify this by the processes
// that are running under the specified app and user ID.
} else {
final boolean isDep = app.pkgDeps != null
boolean isDep = app.pkgDeps != null
&& app.pkgDeps.contains(packageName);
isDep = PreventRunningUtils.returnFalse(isDep);
if (!isDep && UserHandle.getAppId(app.uid) != appId) {
continue;
}
Expand Down Expand Up @@ -11222,6 +11253,15 @@ void moveTaskToFrontLocked(int taskId, int flags, SafeActivityOptions options,
*/
@Override
public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) {
if (moveActivityTaskToBack$Pr(token, nonRoot)) {
PreventRunningUtils.onMoveActivityTaskToBack(token);
return true;
} else {
return false;
}
}

public boolean moveActivityTaskToBack$Pr(IBinder token, boolean nonRoot) {
enforceNotIsolatedCaller("moveActivityTaskToBack");
synchronized(this) {
final long origId = Binder.clearCallingIdentity();
Expand Down Expand Up @@ -20440,6 +20480,20 @@ public PendingIntent getRunningServiceControlPanel(ComponentName name) {
public ComponentName startService(IApplicationThread caller, Intent service,
String resolvedType, boolean requireForeground, String callingPackage, int userId)
throws TransactionTooLargeException {
try {
PreventRunningUtils.setSender(caller);
if (PreventRunningUtils.hookStartService(caller, service)) {
return startService$Pr(caller, service, resolvedType, requireForeground, callingPackage, userId);
}
return null;
} finally {
PreventRunningUtils.clearSender();
}
}

public ComponentName startService$Pr(IApplicationThread caller, Intent service,
String resolvedType, boolean requireForeground, String callingPackage, int userId)
throws TransactionTooLargeException {
enforceNotIsolatedCaller("startService");
// Refuse possible leaked file descriptors
if (service != null && service.hasFileDescriptors() == true) {
Expand Down Expand Up @@ -20590,6 +20644,22 @@ boolean isValidSingletonCall(int callingUid, int componentUid) {
public int bindService(IApplicationThread caller, IBinder token, Intent service,
String resolvedType, IServiceConnection connection, int flags, String callingPackage,
int userId) throws TransactionTooLargeException {
try {
PreventRunningUtils.setSender(caller);
if (PreventRunningUtils.hookBindService(caller, token, service)) {
return bindService$Pr(caller, token, service,
resolvedType, connection, flags, callingPackage, userId);
} else {
return 0;
}
} finally {
PreventRunningUtils.clearSender();
}
}

public int bindService$Pr(IApplicationThread caller, IBinder token, Intent service,
String resolvedType, IServiceConnection connection, int flags, String callingPackage,
int userId) throws TransactionTooLargeException {
enforceNotIsolatedCaller("bindService");

// Refuse possible leaked file descriptors
Expand Down Expand Up @@ -22029,6 +22099,27 @@ public final int broadcastIntent(IApplicationThread caller,
int resultCode, String resultData, Bundle resultExtras,
String[] requiredPermissions, int appOp, Bundle bOptions,
boolean serialized, boolean sticky, int userId) {
try {
PreventRunningUtils.setSender(caller);
int res = broadcastIntent$Pr(caller,
intent, resolvedType, resultTo,
resultCode, resultData, resultExtras,
requiredPermissions, appOp, bOptions,
serialized, sticky, userId);
if (res == 0) {
PreventRunningUtils.onBroadcastIntent(intent);
}
return res;
} finally {
PreventRunningUtils.clearSender();
}
}

public final int broadcastIntent$Pr(IApplicationThread caller,
Intent intent, String resolvedType, IIntentReceiver resultTo,
int resultCode, String resultData, Bundle resultExtras,
String[] requiredPermissions, int appOp, Bundle bOptions,
boolean serialized, boolean sticky, int userId) {
enforceNotIsolatedCaller("broadcastIntent");
synchronized(this) {
intent = verifyBroadcastLocked(intent);
Expand Down
3 changes: 3 additions & 0 deletions services/core/java/com/android/server/am/ActivityStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,7 @@ final boolean startPausingLocked(boolean userLeaving, boolean uiSleeping,
mService.getLifecycleManager().scheduleTransaction(prev.app.thread, prev.appToken,
PauseActivityItem.obtain(prev.finishing, userLeaving,
prev.configChangeFlags, pauseImmediately));
PreventRunningUtils.onUserLeavingActivity(prev.appToken, prev.finishing, userLeaving);
} catch (Exception e) {
// Ignore exception, if process died other code will cleanup.
Slog.w(TAG, "Exception thrown during pause", e);
Expand Down Expand Up @@ -2706,6 +2707,7 @@ private boolean resumeTopActivityInnerLocked(ActivityRecord prev, ActivityOption
ResumeActivityItem.obtain(next.app.repProcState,
mService.isNextTransitionForward()));
mService.getLifecycleManager().scheduleTransaction(transaction);
PreventRunningUtils.onResumeActivity(next.appToken);

if (DEBUG_STATES) Slog.d(TAG_STATES, "resumeTopActivityLocked: Resumed "
+ next);
Expand Down Expand Up @@ -4324,6 +4326,7 @@ final boolean destroyActivityLocked(ActivityRecord r, boolean removeFromApp, Str
if (DEBUG_SWITCH) Slog.i(TAG_SWITCH, "Destroying: " + r);
mService.getLifecycleManager().scheduleTransaction(r.app.thread, r.appToken,
DestroyActivityItem.obtain(r.finishing, r.configChangeFlags));
PreventRunningUtils.onDestroyActivity(r.appToken);
} catch (Exception e) {
// We can just ignore exceptions here... if the process
// has crashed, our death notification will clean things
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,7 @@ final boolean realStartActivityLocked(ActivityRecord r, ProcessRecord app,
r.launchedFromPackage, task.voiceInteractor, app.repProcState, r.icicle,
r.persistentState, results, newIntents, mService.isNextTransitionForward(),
profilerInfo));
PreventRunningUtils.onLaunchActivity(r.appToken);

// Set desired final state.
final ActivityLifecycleItem lifecycleItem;
Expand Down Expand Up @@ -3079,6 +3080,17 @@ boolean removeTaskByIdLocked(int taskId, boolean killProcess, boolean removeFrom
}

void cleanUpRemovedTaskLocked(TaskRecord tr, boolean killProcess, boolean removeFromRecents) {
try {
cleanUpRemovedTaskLocked$Pr(tr, killProcess, removeFromRecents);
} finally {
if (killProcess) {
PreventRunningUtils.onCleanUpRemovedTask(tr.getBaseIntent());
}
}
}

private void cleanUpRemovedTaskLocked$Pr(TaskRecord tr, boolean killProcess, boolean removeFromRecents) {

if (removeFromRecents) {
mRecentTasks.remove(tr);
}
Expand Down
Loading