Loading core/java/android/accounts/ChooseAccountActivity.java +2 −13 Original line number Diff line number Diff line Loading @@ -16,16 +16,12 @@ package android.accounts; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.IBinder; import android.os.Parcelable; import android.os.RemoteException; import android.os.Process; import android.os.UserHandle; import android.util.Log; Loading Loading @@ -71,15 +67,8 @@ public class ChooseAccountActivity extends Activity { return; } try { IBinder activityToken = getActivityToken(); mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken); mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage( activityToken); } catch (RemoteException re) { // Couldn't figure out caller details Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re); } mCallingUid = getLaunchedFromUid(); mCallingPackage = getLaunchedFromPackage(); if (UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) && getIntent().getStringExtra(AccountManager.KEY_ANDROID_PACKAGE_NAME) != null) { Loading core/java/android/accounts/ChooseTypeAndAccountActivity.java +7 −20 Original line number Diff line number Diff line Loading @@ -15,16 +15,12 @@ */ package android.accounts; import android.app.ActivityTaskManager; import com.google.android.collect.Sets; import android.app.Activity; import android.app.ActivityManager; import android.content.Intent; import android.os.Bundle; import android.os.IBinder; import android.os.Parcelable; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.text.TextUtils; Loading Loading @@ -144,23 +140,14 @@ public class ChooseTypeAndAccountActivity extends Activity + savedInstanceState + ")"); } String message = null; try { IBinder activityToken = getActivityToken(); mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken); mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage( activityToken); mCallingUid = getLaunchedFromUid(); mCallingPackage = getLaunchedFromPackage(); if (mCallingUid != 0 && mCallingPackage != null) { Bundle restrictions = UserManager.get(this) .getUserRestrictions(new UserHandle(UserHandle.getUserId(mCallingUid))); mDisallowAddAccounts = restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false); } } catch (RemoteException re) { // Couldn't figure out caller details Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re); } // save some items we use frequently final Intent intent = getIntent(); Loading core/java/android/accounts/GrantCredentialsPermissionActivity.java +1 −11 Original line number Diff line number Diff line Loading @@ -16,18 +16,14 @@ package android.accounts; import android.app.Activity; import android.app.ActivityTaskManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.Bundle; import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; Loading Loading @@ -85,13 +81,7 @@ public class GrantCredentialsPermissionActivity extends Activity implements View return; } try { IBinder activityToken = getActivityToken(); mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken); } catch (RemoteException re) { // Couldn't figure out caller details Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re); } mCallingUid = getLaunchedFromUid(); if (!UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) && mCallingUid != mUid) { setResult(Activity.RESULT_CANCELED); Loading core/java/android/app/Activity.java +17 −0 Original line number Diff line number Diff line Loading @@ -6229,6 +6229,23 @@ public class Activity extends ContextThemeWrapper return ActivityClient.getInstance().getCallingActivity(mToken); } /** * Returns the uid who started this activity. * @hide */ public int getLaunchedFromUid() { return ActivityClient.getInstance().getLaunchedFromUid(getActivityToken()); } /** * Returns the package who started this activity. * @hide */ @Nullable public String getLaunchedFromPackage() { return ActivityClient.getInstance().getLaunchedFromPackage(getActivityToken()); } /** * Control whether this activity's main window is visible. This is intended * only for the special case of an activity that is not going to show a Loading core/java/android/app/ActivityClient.java +16 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,22 @@ public class ActivityClient { } } public int getLaunchedFromUid(IBinder token) { try { return getActivityClientController().getLaunchedFromUid(token); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } public String getLaunchedFromPackage(IBinder token) { try { return getActivityClientController().getLaunchedFromPackage(token); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } Bundle getActivityOptions(IBinder token) { try { return getActivityClientController().getActivityOptions(token); Loading Loading
core/java/android/accounts/ChooseAccountActivity.java +2 −13 Original line number Diff line number Diff line Loading @@ -16,16 +16,12 @@ package android.accounts; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.IBinder; import android.os.Parcelable; import android.os.RemoteException; import android.os.Process; import android.os.UserHandle; import android.util.Log; Loading Loading @@ -71,15 +67,8 @@ public class ChooseAccountActivity extends Activity { return; } try { IBinder activityToken = getActivityToken(); mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken); mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage( activityToken); } catch (RemoteException re) { // Couldn't figure out caller details Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re); } mCallingUid = getLaunchedFromUid(); mCallingPackage = getLaunchedFromPackage(); if (UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) && getIntent().getStringExtra(AccountManager.KEY_ANDROID_PACKAGE_NAME) != null) { Loading
core/java/android/accounts/ChooseTypeAndAccountActivity.java +7 −20 Original line number Diff line number Diff line Loading @@ -15,16 +15,12 @@ */ package android.accounts; import android.app.ActivityTaskManager; import com.google.android.collect.Sets; import android.app.Activity; import android.app.ActivityManager; import android.content.Intent; import android.os.Bundle; import android.os.IBinder; import android.os.Parcelable; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.text.TextUtils; Loading Loading @@ -144,23 +140,14 @@ public class ChooseTypeAndAccountActivity extends Activity + savedInstanceState + ")"); } String message = null; try { IBinder activityToken = getActivityToken(); mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken); mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage( activityToken); mCallingUid = getLaunchedFromUid(); mCallingPackage = getLaunchedFromPackage(); if (mCallingUid != 0 && mCallingPackage != null) { Bundle restrictions = UserManager.get(this) .getUserRestrictions(new UserHandle(UserHandle.getUserId(mCallingUid))); mDisallowAddAccounts = restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false); } } catch (RemoteException re) { // Couldn't figure out caller details Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re); } // save some items we use frequently final Intent intent = getIntent(); Loading
core/java/android/accounts/GrantCredentialsPermissionActivity.java +1 −11 Original line number Diff line number Diff line Loading @@ -16,18 +16,14 @@ package android.accounts; import android.app.Activity; import android.app.ActivityTaskManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.Bundle; import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; Loading Loading @@ -85,13 +81,7 @@ public class GrantCredentialsPermissionActivity extends Activity implements View return; } try { IBinder activityToken = getActivityToken(); mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken); } catch (RemoteException re) { // Couldn't figure out caller details Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re); } mCallingUid = getLaunchedFromUid(); if (!UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) && mCallingUid != mUid) { setResult(Activity.RESULT_CANCELED); Loading
core/java/android/app/Activity.java +17 −0 Original line number Diff line number Diff line Loading @@ -6229,6 +6229,23 @@ public class Activity extends ContextThemeWrapper return ActivityClient.getInstance().getCallingActivity(mToken); } /** * Returns the uid who started this activity. * @hide */ public int getLaunchedFromUid() { return ActivityClient.getInstance().getLaunchedFromUid(getActivityToken()); } /** * Returns the package who started this activity. * @hide */ @Nullable public String getLaunchedFromPackage() { return ActivityClient.getInstance().getLaunchedFromPackage(getActivityToken()); } /** * Control whether this activity's main window is visible. This is intended * only for the special case of an activity that is not going to show a Loading
core/java/android/app/ActivityClient.java +16 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,22 @@ public class ActivityClient { } } public int getLaunchedFromUid(IBinder token) { try { return getActivityClientController().getLaunchedFromUid(token); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } public String getLaunchedFromPackage(IBinder token) { try { return getActivityClientController().getLaunchedFromPackage(token); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } Bundle getActivityOptions(IBinder token) { try { return getActivityClientController().getActivityOptions(token); Loading