Merge "Restrict the getter of where the app launched from" into sc-qpr1-dev
This commit is contained in:
@@ -21,6 +21,8 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
|||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
|
||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
||||||
|
import static android.os.Process.INVALID_UID;
|
||||||
|
import static android.os.Process.SYSTEM_UID;
|
||||||
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
|
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
|
||||||
import static android.service.voice.VoiceInteractionSession.SHOW_SOURCE_APPLICATION;
|
import static android.service.voice.VoiceInteractionSession.SHOW_SOURCE_APPLICATION;
|
||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
@@ -53,6 +55,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.PackageManagerInternal;
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -64,6 +67,7 @@ import android.os.PersistableBundle;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.service.voice.VoiceInteractionManagerInternal;
|
import android.service.voice.VoiceInteractionManagerInternal;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.RemoteAnimationDefinition;
|
import android.view.RemoteAnimationDefinition;
|
||||||
@@ -74,6 +78,7 @@ import com.android.internal.policy.IKeyguardDismissCallback;
|
|||||||
import com.android.internal.protolog.common.ProtoLog;
|
import com.android.internal.protolog.common.ProtoLog;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.Watchdog;
|
import com.android.server.Watchdog;
|
||||||
|
import com.android.server.pm.parsing.pkg.AndroidPackage;
|
||||||
import com.android.server.uri.NeededUriGrants;
|
import com.android.server.uri.NeededUriGrants;
|
||||||
import com.android.server.vr.VrManagerInternal;
|
import com.android.server.vr.VrManagerInternal;
|
||||||
|
|
||||||
@@ -557,20 +562,45 @@ class ActivityClientController extends IActivityClientController.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLaunchedFromUid(IBinder token) {
|
public int getLaunchedFromUid(IBinder token) {
|
||||||
|
if (!canGetLaunchedFrom()) {
|
||||||
|
return INVALID_UID;
|
||||||
|
}
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final ActivityRecord r = ActivityRecord.forTokenLocked(token);
|
final ActivityRecord r = ActivityRecord.forTokenLocked(token);
|
||||||
return r != null ? r.launchedFromUid : android.os.Process.INVALID_UID;
|
return r != null ? r.launchedFromUid : INVALID_UID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLaunchedFromPackage(IBinder token) {
|
public String getLaunchedFromPackage(IBinder token) {
|
||||||
|
if (!canGetLaunchedFrom()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final ActivityRecord r = ActivityRecord.forTokenLocked(token);
|
final ActivityRecord r = ActivityRecord.forTokenLocked(token);
|
||||||
return r != null ? r.launchedFromPackage : null;
|
return r != null ? r.launchedFromPackage : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether the caller can get the package or uid that launched its activity. */
|
||||||
|
private boolean canGetLaunchedFrom() {
|
||||||
|
final int uid = Binder.getCallingUid();
|
||||||
|
if (UserHandle.getAppId(uid) == SYSTEM_UID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final PackageManagerInternal pm = mService.mWindowManager.mPmInternal;
|
||||||
|
final AndroidPackage callingPkg = pm.getPackage(uid);
|
||||||
|
if (callingPkg == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (callingPkg.isSignedWithPlatformKey()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final String[] installerNames = pm.getKnownPackageNames(
|
||||||
|
PackageManagerInternal.PACKAGE_INSTALLER, UserHandle.getUserId(uid));
|
||||||
|
return installerNames.length > 0 && callingPkg.getPackageName().equals(installerNames[0]);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRequestedOrientation(IBinder token, int requestedOrientation) {
|
public void setRequestedOrientation(IBinder token, int requestedOrientation) {
|
||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
|
|||||||
Reference in New Issue
Block a user