Merge "Revert "Revert "Remove getAppsUsingPermisisons"""

This commit is contained in:
TreeHugger Robot
2017-02-01 02:57:17 +00:00
committed by Android (Google) Code Review
4 changed files with 1 additions and 107 deletions

View File

@@ -33747,7 +33747,6 @@ package android.permissionpresenterservice {
method public final void attachBaseContext(android.content.Context);
method public final android.os.IBinder onBind(android.content.Intent);
method public abstract java.util.List<android.content.pm.permission.RuntimePermissionPresentationInfo> onGetAppPermissions(java.lang.String);
method public abstract java.util.List<android.content.pm.ApplicationInfo> onGetAppsUsingPermissions(boolean);
field public static final java.lang.String SERVICE_INTERFACE = "android.permissionpresenterservice.RuntimePermissionPresenterService";
}

View File

@@ -25,5 +25,4 @@ import android.os.RemoteCallback;
*/
oneway interface IRuntimePermissionPresenter {
void getAppPermissions(String packageName, in RemoteCallback callback);
void getAppsUsingPermissions(boolean system, in RemoteCallback callback);
}
}

View File

@@ -72,15 +72,6 @@ public final class RuntimePermissionPresenter {
List<RuntimePermissionPresentationInfo> permissions) {
/* do nothing - stub */
}
/**
* The result for {@link #getAppsUsingPermissions(boolean, List)}.
* @param system Whether to return only the system apps or only the non-system ones.
* @param apps The apps using runtime permissions.
*/
public void getAppsUsingPermissions(boolean system, @NonNull List<ApplicationInfo> apps) {
/* do nothing - stub */
}
}
private static final Object sLock = new Object();
@@ -127,29 +118,6 @@ public final class RuntimePermissionPresenter {
mRemoteService.processMessage(message);
}
/**
* Gets the system apps that use runtime permissions. System apps are ones
* that are considered system for presentation purposes instead of ones
* that are preinstalled on the system image. System apps are ones that
* are on the system image, haven't been updated (a.k.a factory apps)
* that do not have a launcher icon.
*
* @param system If true only system apps are returned otherwise only
* non-system ones are returned.
* @param callback Callback to receive the result.
* @param handler Handler on which to invoke the callback.
*/
public void getAppsUsingPermissions(boolean system, @NonNull OnResultCallback callback,
@Nullable Handler handler) {
SomeArgs args = SomeArgs.obtain();
args.arg1 = callback;
args.arg2 = handler;
args.argi1 = system ? 1 : 0;
Message message = mRemoteService.obtainMessage(
RemoteService.MSG_GET_APPS_USING_PERMISSIONS, args);
mRemoteService.processMessage(message);
}
private static final class RemoteService
extends Handler implements ServiceConnection {
private static final long UNBIND_TIMEOUT_MILLIS = 10000;
@@ -254,51 +222,6 @@ public final class RuntimePermissionPresenter {
scheduleUnbind();
} break;
case MSG_GET_APPS_USING_PERMISSIONS: {
SomeArgs args = (SomeArgs) msg.obj;
final OnResultCallback callback = (OnResultCallback) args.arg1;
final Handler handler = (Handler) args.arg2;
final boolean system = args.argi1 == 1;
args.recycle();
final IRuntimePermissionPresenter remoteInstance;
synchronized (mLock) {
remoteInstance = mRemoteInstance;
}
if (remoteInstance == null) {
return;
}
try {
remoteInstance.getAppsUsingPermissions(system, new RemoteCallback(
new RemoteCallback.OnResultListener() {
@Override
public void onResult(Bundle result) {
final List<ApplicationInfo> reportedApps;
List<ApplicationInfo> apps = null;
if (result != null) {
apps = result.getParcelableArrayList(KEY_RESULT);
}
if (apps == null) {
apps = Collections.emptyList();
}
reportedApps = apps;
if (handler != null) {
handler.post(new Runnable() {
@Override
public void run() {
callback.getAppsUsingPermissions(system, reportedApps);
}
});
} else {
callback.getAppsUsingPermissions(system, reportedApps);
}
}
}, this));
} catch (RemoteException re) {
Log.e(TAG, "Error getting apps using permissions", re);
}
scheduleUnbind();
} break;
case MSG_UNBIND: {
synchronized (mLock) {
if (mBound) {

View File

@@ -72,14 +72,6 @@ public abstract class RuntimePermissionPresenterService extends Service {
*/
public abstract List<RuntimePermissionPresentationInfo> onGetAppPermissions(String packageName);
/**
* Gets the apps that use runtime permissions.
*
* @param system Whether to return only the system apps or only the non-system ones.
* @return The app list.
*/
public abstract List<ApplicationInfo> onGetAppsUsingPermissions(boolean system);
@Override
public final IBinder onBind(Intent intent) {
return new IRuntimePermissionPresenter.Stub() {
@@ -91,12 +83,6 @@ public abstract class RuntimePermissionPresenterService extends Service {
mHandler.obtainMessage(MyHandler.MSG_GET_APP_PERMISSIONS,
args).sendToTarget();
}
@Override
public void getAppsUsingPermissions(boolean system, RemoteCallback callback) {
mHandler.obtainMessage(MyHandler.MSG_GET_APPS_USING_PERMISSIONS,
system ? 1 : 0, 0, callback).sendToTarget();
}
};
}
@@ -127,19 +113,6 @@ public abstract class RuntimePermissionPresenterService extends Service {
callback.sendResult(null);
}
} break;
case MSG_GET_APPS_USING_PERMISSIONS: {
RemoteCallback callback = (RemoteCallback) msg.obj;
final boolean system = msg.arg1 == 1;
List<ApplicationInfo> apps = onGetAppsUsingPermissions(system);
if (apps != null && !apps.isEmpty()) {
Bundle result = new Bundle();
result.putParcelableList(RuntimePermissionPresenter.KEY_RESULT, apps);
callback.sendResult(result);
} else {
callback.sendResult(null);
}
} break;
}
}
}