Merge "Add null check for intent in AppPermissionPreferenceController" into rvc-dev am: bb7a65a19b
am: 35c1670be2
Change-Id: I944b56d97a8f73ca9408b951bbc24613fd87879d
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.applications.appinfo;
|
package com.android.settings.applications.appinfo;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -123,21 +124,28 @@ public class AppPermissionPreferenceController extends AppInfoPreferenceControll
|
|||||||
|
|
||||||
private void startManagePermissionsActivity() {
|
private void startManagePermissionsActivity() {
|
||||||
// start new activity to manage app permissions
|
// start new activity to manage app permissions
|
||||||
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
|
final Intent permIntent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
|
||||||
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mParent.getAppEntry().info.packageName);
|
permIntent.putExtra(Intent.EXTRA_PACKAGE_NAME, mParent.getAppEntry().info.packageName);
|
||||||
intent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
|
permIntent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
|
||||||
String action = mParent.getActivity().getIntent().getAction();
|
Activity activity = mParent.getActivity();
|
||||||
long sessionId = mParent.getActivity().getIntent().getLongExtra(
|
Intent intent = activity != null ? activity.getIntent() : null;
|
||||||
Intent.ACTION_AUTO_REVOKE_PERMISSIONS, INVALID_SESSION_ID);
|
if (intent != null) {
|
||||||
if ((action != null && action.equals(Intent.ACTION_AUTO_REVOKE_PERMISSIONS))
|
String action = intent.getAction();
|
||||||
|| sessionId != INVALID_SESSION_ID) {
|
long sessionId = intent.getLongExtra(
|
||||||
while (sessionId == INVALID_SESSION_ID) {
|
Intent.ACTION_AUTO_REVOKE_PERMISSIONS, INVALID_SESSION_ID);
|
||||||
sessionId = new Random().nextLong();
|
if ((action != null && action.equals(Intent.ACTION_AUTO_REVOKE_PERMISSIONS))
|
||||||
|
|| sessionId != INVALID_SESSION_ID) {
|
||||||
|
// If intent is Auto revoke, and we don't already have a session ID, make one
|
||||||
|
while (sessionId == INVALID_SESSION_ID) {
|
||||||
|
sessionId = new Random().nextLong();
|
||||||
|
}
|
||||||
|
permIntent.putExtra(Intent.ACTION_AUTO_REVOKE_PERMISSIONS, sessionId);
|
||||||
}
|
}
|
||||||
intent.putExtra(Intent.ACTION_AUTO_REVOKE_PERMISSIONS, sessionId);
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mParent.getActivity().startActivityForResult(intent, mParent.SUB_INFO_FRAGMENT);
|
if (activity != null) {
|
||||||
|
activity.startActivityForResult(permIntent, mParent.SUB_INFO_FRAGMENT);
|
||||||
|
}
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Log.w(TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
|
Log.w(TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user