am e9fc4cda: Merge "Add camera app op - framework" into mnc-dev
* commit 'e9fc4cda50664558028b79edd1f4b893cd4f52d3': Add camera app op - framework
This commit is contained in:
@@ -1638,6 +1638,12 @@ public final class ActivityThread {
|
||||
return sCurrentActivityThread;
|
||||
}
|
||||
|
||||
public static String currentOpPackageName() {
|
||||
ActivityThread am = currentActivityThread();
|
||||
return (am != null && am.getApplication() != null)
|
||||
? am.getApplication().getOpPackageName() : null;
|
||||
}
|
||||
|
||||
public static String currentPackageName() {
|
||||
ActivityThread am = currentActivityThread();
|
||||
return (am != null && am.mBoundApplication != null)
|
||||
|
||||
@@ -460,9 +460,8 @@ public class Camera {
|
||||
mEventHandler = null;
|
||||
}
|
||||
|
||||
String packageName = ActivityThread.currentPackageName();
|
||||
|
||||
return native_setup(new WeakReference<Camera>(this), cameraId, halVersion, packageName);
|
||||
return native_setup(new WeakReference<Camera>(this), cameraId, halVersion,
|
||||
ActivityThread.currentOpPackageName());
|
||||
}
|
||||
|
||||
private int cameraInitNormal(int cameraId) {
|
||||
|
||||
@@ -38,13 +38,13 @@ interface ICameraService
|
||||
int getCameraInfo(int cameraId, out CameraInfo info);
|
||||
|
||||
int connect(ICameraClient client, int cameraId,
|
||||
String clientPackageName,
|
||||
String opPackageName,
|
||||
int clientUid,
|
||||
// Container for an ICamera object
|
||||
out BinderHolder device);
|
||||
|
||||
int connectDevice(ICameraDeviceCallbacks callbacks, int cameraId,
|
||||
String clientPackageName,
|
||||
String opPackageName,
|
||||
int clientUid,
|
||||
// Container for an ICameraDeviceUser object
|
||||
out BinderHolder device);
|
||||
@@ -69,7 +69,7 @@ interface ICameraService
|
||||
|
||||
int connectLegacy(ICameraClient client, int cameraId,
|
||||
int halVersion,
|
||||
String clientPackageName,
|
||||
String opPackageName,
|
||||
int clientUid,
|
||||
// Container for an ICamera object
|
||||
out BinderHolder device);
|
||||
|
||||
@@ -314,7 +314,7 @@ public final class CameraManager {
|
||||
"Camera service is currently unavailable");
|
||||
}
|
||||
cameraService.connectDevice(callbacks, id,
|
||||
mContext.getPackageName(), USE_CALLING_UID, holder);
|
||||
mContext.getOpPackageName(), USE_CALLING_UID, holder);
|
||||
cameraUser = ICameraDeviceUser.Stub.asInterface(holder.getBinder());
|
||||
} else {
|
||||
// Use legacy camera implementation for HAL1 devices
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.Application;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -380,7 +379,7 @@ public class AudioRecord
|
||||
int initResult = native_setup( new WeakReference<AudioRecord>(this),
|
||||
mAudioAttributes, mSampleRate, mChannelMask, mChannelIndexMask,
|
||||
mAudioFormat, mNativeBufferSizeInBytes,
|
||||
session, getMyOpPackageName());
|
||||
session, ActivityThread.currentOpPackageName());
|
||||
if (initResult != SUCCESS) {
|
||||
loge("Error code "+initResult+" when initializing native AudioRecord object.");
|
||||
return; // with mState == STATE_UNINITIALIZED
|
||||
@@ -1500,15 +1499,4 @@ public class AudioRecord
|
||||
private static void loge(String msg) {
|
||||
Log.e(TAG, msg);
|
||||
}
|
||||
|
||||
private static String getMyOpPackageName() {
|
||||
ActivityThread activityThread = ActivityThread.currentActivityThread();
|
||||
if (activityThread != null) {
|
||||
Application application = activityThread.getApplication();
|
||||
if (application != null) {
|
||||
return application.getOpPackageName();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Cannot create AudioRecord outside of an app");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package android.media;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.Application;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -113,7 +112,8 @@ public class MediaRecorder
|
||||
/* Native setup requires a weak reference to our object.
|
||||
* It's easier to create it here than in C++.
|
||||
*/
|
||||
native_setup(new WeakReference<MediaRecorder>(this), packageName, getMyOpPackageName());
|
||||
native_setup(new WeakReference<MediaRecorder>(this), packageName,
|
||||
ActivityThread.currentOpPackageName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1096,15 +1096,4 @@ public class MediaRecorder
|
||||
|
||||
@Override
|
||||
protected void finalize() { native_finalize(); }
|
||||
|
||||
private static String getMyOpPackageName() {
|
||||
ActivityThread activityThread = ActivityThread.currentActivityThread();
|
||||
if (activityThread != null) {
|
||||
Application application = activityThread.getApplication();
|
||||
if (application != null) {
|
||||
return application.getOpPackageName();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Cannot create AudioRecord outside of an app");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package android.media.audiofx;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SdkConstant.SdkConstantType;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.Application;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
@@ -397,7 +396,7 @@ public class AudioEffect {
|
||||
// native initialization
|
||||
int initResult = native_setup(new WeakReference<AudioEffect>(this),
|
||||
type.toString(), uuid.toString(), priority, audioSession, id,
|
||||
desc, getMyOpPackageName());
|
||||
desc, ActivityThread.currentOpPackageName());
|
||||
if (initResult != SUCCESS && initResult != ALREADY_EXISTS) {
|
||||
Log.e(TAG, "Error code " + initResult
|
||||
+ " when initializing AudioEffect.");
|
||||
@@ -1359,15 +1358,4 @@ public class AudioEffect {
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
private static String getMyOpPackageName() {
|
||||
ActivityThread activityThread = ActivityThread.currentActivityThread();
|
||||
if (activityThread != null) {
|
||||
Application application = activityThread.getApplication();
|
||||
if (application != null) {
|
||||
return application.getOpPackageName();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Cannot create AudioEffect outside of an app");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package android.media.audiofx;
|
||||
|
||||
import android.app.ActivityThread;
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
import java.lang.ref.WeakReference;
|
||||
import android.os.Handler;
|
||||
@@ -209,7 +208,7 @@ public class Visualizer {
|
||||
mState = STATE_UNINITIALIZED;
|
||||
// native initialization
|
||||
int result = native_setup(new WeakReference<Visualizer>(this), audioSession, id,
|
||||
getMyOpPackageName());
|
||||
ActivityThread.currentOpPackageName());
|
||||
if (result != SUCCESS && result != ALREADY_EXISTS) {
|
||||
Log.e(TAG, "Error code "+result+" when initializing Visualizer.");
|
||||
switch (result) {
|
||||
@@ -769,16 +768,5 @@ public class Visualizer {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String getMyOpPackageName() {
|
||||
ActivityThread activityThread = ActivityThread.currentActivityThread();
|
||||
if (activityThread != null) {
|
||||
Application application = activityThread.getApplication();
|
||||
if (application != null) {
|
||||
return application.getOpPackageName();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Cannot create AudioRecord outside of an app");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user